From 06610321d62c5fb16719eca623ebb6025b58614d Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Mon, 30 Jan 2023 11:19:22 -0700 Subject: [PATCH 001/159] added .gitignore --- .gitignore | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..b7bea7f384 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +# Ignore .o files, these are built when running +*.o +*.mod +*.a + +# Build testing file +driver/run/cosp2_test From 633e2e1cf2f0cc224dde7fea6c303ee8291da541 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Mon, 6 Feb 2023 13:33:47 -0700 Subject: [PATCH 002/159] pre-pull commit --- .gitignore | 3 +++ build/Makefile.conf | 2 ++ 2 files changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index b7bea7f384..64b2537769 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ # Build testing file driver/run/cosp2_test + +# Ignore changes to the testing files for data +*.nc diff --git a/build/Makefile.conf b/build/Makefile.conf index 7c6e79379b..d5c9ba6d29 100644 --- a/build/Makefile.conf +++ b/build/Makefile.conf @@ -2,5 +2,7 @@ #F90FLAGS = -O3 -ffree-line-length-none -fcheck=bounds -finit-real=nan F90_LIB = /home/runner/netcdf-fortran +#F90_LIB = /glade/u/apps/dav/opt/netcdf/4.8.1/gnu/9.1.0 +#F90_LIB = /glade/u/apps/dav/opt/netcdf/4.8.1/gnu/10.1.0 NC_INC = -I$(F90_LIB)/include NC_LIB = -L$(F90_LIB)/lib From 071a6c3304d354588375a75361a7cbbcc60dba0e Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 7 Feb 2023 16:47:07 -0700 Subject: [PATCH 003/159] Create rttov input/output test files and the RTTOV v13 code files. The RTTOV v13 code files are copies of cosp_rttov_interface.F90 and cosp_rttov11.F90 No changes made yet. --- driver/run/cosp2_input_rttov_nl.txt | 96 ++ driver/run/cosp2_output_rttov_nl.txt | 152 +++ src/simulator/cosp_rttov_interface_v13.F90 | 143 +++ src/simulator/rttov/cosp_rttov_v13.F90 | 1060 ++++++++++++++++++++ 4 files changed, 1451 insertions(+) create mode 100644 driver/run/cosp2_input_rttov_nl.txt create mode 100755 driver/run/cosp2_output_rttov_nl.txt create mode 100644 src/simulator/cosp_rttov_interface_v13.F90 create mode 100644 src/simulator/rttov/cosp_rttov_v13.F90 diff --git a/driver/run/cosp2_input_rttov_nl.txt b/driver/run/cosp2_input_rttov_nl.txt new file mode 100644 index 0000000000..3b3d6319ac --- /dev/null +++ b/driver/run/cosp2_input_rttov_nl.txt @@ -0,0 +1,96 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&COSP_INPUT + NPOINTS=153,! Number of gridpoints 153,27840,7081,6912 + NPOINTS_IT=5000,! Max number of gridpoints to be processed in one iteration + NCOLUMNS=20, ! Number of subcolumns + NLEVELS=38, ! Number of model levels + USE_VGRID=.true., ! Use fixed vertical grid for outputs? (if .true. then you need to define number of levels with Nlr) + NLVGRID=40, ! Number of levels in statistical outputs (only used if USE_VGRID=.true.) + CSAT_VGRID=.true., ! CloudSat vertical grid? (if .true. then the CloudSat standard grid is used for the outputs. + ! USE_VGRID needs also be .true.) + DINPUT='./', ! Directory where the input files are located. Useful when processing multiple files. + ! Leave blank ('') if you are using the full path in FINPUT. + FINPUT='../data/inputs/UKMO/cosp_input_um.nc', ! List input NetCDF files + FOUTPUT='../data/outputs/UKMO/cosp2_output_rttov_um.nc', + !---------------------------------------------------------------------------------- + !--------------- Inputs related to radar simulations + !---------------------------------------------------------------------------------- + cloudsat_RADAR_FREQ=94.0, ! CloudSat radar frequency (GHz) + SURFACE_RADAR=0, ! surface=1, spaceborne=0 + cloudsat_use_gas_abs=1, ! include gaseous absorption? yes=1,no=0 + cloudsat_do_ray=0, ! calculate/output Rayleigh refl=1, not=0 + cloudsat_k2=-1, ! |K|^2, -1=use frequency dependent default + use_precipitation_fluxes=.true., ! True if precipitation fluxes are input to the algorithm + cloudsat_micro_scheme='MMF_v3_single_moment', !'MMF_v3.5_two_moment' + !---------------------------------------------------------------------------------- + !---------------- Inputs related to lidar simulations + !---------------------------------------------------------------------------------- + lidar_ice_type=0, ! Ice particle shape in lidar calculations (0=ice-spheres ; 1=ice-non-spherical) + OVERLAP=3, ! overlap assumption used by scops: 1=max, 2=rand, 3=max/rand + !---------------------------------------------------------------------------------- + !---------------- Inputs related to ISCCP simulator + !---------------------------------------------------------------------------------- + ISCCP_TOPHEIGHT=1, ! 1 = adjust top height using both a computed + ! infrared brightness temperature and the visible + ! optical depth to adjust cloud top pressure. Note + ! that this calculation is most appropriate to compare + ! to ISCCP data during sunlit hours. + ! 2 = do not adjust top height, that is cloud top + ! pressure is the actual cloud top pressure + ! in the model + ! 3 = adjust top height using only the computed + ! infrared brightness temperature. Note that this + ! calculation is most appropriate to compare to ISCCP + ! IR only algortihm (i.e. you can compare to nighttime + ! ISCCP data with this option) + ISCCP_TOPHEIGHT_DIRECTION=2, ! direction for finding atmosphere pressure level + ! with interpolated temperature equal to the radiance + ! determined cloud-top temperature + ! 1 = find the *lowest* altitude (highest pressure) level + ! with interpolated temperature equal to the radiance + ! determined cloud-top temperature + ! 2 = find the *highest* altitude (lowest pressure) level + ! with interpolated temperature equal to the radiance + ! determined cloud-top temperature. This is the + ! default value since V4.0 of the ISCCP simulator. + ! ONLY APPLICABLE IF top_height EQUALS 1 or 3 + !---------------------------------------------------------------------------------- + !-------------- RTTOV inputs + !---------------------------------------------------------------------------------- + rttov_Platform=1, ! satellite platform + rttov_Satellite=15, ! satellite + rttov_Instrument=5, ! instrument + rttov_Nchannels=3, ! Number of channels to be computed + rttov_Channels=1,2,3, ! Channel numbers (please be sure that you supply Nchannels) + rttov_Surfem=0.0,0.0,0.0, ! Surface emissivity (please be sure that you supply Nchannels) + rttov_ZenAng=50.0, ! Satellite Zenith Angle + CO2=5.241e-04, ! Mixing ratios of trace gases + CH4=9.139e-07, + N2O=4.665e-07, + CO=2.098e-07 +/ diff --git a/driver/run/cosp2_output_rttov_nl.txt b/driver/run/cosp2_output_rttov_nl.txt new file mode 100755 index 0000000000..e9a4f7c8b1 --- /dev/null +++ b/driver/run/cosp2_output_rttov_nl.txt @@ -0,0 +1,152 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +! Namelist that sets up output-related variables. It controls +! the instrument simulators to run and the list of variables +! to be written to file +&COSP_OUTPUT + !- CloudSat + Lcfaddbze94=.true., + Ldbze94=.true., + !- CALIPSO + Latb532=.true., + LcfadLidarsr532=.true., + Lclcalipso=.true., + Lclhcalipso=.true., + Lcllcalipso=.true., + Lclmcalipso=.true., + Lcltcalipso=.true., + LparasolRefl=.true., + ! CALIPSO phase diagnostics + Lclcalipsoliq=.true., + Lclcalipsoice=.true., + Lclcalipsoun=.true., + Lclcalipsotmp=.true., + Lclcalipsotmpliq=.true., + Lclcalipsotmpice=.true., + Lclcalipsotmpun=.true., + Lclhcalipsoliq=.true., + Lcllcalipsoliq=.true., + Lclmcalipsoliq=.true., + Lcltcalipsoliq=.true., + Lclhcalipsoice=.true., + Lcllcalipsoice=.true., + Lclmcalipsoice=.true., + Lcltcalipsoice=.true., + Lclhcalipsoun=.true., + Lcllcalipsoun=.true., + Lclmcalipsoun=.true., + Lcltcalipsoun=.true., + ! CALIPSO OPAQ diagnostics + Lclopaquecalipso=.true., + Lclthincalipso=.true., + Lclzopaquecalipso=.true., + Lclcalipsoopaque=.true., + Lclcalipsothin=.true., + Lclcalipsozopaque=.true., + Lclcalipsoopacity=.true., + Lclopaquetemp=.true., + Lclthintemp=.true., + Lclzopaquetemp=.true., + Lclopaquemeanz=.true., + Lclthinmeanz=.true., + Lclthinemis=.true., + Lclopaquemeanzse=.true., + Lclthinmeanzse=.true., + Lclzopaquecalipsose=.true., + ! GROUND LIDAR diagnostics + LlidarBetaMol532gr=.true., + LcfadLidarsr532gr=.true., + Latb532gr=.true., + LclgrLidar532=.true., + LclhgrLidar532=.true., + LcllgrLidar532=.true., + LclmgrLidar532=.true., + LcltgrLidar532=.true., + ! ATLID diagnostics + LlidarBetaMol355=.true., + LcfadLidarsr355=.true., + Latb355=.true., + Lclatlid=.true., + Lclhatlid=.true., + Lcllatlid=.true., + Lclmatlid=.true., + Lcltatlid=.true., + !- ISCCP + Lalbisccp=.true., + Lboxptopisccp=.true., + Lboxtauisccp=.true., + Lpctisccp=.true., + Lclisccp=.true., + Ltauisccp=.true., + Lcltisccp=.true., + Lmeantbisccp=.true., + Lmeantbclrisccp=.true., + !- MISR + LclMISR=.true., + !- Use lidar and radar + Lclcalipso2=.true., + Lcltlidarradar=.true., + Lcloudsat_tcc=.true., + Lcloudsat_tcc2=.true., + !- These are provided for debugging or special purposes + Lfracout=.true., + LlidarBetaMol532=.true., + !- MODIS + Lcltmodis=.true., + Lclwmodis=.true., + Lclimodis=.true., + Lclhmodis=.true., + Lclmmodis=.true., + Lcllmodis=.true., + Ltautmodis=.true., + Ltauwmodis=.true., + Ltauimodis=.true., + Ltautlogmodis=.true., + Ltauwlogmodis=.true., + Ltauilogmodis=.true., + Lreffclwmodis=.true., + Lreffclimodis=.true., + Lpctmodis=.true., + Llwpmodis=.true., + Liwpmodis=.true., + Lclmodis=.true., + !- RTTOV + Ltbrttov=.true., + ! -CLOUDSAT precipitation frequency/occurence diagnostics + Lptradarflag0=.true., + Lptradarflag1=.true., + Lptradarflag2=.true., + Lptradarflag3=.true., + Lptradarflag4=.true., + Lptradarflag5=.true., + Lptradarflag6=.true., + Lptradarflag7=.true., + Lptradarflag8=.true., + Lptradarflag9=.true., + Lradarpia=.true., + !- CloudSat+MODIS joint diagnostics + Lwr_occfreq=.true., + Lcfodd=.true. +/ diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 new file mode 100644 index 0000000000..b7a6ec65a6 --- /dev/null +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -0,0 +1,143 @@ +! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +! Copyright (c) 2015, Regents of the University of Colorado +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are +! permitted provided that the following conditions are met: +! +! 1. Redistributions of source code must retain the above copyright notice, this list of +! conditions and the following disclaimer. +! +! 2. Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other +! materials provided with the distribution. +! +! 3. Neither the name of the copyright holder nor the names of its contributors may be +! used to endorse or promote products derived from this software without specific prior +! written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +! MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +! THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +! OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +! +! History +! May 2015 - D. Swales - Original version +! Apr 2015 - D. Swales - Modified for RTTOVv11.3 +! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +MODULE MOD_COSP_RTTOV_INTERFACE + USE COSP_KINDS, ONLY: wp + USE MOD_COSP_CONFIG, ONLY: RTTOV_MAX_CHANNELS,rttovDir + use mod_cosp_rttov, only: platform,satellite,sensor,nChannels,iChannel,coef_rttov, & + coef_scatt,opts,opts_scatt,construct_rttov_coeffilename, & + construct_rttov_scatfilename + IMPLICIT NONE +#include "rttov_read_coefs.interface" +#include "rttov_read_scattcoeffs.interface" + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! TYPE rttov_in + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + type rttov_in + integer,pointer :: & + nPoints, & ! Number of profiles to simulate + nLevels, & ! Number of levels + nSubCols, & ! Number of subcolumns + month ! Month (needed for surface emissivity calculation) + real(wp),pointer :: & + zenang, & ! Satellite zenith angle + co2, & ! Carbon dioxide + ch4, & ! Methane + n2o, & ! n2o + co ! Carbon monoxide + real(wp),dimension(:),pointer :: & + surfem ! Surface emissivities for the channels + real(wp),dimension(:),pointer :: & + h_surf, & ! Surface height + u_surf, & ! U component of surface wind + v_surf, & ! V component of surface wind + t_skin, & ! Surface skin temperature + p_surf, & ! Surface pressure + t2m, & ! 2 m Temperature + q2m, & ! 2 m Specific humidity + lsmask, & ! land-sea mask + latitude, & ! Latitude + longitude, & ! Longitude + seaice ! Sea-ice? + real(wp),dimension(:,:),pointer :: & + p, & ! Pressure @ model levels + ph, & ! Pressure @ model half levels + t, & ! Temperature + q, & ! Specific humidity + o3 ! Ozone + + ! These fields below are needed ONLY for the RTTOV all-sky brightness temperature + real(wp),dimension(:,:),pointer :: & + tca, & ! Cloud fraction + cldIce, & ! Cloud ice + cldLiq, & ! Cloud liquid + fl_rain, & ! Precipitation flux (startiform+convective rain) (kg/m2/s) + fl_snow ! Precipitation flux (stratiform+convective snow) + end type rttov_in +CONTAINS + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE cosp_rttov_init + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN) + integer,intent(in) :: & + NchanIN, & ! Number of channels + platformIN, & ! Satellite platform + satelliteIN, & ! Satellite + instrumentIN ! Instrument + integer,intent(in),dimension(RTTOV_MAX_CHANNELS) :: & + channelsIN ! RTTOV channels + + ! Local variables + character(len=256) :: coef_file,scat_file + integer :: errorstatus + + ! Initialize fields in module memory (cosp_rttovXX.F90) + nChannels = NchanIN + platform = platformIN + satellite = satelliteIN + sensor = instrumentIN + iChannel = channelsIN + + ! Options common to RTTOV clear-sky Tb calculation + opts%interpolation%addinterp = .true. ! allow interpolation of input profile + opts%rt_all%use_q2m = .true. + opts%config%do_checkinput = .false. + opts%config%verbose = .false. + opts%rt_all%addrefrac = .true. ! include refraction in path calc + opts%interpolation%reg_limit_extrap = .true. + ! Options common to RTTOV clear-sky Tb calculation + opts_scatt%config%do_checkinput = .false. + opts_scatt%config%verbose = .false. + opts_scatt%config%apply_reg_limits = .true. + opts_scatt%interp_mode = 1 + opts_scatt%reg_limit_extrap = .true. + opts_scatt%use_q2m = .true. + opts%rt_mw%clw_data = .true. + + ! Read in scattering coefficient file. + coef_file = trim(rttovDir)//"rtcoef_rttov11/rttov7pred54L/"// & + trim(construct_rttov_coeffilename(platform,satellite,sensor)) + call rttov_read_coefs(errorstatus,coef_rttov, opts, file_coef=trim(coef_file)) + + ! Read in scattering (clouds+aerosol) coefficient file. *ONLY NEEDED IF DOING RTTOV ALL-SKY.* + !scat_file = trim(rttovDir)//"rtcoef_rttov11/cldaer/"//& + ! trim(construct_rttov_scatfilename(platform,satellite,sensor)) + ! Can't pass filename to rttov_read_scattcoeffs!!!!! + !call rttov_read_scattcoeffs (errorstatus, coef_rttov%coef, coef_scatt,) + + END SUBROUTINE COSP_RTTOV_INIT + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! END MODULE + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +END MODULE MOD_COSP_RTTOV_INTERFACE diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 new file mode 100644 index 0000000000..94d82379c5 --- /dev/null +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -0,0 +1,1060 @@ +! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +! Copyright (c) 2016, Regents of the University of Colorado +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are +! permitted provided that the following conditions are met: +! +! 1. Redistributions of source code must retain the above copyright notice, this list of +! conditions and the following disclaimer. +! +! 2. Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other +! materials provided with the distribution. +! +! 3. Neither the name of the copyright holder nor the names of its contributors may be +! used to endorse or promote products derived from this software without specific prior +! written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +! MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +! THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +! OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +! +! History +! March 2016 - M. Johnston - Original version +! April 2016 - D. Swales - Modified for use in COSPv2.0 +! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +module mod_cosp_rttov + use rttov_const, only : errorstatus_success, errorstatus_fatal + use rttov_types, only : rttov_options,rttov_coefs,profile_type, & + transmission_type,radiance_type,rttov_chanprof, & + rttov_emissivity,profile_cloud_type,rttov_scatt_coef, & + rttov_options_scatt + use rttov_const, only : surftype_sea, surftype_land, surftype_seaice + use rttov_unix_env, only : rttov_exit + use cosp_kinds, only : wp + use mod_cosp_config, only : RTTOV_MAX_CHANNELS,N_HYDRO,rttovDir + use cosp_phys_constants, only : mdry=>amd,mO3=>amO3,mco2=>amCO2,mCH4=>amCH4, & + mn2o=>amN2O,mco=>amCO + implicit none +#include "rttov_direct.interface" +#include "rttov_alloc_prof.interface" +#include "rttov_alloc_rad.interface" +#include "rttov_alloc_transmission.interface" +#include "rttov_dealloc_coefs.interface" +#include "rttov_user_options_checkinput.interface" +#include "rttov_read_coefs.interface" +#include "rttov_get_emis.interface" +#include "rttov_boundaryconditions.interface" + + ! Module parameters + integer, parameter :: maxlim = 10000 + real(wp),parameter :: eps = 0.622 + + ! Initialization parameters + integer :: & + platform, & ! RTTOV platform + sensor, & ! RTTOV instrument + satellite, & ! RTTOV satellite + nChannels ! Number of channels + integer,dimension(RTTOV_MAX_CHANNELS) :: & + iChannel ! RTTOV channel numbers + + ! Scattering coefficients (read in once during initialization) + type(rttov_coefs) :: & + coef_rttov + type(rttov_scatt_coef) :: & + coef_scatt + ! RTTOV setup and options (set during initialization) + type(rttov_options) :: & + opts ! defaults to everything optional switched off + type(rttov_options_scatt) :: & + opts_scatt +contains + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE rttov_column + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine rttov_column(nPoints,nLevels,nSubCols,q,p,t,o3,ph,h_surf,u_surf,v_surf, & + p_surf,t_skin,t2m,q2m,lsmask,lon,lat,seaice,co2,ch4,n2o,co, & + zenang,lCleanup, & + ! Outputs + Tb,error, & + ! Optional arguments for surface emissivity calculation. + surfem,month, & + ! Optional arguments for all-sky calculation. + tca,ciw,clw,rain,snow) + ! Inputs + integer,intent(in) :: & + nPoints, & ! Number of gridpoints + nLevels, & ! Number of vertical levels + nSubCols ! Number of subcolumns + real(wp),intent(in) :: & + co2, & ! CO2 mixing ratio (kg/kg) + ch4, & ! CH4 mixing ratio (kg/kg) + n2o, & ! N2O mixing ratio (kg/kg) + co, & ! CO mixing ratio (kg/kg) + zenang ! Satellite zenith angle + real(wp),dimension(nPoints),intent(in) :: & + h_surf, & ! Surface height (m) + u_surf, & ! Surface u-wind (m/s) + v_surf, & ! Surface v-wind (m/s) + p_surf, & ! Surface pressure (Pa) + t_skin, & ! Skin temperature (K) + t2m, & ! 2-meter temperature (K) + q2m, & ! 2-meter specific humidity (kg/kg) + lsmask, & ! Land/sea mask + lon, & ! Longitude (deg) + lat, & ! Latitude (deg) + seaice ! Seaice fraction (0-1) + real(wp),dimension(nPoints,nLevels),intent(in) :: & + q, & ! Specific humidity (kg/kg) + p, & ! Pressure(Pa) + t, & ! Temperature (K) + o3 ! Ozone + real(wp),dimension(nPoints,nLevels+1),intent(in) :: & + ph ! Pressure @ half-levels (Pa) + logical,intent(in) :: & + lCleanup ! Flag to determine whether to deallocate RTTOV types + + ! Optional inputs (Needed for surface emissivity calculation) + integer,optional :: & + month ! Month (needed to determine table to load) + real(wp),dimension(nChannels),optional :: & + surfem ! Surface emissivity for each RTTOV channel + + ! Optional inputs (Needed for all-sky calculation) + real(wp),dimension(nPoints,nLevels),optional :: & + tca ! Total column cloud amount (0-1) + real(wp),dimension(nPoints,nSubCols,nLevels),optional :: & + ciw, & ! Cloud ice + clw, & ! Cloud liquid + rain, & ! Precipitation flux (kg/m2/s) + snow ! Precipitation flux (kg/m2/s) + + ! Outputs + real(wp),dimension(nPoints,nChannels) :: & + Tb ! RTTOV brightness temperature. + character(len=128) :: & + error ! Error messages (only populated if error encountered) + + ! Local variables + integer :: & + nloop,rmod,il,istart,istop,za,i,j,subcol,errorstatus,npts_it + integer,dimension(60) :: & + alloc_status + real(wp),dimension(nPoints) :: & + sh_surf + real(wp),dimension(nPoints,nLevels) :: & + sh,totalice + real(wp),dimension(nSubCols,nPoints,nChannels) :: & + Tbs ! Subcolumn brightness temperature + logical :: & + use_totalice, mmr_snowrain, cfrac + logical :: & + lallSky, & ! Control for type of brightness temperature calculation + ! (False(default) => clear-sky brightness temperature, True => All-sky) + lsfcEmis ! Control for surface emissivity calculation (true => compute surface emissivity, + ! provided that the field "month" is available) + +#include "rttov_read_coefs.interface" +#include "rttov_read_scattcoeffs.interface" +#include "rttov_user_options_checkinput.interface" +#include "rttov_dealloc_coefs.interface" +#include "rttov_dealloc_scattcoeffs.interface" +#include "rttov_setup_emis_atlas.interface" +#include "rttov_deallocate_emis_atlas.interface" +#include "rttov_print_opts.interface" +#include "rttov_print_profile.interface" +#include "rttov_boundaryconditions.interface" + + ! Initialize some things + totalice = 0._wp + Tbs(:,:,:) = 0._wp + Tb(:,:) = 0._wp + error = '' + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Setup for call to RTTOV + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! First, check to see if we are doing an all-sky or clear-sky calculation brightness + ! temperature + lallSky = .false. + if (present(tca) .and. present(clw) .and. present(ciw) .and. present(rain) & + .and. present(snow)) lallSky=.true. + + ! Check to see if we need to compute the surface emissivity (defualt is to compute + ! surface emissivity using the atlas tables) + lsfcEmis = .true. + if (present(surfem)) lsfcEmis = .false. + + ! We also need the month for the emissivity atlas, so check... + if (.not. present(month)) lsfcEmis = .false. + + if (lsfcEmis .eq. .false. .and. .not. present(surfem)) then + error = 'ERROR (rttov_column): User did not provide surface emissivity and did not '//& + 'request the surface emissivity to be calculated!!!' + return + endif + + ! Convert specific humidity to ppmv + sh = ( q / ( q + eps * ( 1._wp - q ) ) ) * 1e6 + sh_surf = ( q2m / ( q2m + eps * ( 1._wp - q2m ) ) ) * 1e6 + + ! Settings unique to all-sky call. + use_totalice = .false. + mmr_snowrain = .true. + cfrac = .true. + opts_scatt%lusercfrac = cfrac + + ! RTTOV can handle only about 100 profiles at a time (fixme: check this with roger), + ! so we are putting a loop of 100 + nloop = npoints / maxlim + rmod = mod( npoints, maxlim ) + if( rmod .ne. 0 ) then + nloop = nloop + 1 + endif + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Initialize emissivity atlas data for chosen sensor. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + call rttov_setup_emis_atlas(errorstatus,opts,month,coef_rttov,path=trim(rttovDir)//"emis_data/") + if (errorstatus /= errorstatus_success) then + error = 'ERROR (rttov_column): Error reading emis atlas data!' + return + endif + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Some quality control prior to RTTOV call + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Ensure the options and coefficients are consistent + if(opts_scatt%config%do_checkinput) then + call rttov_user_options_checkinput(errorstatus, opts, coef_rttov) + if (errorstatus /= errorstatus_success) then + error = 'ERROR (rttov_column): Error when checking input data!' + return + endif + endif + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Call to RTTOV + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Looping over maxlim number of profiles + do il = 1, nloop + istart = (il - 1) * maxlim + 1 + istop = min(il * maxlim, npoints) + if( ( il .eq. nloop ) .and. ( rmod .ne. 0 ) ) then + npts_it = rmod + else + npts_it = maxlim + endif + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Clear-sky brightness temperature + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + if (.not. lallSky) then + call rttov_multprof(nChannels,iChannel,surfem,npts_it,nLevels,platform, & + satellite,sensor,opts,coef_rttov,zenang, & + p(istart:istop,:)/100._wp,t(istart:istop,:), & + sh(istart:istop,:),(mdry/mo3)*o3(istart:istop,:)*1e6, & + (mdry/mco2)*co2*1e6,(mdry/mch4)*ch4*1e6,(mdry/mn2o)*n2o*1e6,& + (mdry/mco)*co*1e6,h_surf(istart:istop),u_surf(istart:istop),& + v_surf(istart:istop),t_skin(istart:istop), & + p_surf(istart:istop)/100.,t2m(istart:istop), & + sh_surf(istart:istop),lsmask(istart:istop), & + seaice(istart:istop),lat(istart:istop),lon(istart:istop), & + Tb(istart:istop,:)) + endif + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! All-sky brightness temperature + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + if (lallSky) then + ! Loop over all subcolumns + do subcol = 1, nSubCols + ! Call RTTOV + call cosp_rttov_mwscatt(nChannels,iChannel,surfem,nPoints,nlevels,platform, & + satellite,sensor,opts,opts_scatt,coef_rttov, & + coef_scatt,zenang,p(istart:istop,:)/100._wp, & + ph(istart:istop,:)/100._wp,t(istart:istop, :), & + sh(istart:istop, :), & + (mdry/mo3)*o3(istart:istop,:)*1e6, & + clw(istart:istop,subcol,:), & + ciw(istart:istop,subcol,:),tca(istart:istop, :), & + totalice(istart:istop,:),snow(istart:istop,subcol,:),& + rain(istart:istop,subcol,:),(mdry/mco2)*co2*1e6, & + (mdry/mch4)*ch4*1e6,(mdry/mn2o)*n2o*1e6, & + (mdry/mco)*co*1e6,h_surf(istart:istop), & + u_surf(istart:istop),v_surf(istart:istop), & + t_skin(istart:istop), p_surf(istart:istop)/100., & + t2m(istart:istop),sh_surf(istart:istop), & + lsmask(istart:istop),seaice(istart:istop), & + lat(istart:istop),lon(istart:istop), use_totalice, & + mmr_snowrain,cfrac,Tbs(subcol,istart:istop,:)) + enddo + endif + enddo + + ! For all-sky calculation we need to average together all of the cloudy subcolumns. + if (lallSky) then + do subcol = 1, nSubCols + Tb = Tb + tbs(subcol,:,:) + enddo + Tb = Tb/nSubCols + endif + + ! Free up space + if (lCleanup) then + call rttov_dealloc_coefs(errorstatus,coef_rttov) + call rttov_deallocate_emis_atlas(coef_rttov) + if (lallSky) call rttov_dealloc_scattcoeffs(coef_scatt) + endif + end subroutine rttov_column + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE rttov_multprof + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine rttov_multprof( & + nch_in, & ! number of channels + ichan_in, & ! channel indices + surfem_in, & ! surface emissivity values + prf_num_in, & ! number of profiles to simulate + nlevels_in, & ! number of pressure levels + plat_in, & ! platform number + sat_in, & ! satellite number + sens_in, & ! instrument number + opts, & + coef_rttov, & + zenang_in, & ! zenith angle + p_in, & ! pressure [hpa] + t_in, & ! temperature [ k ] + q_in, & ! specific humidity [ ppmv ] + o3_in, & ! ozone vmr [ ppmv ] + co2_in, & ! co2 vmr [ ppmv ] *this is a single value* + ch4_in, & ! ch4 vmr [ ppmv ] *this is a single value* + n2o_in, & ! n2o vmr [ ppmv ] *this is a single value* + co_in, & ! co vmr [ ppmv ] *this is a single value* + h_surf, & ! surface height [ m ] + u_surf, & ! u wind at 10 m [ m/s ] + v_surf, & ! v wind at 10 m [ m/s ] + t_skin, & ! skin temperatre [ k ] + p_surf, & ! surface pressure + t_surf, & ! 1.5 m temperature [ k ] + q_surf, & ! 1.5 m specific humidity [ ppmv ] + lsmask, & ! land sea mask + seaice, & ! seaice fraction + latitude, & ! latitude [ deg north ] + longitude, & ! longitude [ deg east ] + tbs & ! brightness temperature [ k ] (output) + ) + + !------ input arguments. no rttov kinds should be used here ----------------- + integer, intent(in) :: nch_in ! number of channels to be computed + integer, intent(in) :: ichan_in(nch_in) ! indices of selected channels + real(wp), intent(in) :: surfem_in(nch_in) ! surface emissivities for the channels + integer, intent(in) :: prf_num_in + integer, intent(in) :: nlevels_in + integer, intent(in) :: plat_in ! satellite platform + integer, intent(in) :: sat_in ! satellite number + integer, intent(in) :: sens_in ! satellite sensor + real(wp), intent(in) :: zenang_in ! satellite zenith angle + + type(rttov_options) :: opts + type(rttov_coefs) :: coef_rttov + + real(wp), intent(in) :: p_in(prf_num_in, nlevels_in) ! pressure profiles + real(wp), intent(in) :: t_in(prf_num_in, nlevels_in) ! temperature profiles + real(wp), intent(in) :: q_in(prf_num_in, nlevels_in) ! humidity profiles + real(wp), intent(in) :: o3_in(prf_num_in, nlevels_in) ! ozone profiles + + ! the following trace gases contain constant values + real(wp), intent(in) :: co2_in ! carbon dioxide + real(wp), intent(in) :: ch4_in ! methane + real(wp), intent(in) :: n2o_in ! n2o + real(wp), intent(in) :: co_in ! carbon monoxide + real(wp), intent(in) :: h_surf(prf_num_in) ! surface height + real(wp), intent(in) :: u_surf(prf_num_in) ! u component of surface wind + real(wp), intent(in) :: v_surf(prf_num_in) ! v component of surface wind + real(wp), intent(in) :: t_skin(prf_num_in) ! surface skin temperature + real(wp), intent(in) :: p_surf(prf_num_in) ! surface pressure + real(wp), intent(in) :: t_surf(prf_num_in) ! 1.5 m temperature + real(wp), intent(in) :: q_surf(prf_num_in) ! 1.5 m specific humidity + real(wp), intent(in) :: lsmask(prf_num_in) ! land-sea mask + real(wp), intent(in) :: seaice(prf_num_in) ! sea-ice fraction + real(wp), intent(in) :: latitude(prf_num_in) ! latitude + real(wp), intent(in) :: longitude(prf_num_in) ! longitude + + real(wp), intent(inout) :: tbs(prf_num_in, nch_in) ! tbs (in the right format) + + !------ local variables. use only rttov kinds or derived types. + ! logical variables are declared with the same kind + ! as integers, as they are affected inthe same way by flags like -qintsize=8 + + ! type(rttov_options) :: opts ! options structure + ! type(rttov_coefs), allocatable :: coefs(:) ! coefficients structure + type(rttov_chanprof), allocatable :: chanprof(:) ! input channel/profile list + type(profile_type), allocatable :: profiles(:) ! input profiles + logical, allocatable :: calcemis(:) ! flag to indicate calculation of emissivity within rttov + type(rttov_emissivity), allocatable :: emissivity(:) ! input/output surface emissivity + type(transmission_type) :: transmission ! output transmittances + type(radiance_type) :: radiance ! output radiances + + integer, allocatable :: instrument(:,:) ! instrument id (3 x n_instruments) + integer, allocatable :: nchan(:) ! number of channels per instrument + integer, allocatable :: ichan(:,:) ! channel list per instrument + + integer :: asw + integer :: mxchn + integer :: nrttovid ! maximum number of instruments + integer :: no_id ! instrument loop index + integer :: i, j, jch + integer :: nprof ! number of calls to rttov + integer :: nch ! intermediate variable + integer :: errorstatus + integer :: ich, ich_temp, nchanprof, nchannels, chan + integer :: alloc_status(60) + + real(wp), allocatable :: input_emissivity (:) + + character (len=14) :: nameofroutine = 'rttov_multprof' + + logical :: refrac, solrad, laerosl, lclouds, lsun, all_channels + + ! local variables for input arguments that need type casting to avoid type-mismatch with + ! rttov kinds. this happens with some compiler flags (-qintsize=8). + integer :: prof_num + integer :: nlevels + + ! -------------------------------------------------------------------------- + ! 0. initialise cosp-specific things + ! -------------------------------------------------------------------------- + + ! type-casting of input arguments that need to be passed to rttov + prof_num = prf_num_in + nlevels = nlevels_in + nprof = prof_num + + ! currently we plan to calculate only 1 instrument per call + nrttovid = 1 + mxchn = nch_in + + errorstatus = 0 + alloc_status(:) = 0 + + ! allocate(coefs(nrttovid), stat = alloc_status(1)) + + ! allocate(instrument(3, nrttovid), stat = alloc_status(4)) + + !maximum number of channels allowed for one instrument is mxchn + ! allocate(surfem(nch_in, nrttovid), stat = alloc_status(11)) + allocate(ichan(nch_in, nrttovid), stat = alloc_status(12)) + call rttov_error('ichan mem allocation error for profile array' , lalloc = .true.) + + + do no_id = 1, nrttovid + ichan(:, no_id) = ichan_in + enddo + + asw = 1 ! switch for allocation passed into rttov subroutines + + ! allocate input profile arrays + allocate(profiles(nprof), stat = alloc_status(1)) + call rttov_error('Profile mem allocation error' , lalloc = .true.) + + call rttov_alloc_prof( & + errorstatus, & + nprof, & + profiles, & + nlevels, & + opts, & + asw, & + coefs = coef_rttov, & + init = .true.) + call rttov_error('Profile 2 mem allocation error' , lalloc = .true.) + ! -------------------------------------------------------------------------- + ! 5. store profile data in profile type + ! -------------------------------------------------------------------------- + do i = 1, nprof + profiles(i)%p(:) = p_in(i, :) + profiles(i)%t(:) = t_in(i, :) + profiles(i)%q(:) = q_in(i, :) + + where(profiles(i)%q(:) < 1e-4) + profiles(i)%q(:) = 1e-4 + end where + + profiles(i)%cfraction = 0. + profiles(i)%ctp = 500. + + ! 2m parameters + profiles(i)%s2m%p = p_surf(i) + profiles(i)%s2m%t = t_surf(i) + profiles(i)%s2m%q = q_surf(i) + profiles(i)%s2m%u = u_surf(i) ! dar: hard-coded at 2ms-1? + profiles(i)%s2m%v = v_surf(i) ! dar: hard-coded at 2ms-1? + profiles(i)%s2m%wfetc = 10000. ! dar: default? + + ! skin variables for emissivity calculations + profiles(i)%skin%t = t_skin(i) + + ! fastem coefficients - for mw calculations + profiles(i)%skin%fastem(1) = 3.0 + profiles(i)%skin%fastem(2) = 5.0 + profiles(i)%skin%fastem(3) = 15.0 + profiles(i)%skin%fastem(4) = 0.1 + profiles(i)%skin%fastem(5) = 0.3 + + profiles(i)%zenangle = zenang_in ! pass in from cosp + + profiles(i)%azangle = 0. ! hard-coded in rttov9 int + + profiles(i)%latitude = latitude(i) + profiles(i)%longitude = longitude(i) + profiles(i)%elevation = h_surf(i) + + profiles(i)%sunzenangle = 0. ! hard-coded in rttov9 int + profiles(i)%sunazangle = 0. ! hard-coded in rttov9 int + + ! surface type + ! land-sea mask indicates proportion of land in grid + if (lsmask(i) < 0.5) then + profiles(i)%skin%surftype = surftype_sea + else + profiles(i)%skin%surftype = surftype_land + endif + ! sea-ice fraction + if (seaice(i) >= 0.5) then + profiles(i)%skin%surftype = surftype_seaice + endif + + ! dar: hard-coded to 1 (=ocean water) in rttov 9 int + profiles(i)%skin%watertype = 1 + profiles(i) %idg = 0. + profiles(i) %ish = 0. + enddo + ! end of 5. + + ich_temp = 1 + nchannels = nch_in + do no_id = 1, nrttovid + + ! -------------------------------------------------------------------------- + ! 3. build the list of profile/channel indices in chanprof + ! -------------------------------------------------------------------------- + + allocate(nchan(nprof)) ! number of channels per profile + nchan(:) = size(ichan(:,no_id)) ! = nch_in + + ! size of chanprof array is total number of channels over all profiles + ! square in this case - here same channels done for all profiles + nchanprof = sum(nchan(:)) + + ! pack channels and input emissivity arrays + allocate(chanprof(nchanprof)) + ! allocate(emis(nchanprof)) + chanprof(:)%chan =0 + + nch = 0 + do j = 1, nprof + do jch = 1, nchan(j) + nch = nch + 1 + chanprof(nch)%prof = j + if(ichan(jch, no_id) < 1) then + errorstatus = errorstatus_fatal + call rttov_error('Sensor channel number must be 1 or greater' , lalloc = .true.) + else + chanprof(nch)%chan = ichan(jch, no_id) + endif + enddo + enddo + ! end of 3. + + ! allocate output radiance arrays + call rttov_alloc_rad( & + errorstatus, & + nchanprof, & + radiance, & + nlevels - 1, & ! nlayers + asw) + call rttov_error('allocation error for radiance arrays' , lalloc = .true.) + + ! allocate transmittance structure + call rttov_alloc_transmission( & + errorstatus, & + transmission, & + nlevels - 1, & + nchanprof, & + asw, & + init=.true.) + call rttov_error('allocation error for transmission arrays' , lalloc = .true.) + + ! allocate arrays for surface emissivity + allocate(calcemis(nchanprof), stat=alloc_status(1)) + allocate(emissivity(nchanprof), stat=alloc_status(2)) + call rttov_error('mem allocation error for emissivity arrays' , lalloc = .true.) + + call rttov_get_emis( & + & errorstatus, & + & opts, & + & chanprof, & + & profiles, & + & coef_rttov, & + !& resolution=resolution, & ! *** MW atlas native + ! resolution is 0.25 degree lat/lon; if you know better + ! value for satellite footprint (larger than this) then + ! you can specify it here + & emissivity=emissivity(:)%emis_in) + ! & emissivity(:)%emis_in) + + call rttov_error('Get emissivity error' , lalloc = .true.) + calcemis(:) = .false. + ! calculate emissivity for missing and ocean location (fastem) + where (emissivity(:)%emis_in <= 0.0) + calcemis(:) = .true. + endwhere + + call rttov_direct( & + errorstatus, &! out + chanprof, & + opts, & + profiles, &! in + coef_rttov, &! in + transmission, &! out + radiance, & + calcemis = calcemis, &! in + emissivity = emissivity) ! inout + call rttov_error('rttov_direct error', lalloc = .true.) + + tbs(1:prof_num , ich_temp:ich_temp + size(ichan(:,no_id)) - 1) = & + transpose(reshape(radiance%bt(1:nchanprof), (/ size(ichan(:,no_id)), prof_num/) )) + + ich_temp = ich_temp + size(ichan(:,no_id)) + + ! -------------------------------------------------------------------------- + ! 8. deallocate all rttov arrays and structures + ! -------------------------------------------------------------------------- + deallocate (nchan, stat=alloc_status(3)) + deallocate (chanprof, stat=alloc_status(4)) + deallocate (emissivity, stat=alloc_status(5)) + deallocate (calcemis, stat=alloc_status(6)) + call rttov_error('rttov array deallocation error', lalloc = .true.) + + asw = 0 ! switch for deallocation passed into rttov subroutines + + ! deallocate radiance arrays + call rttov_alloc_rad(errorstatus, nchannels, radiance, nlevels - 1, asw) + call rttov_error('radiance deallocation error', lalloc = .true.) + + ! deallocate transmission arrays + call rttov_alloc_transmission(errorstatus, transmission, nlevels - 1, nchannels, asw) + call rttov_error('transmission deallocation error', lalloc = .true.) + + enddo + + ! deallocate profile arrays + call rttov_alloc_prof(errorstatus, nprof, profiles, nlevels, opts, asw) + call rttov_error('profile deallocation error', lalloc = .true.) + + deallocate(profiles, stat=alloc_status(1)) + call rttov_error('mem deallocation error for profile array', lalloc= .true.) + + contains + + subroutine rttov_error(msg, lalloc) + character(*) :: msg + logical :: lalloc + + if(lalloc) then + if (any(alloc_status /= 0)) then + write(*,*) msg + errorstatus = 1 + call rttov_exit(errorstatus) + endif + else + if (errorstatus /= errorstatus_success) then + write(*,*) msg + call rttov_exit(errorstatus) + endif + endif + end subroutine rttov_error + + end subroutine rttov_multprof + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + !----------------- subroutine cosp_rttov_mwscatt --------------- + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + subroutine cosp_rttov_mwscatt(& + nch_in, & ! number of channels + ichan_in, & ! channel indices + surfem_in, & ! surface emissivity values + prf_num_in, & ! number of profiles to simulate + nlevels_in, & ! number of pressure levels + plat_in, & ! platform number + sat_in, & ! satellite number + sens_in, & ! instrument number + opts, & + opts_scatt, & + coef_rttov, & + coef_scatt, & + zenang_in, & ! zenith angle + p_in, & ! pressure [hpa] + ph_in, & ! pressure on half levels [hpa] + t_in, & ! temperature [ k ] + q_in, & ! specific humidity [ ppmv ] + o3_in, & ! ozone vmr [ ppmv ] + clw_in, & ! cloud water [0-1] + ciw_in, & ! cloud ice [0-1] + cc_in, & ! effective cloud fraction [0-1] + totalice_in,& ! total ice, except snow [kg/kg] or [kg/m2/s] + sp_in, & ! solid precip with snow [kg/kg] or [kg/m2/s] + rain_in, & ! total liquid water [kg/kg] or [kg/m2/s] + co2_in, & ! co2 vmr [ ppmv ] *this is a single value* + ch4_in, & ! ch4 vmr [ ppmv ] *this is a single value* + n2o_in, & ! n2o vmr [ ppmv ] *this is a single value* + co_in, & ! co vmr [ ppmv ] *this is a single value* + h_surf, & ! surface height [ m ] + u_surf, & ! u wind at 10 m [ m/s ] + v_surf, & ! v wind at 10 m [ m/s ] + t_skin, & ! skin temperatre [ k ] + p_surf, & ! surface pressure + t_surf, & ! 1.5 m temperature [ k ] + q_surf, & ! 1.5 m specific humidity [ ppmv ] + lsmask, & ! land sea mask + seaice, & ! seaice fraction + latitude, & ! latitude [ deg north ] + longitude, & ! longitude [ deg east ] + use_totalice,& ! separate ice and snow, or total ice hydrometeor types + mmr_snowrain,& ! set units for snow and rain: if true units are kg/kg (the default) + cfrac, & ! opts_scatt%lusercfrac=true., supply the effective cloud fraction + tbs & ! brightness temperature [ k ] (output) + ) + + + + + + implicit none + + !------ input arguments. no rttov kinds should be used here ----------------- + integer, intent(in) :: nch_in ! number of channels to be computed + integer, intent(in) :: ichan_in(nch_in) ! indices of selected channels + real(wp), intent(in) :: surfem_in(nch_in) ! surface emissivities for the channels + integer, intent(in) :: prf_num_in + integer, intent(in) :: nlevels_in + integer, intent(in) :: plat_in ! satellite platform + integer, intent(in) :: sat_in ! satellite number + integer, intent(in) :: sens_in ! satellite sensor + real(wp), intent(in) :: zenang_in ! satellite zenith angle + + type(rttov_options) :: opts + type(rttov_options_scatt) :: opts_scatt + type(rttov_coefs) :: coef_rttov + type(rttov_scatt_coef) :: coef_scatt + + real(wp), intent(in) :: p_in(prf_num_in, nlevels_in) ! pressure profiles + real(wp), intent(in) :: t_in(prf_num_in, nlevels_in) ! temperature profiles + real(wp), intent(in) :: q_in(prf_num_in, nlevels_in) ! humidity profiles + real(wp), intent(in) :: o3_in(prf_num_in, nlevels_in) ! ozone profiles + real(wp), intent(in) :: clw_in(prf_num_in, nlevels_in) + real(wp), intent(in) :: ciw_in(prf_num_in, nlevels_in) + real(wp), intent(in) :: cc_in(prf_num_in, nlevels_in) + real(wp), intent(in) :: totalice_in(prf_num_in, nlevels_in) + real(wp), intent(in) :: sp_in(prf_num_in, nlevels_in) + real(wp), intent(in) :: rain_in(prf_num_in, nlevels_in) + real(wp), intent(in) :: ph_in(prf_num_in, nlevels_in+1) + + ! the following trace gases contain constant values + real(wp), intent(in) :: co2_in ! carbon dioxide + real(wp), intent(in) :: ch4_in ! methane + real(wp), intent(in) :: n2o_in ! n2o + real(wp), intent(in) :: co_in ! carbon monoxide + real(wp), intent(in) :: h_surf(prf_num_in) ! surface height + real(wp), intent(in) :: u_surf(prf_num_in) ! u component of surface wind + real(wp), intent(in) :: v_surf(prf_num_in) ! v component of surface wind + real(wp), intent(in) :: t_skin(prf_num_in) ! surface skin temperature + real(wp), intent(in) :: p_surf(prf_num_in) ! surface pressure + real(wp), intent(in) :: t_surf(prf_num_in) ! 1.5 m temperature + real(wp), intent(in) :: q_surf(prf_num_in) ! 1.5 m specific humidity + real(wp), intent(in) :: lsmask(prf_num_in) ! land-sea mask + real(wp), intent(in) :: seaice(prf_num_in) ! seaice fraction + real(wp), intent(in) :: latitude(prf_num_in) ! latitude + real(wp), intent(in) :: longitude(prf_num_in) ! longitude + logical, intent(in) :: cfrac, use_totalice, mmr_snowrain + + real(wp), intent(inout) :: tbs(prf_num_in, nch_in) ! tbs (in the right format) + !****************** local variables ********************************************** + logical , allocatable :: calcemis (:) + type(rttov_emissivity) , allocatable :: emissivity (:) + integer , allocatable :: frequencies (:) + type(rttov_chanprof) , allocatable :: chanprof (:) ! channel and profile indices + type(profile_type) , allocatable :: profiles (:) + type(profile_cloud_type) , allocatable :: cld_profiles(:) + + integer, allocatable :: ichan(:,:) ! channel list per instrument + + integer :: errorstatus + type (radiance_type) :: radiance + ! type (rttov_options) :: opts ! defaults to everything optional switched off + ! type (rttov_options_scatt) :: opts_scatt + ! type (rttov_coefs) :: coef_rttov + ! type (rttov_scatt_coef) :: coef_scatt + + ! integer, allocatable :: instrument (:,:) + integer :: j,k,asw + integer :: nchanxnprof, ninstruments + real(wp) :: zenangle + character (len=256) :: outstring + integer :: alloc_status(60) + +#include "rttov_init_rad.interface" +#include "rttov_scatt_setupindex.interface" +#include "rttov_scatt.interface" +#include "rttov_alloc_rad.interface" +#include "rttov_alloc_prof.interface" +#include "rttov_alloc_scatt_prof.interface" +#include "rttov_get_emis.interface" +#include "rttov_boundaryconditions.interface" + + errorstatus = 0 + alloc_status(:) = 0 + ninstruments = 1 ! number of sensors or platforms + + allocate(ichan(nch_in, ninstruments), stat = alloc_status(3)) + + do j = 1, ninstruments + ichan(:, j) = ichan_in + enddo + + nchanxnprof = prf_num_in * nch_in ! total channels to simulate * profiles + + allocate (chanprof(nchanxnprof)) + allocate (frequencies(nchanxnprof)) + allocate (emissivity(nchanxnprof)) + allocate (calcemis(nchanxnprof)) + allocate (profiles(prf_num_in)) + allocate (cld_profiles(prf_num_in)) + + ! request rttov / fastem to calculate surface emissivity + calcemis = .true. + emissivity % emis_in = 0.0 + + ! setup indices + call rttov_scatt_setupindex ( & + & prf_num_in, & ! in + & nch_in, & ! in + & coef_rttov%coef, & ! in + & nchanxnprof, & ! in + & chanprof, & ! out + & frequencies) ! out + + ! allocate profiles (input) and radiance (output) structures + asw = 1 + call rttov_alloc_prof( errorstatus,prf_num_in,profiles,nlevels_in,opts,asw, init = .true.) + call rttov_alloc_scatt_prof(prf_num_in,cld_profiles, nlevels_in, .false., 1, init = .true.) + call rttov_alloc_rad(errorstatus,nchanxnprof,radiance,nlevels_in-1,asw) + + ! fill the profile structures with data + do j = 1, prf_num_in + profiles(j)%latitude = latitude(j) + profiles(j)%longitude = longitude(j) + profiles(j)%elevation = h_surf(j) + profiles(j)%sunzenangle = 0.0 ! hard-coded in rttov9 int + profiles(j)%sunazangle = 0.0 ! hard-coded in rttov9 int + profiles(j)%azangle = 0.0 + profiles(j)%zenangle = zenang_in + profiles(j)%s2m%t = t_surf(j) + profiles(j)%s2m%q = q_surf(j) + profiles(j)%s2m%u = u_surf(j) + profiles(j)%s2m%v = v_surf(j) + profiles(j)%s2m%wfetc = 10000. + profiles(j)%skin%t = t_skin(j) + profiles(j)%skin%watertype = 1 ! ocean water + if (lsmask(j) < 0.5) then + profiles(j)%skin%surftype = surftype_sea + else + profiles(j)%skin%surftype = surftype_land + endif + if (seaice(j) >= 0.5) then + profiles(j)%skin%surftype = surftype_seaice + endif + profiles(j)%skin%fastem(1) = 3.0 + profiles(j)%skin%fastem(2) = 5.0 + profiles(j)%skin%fastem(3) = 15.0 + profiles(j)%skin%fastem(4) = 0.1 + profiles(j)%skin%fastem(5) = 0.3 + profiles(j)%cfraction = 0.0 + profiles(j)%ctp = 500.0 ! not used but still required by rttov + profiles(j)%p(:) = p_in(j,:) + profiles(j)%t(:) = t_in(j,:) + profiles(j)%q(:) = q_in(j,:) + profiles(j)%idg = 0. + profiles(j)%ish = 0. + where(profiles(j)%q(:) < 1e-4) + profiles(j)%q(:) = 1e-4 + end where + cld_profiles(j)%ph(:) = ph_in(j,:) + cld_profiles(j)%cc(:) = cc_in(j,:) + cld_profiles(j)%clw(:) = clw_in(j,:) + cld_profiles(j)%ciw(:) = ciw_in(j,:) + cld_profiles(j)%rain(:) = rain_in(j,:) + cld_profiles(j)%sp(:) = sp_in(j,:) + profiles(j)%s2m%p = cld_profiles(j)%ph(nlevels_in+1) + enddo + + call rttov_get_emis( & + & errorstatus, & + & opts, & + & chanprof, & + & profiles, & + & coef_rttov, & + ! & resolution=resolution, & ! *** MW atlas native resolution is + ! 0.25 degree lat/lon; if you know better value for satellite + ! footprint (larger than this) then you can specify it here + & emissivity=emissivity(:)%emis_in) + if (errorstatus /= errorstatus_success) then + write(*,*) 'In COSP_RTTOV11: Error RTTOV_GET_EMIS!' + call rttov_exit(errorstatus) + endif + + calcemis(:) = .false. + where (emissivity(:)%emis_in <= 0.) + calcemis(:) = .true. + endwhere + + call rttov_scatt (& + & errorstatus, &! out + & opts_scatt, &! in + & nlevels_in, &! in + & chanprof, &! in + & frequencies, &! in + & profiles, &! in + & cld_profiles, &! in + & coef_rttov, &! in + & coef_scatt, &! in + & calcemis, &! in + & emissivity, &! in + & radiance) ! out + + if (errorstatus /= errorstatus_success) then + write(*,*) 'In COSP_RTTOV11: Error RTTOV_SCATT!' + call rttov_exit(errorstatus) + endif + + !write(*,*) 'Checking emissivities: ', maxval(emissivity(:)%emis_out), \ + ! minval(emissivity(:)%emis_out) + tbs(1:prf_num_in,1:1+size(ichan(:,1))-1) = & + transpose(reshape(radiance%bt(1:nchanxnprof),(/ size(ichan(:,1)),prf_num_in/) )) + + ! deallocate all storage + asw = 0 + ! call rttov_dealloc_coefs(errorstatus,coef_rttov) + ! call rttov_dealloc_scattcoeffs(coef_scatt) + call rttov_alloc_prof(errorstatus,prf_num_in,profiles,nlevels_in,opts,asw) + call rttov_alloc_scatt_prof(prf_num_in,cld_profiles,nlevels_in,.false.,asw) + call rttov_alloc_rad(errorstatus,nchanxnprof,radiance,nlevels_in-1,asw) + deallocate(ichan,chanprof,frequencies,emissivity,calcemis) !instrument, + !*************************************************************************** + !-------- end section -------- + !*************************************************************************** + end subroutine cosp_rttov_mwscatt + function construct_rttov_coeffilename(platform,satellite,instrument) + ! Inputs + integer,intent(in) :: platform,satellite,instrument + ! Outputs + character(len=256) :: construct_rttov_coeffilename + ! Local variables + character(len=256) :: coef_file + integer :: error + + ! Initialize + error = 0 + + ! Platform + if (platform .eq. 1) coef_file = 'rtcoef_noaa_' + if (platform .eq. 10) coef_file = 'rtcoef_metop_' + if (platform .eq. 11) coef_file = 'rtcoef_envisat_' + if (platform .ne. 1 .and. platform .ne. 10 .and. platform .ne. 11) then + error=error+1 + write ( *,* ) 'Unsupported platform ID ',platform + return + endif + + ! Satellite + if (satellite .lt. 10) then + coef_file = trim(coef_file) // char(satellite+48) + else if (satellite .lt. 100) then + coef_file = trim(coef_file) // char(int(satellite/10)+48) + coef_file = trim(coef_file) // char(satellite-int(satellite/10)*10+48) + else + error=error+1 + write ( *,* ) 'Unsupported satellite number ',satellite + return + endif + + ! Sensor + if (sensor .eq. 3) coef_file = trim(coef_file) // '_amsua.dat' + if (sensor .eq. 5) coef_file = trim(coef_file) // '_avhrr.dat' + if (sensor .eq. 49) coef_file = trim(coef_file) // '_mwr.dat' + if (sensor .ne. 3 .and. sensor .ne. 5 .and. sensor .ne. 49) then + error=error+1 + write ( *,* ) 'Unsupported sensor number ', sensor + return + endif + + if (error .eq. 0) construct_rttov_coeffilename=coef_file + + end function construct_rttov_coeffilename + function construct_rttov_scatfilename(platform,satellite,instrument) + ! Inputs + integer,intent(in) :: platform,satellite,instrument + ! Outputs + character(len=256) :: construct_rttov_scatfilename + ! Local variables + character(len=256) :: coef_file + integer :: error + + ! Initialize + error = 0 + + ! Platform + if (platform .eq. 1) coef_file = 'sccldcoef_noaa_' + if (platform .eq. 10) coef_file = 'sccldcoef_metop_' + if (platform .eq. 11) coef_file = 'sccldcoef_envisat_' + if (platform .ne. 1 .and. platform .ne. 10 .and. platform .ne. 11) then + error=error+1 + write ( *,* ) 'Unsupported platform ID ',platform + return + endif + + ! Satellite + if (satellite .lt. 10) then + coef_file = trim(coef_file) // char(satellite+48) + else if (satellite .lt. 100) then + coef_file = trim(coef_file) // char(int(satellite/10)+48) + coef_file = trim(coef_file) // char(satellite-int(satellite/10)*10+48) + else + error=error+1 + write ( *,* ) 'Unsupported satellite number ',satellite + return + endif + + ! Sensor + if (sensor .eq. 3) coef_file = trim(coef_file) // '_amsua.dat' + if (sensor .eq. 5) coef_file = trim(coef_file) // '_avhrr.dat' + if (sensor .eq. 49) coef_file = trim(coef_file) // '_mwr.dat' + if (sensor .ne. 3 .and. sensor .ne. 5 .and. sensor .ne. 49) then + error=error+1 + write ( *,* ) 'Unsupported sensor number ', sensor + return + endif + + if (error .eq. 0) construct_rttov_scatfilename=coef_file + + end function construct_rttov_scatfilename + +end module mod_cosp_rttov From 11e9218c34ff5e30e147f002a2cbe350cda73bad Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 7 Feb 2023 16:51:49 -0700 Subject: [PATCH 004/159] Makefile now points to rttov_v13 COSP files. --- build/Makefile | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/build/Makefile b/build/Makefile index 54ff8ab508..c8ba6b2ddb 100644 --- a/build/Makefile +++ b/build/Makefile @@ -43,7 +43,8 @@ COSP_OBJS = cosp.o cosp_config.o cosp_stats.o cosp_constants.o cosp_errorHandlin cosp_isccp_interface.o icarus.o cosp_misr_interface.o MISR_simulator.o \ cosp_modis_interface.o modis_simulator.o cosp_parasol_interface.o parasol.o \ cosp_calipso_interface.o lidar_simulator.o cosp_cloudsat_interface.o quickbeam.o \ - cosp_rttov_interfaceSTUB.o cosp_rttovSTUB.o cosp_grLidar532_interface.o cosp_atlid_interface.o + cosp_rttov_interface_v13.o cosp_rttov_v13.o cosp_grLidar532_interface.o cosp_atlid_interface.o +# cosp_rttov_interfaceSTUB.o cosp_rttovSTUB.o cosp_grLidar532_interface.o cosp_atlid_interface.o LIBRARY = libcosp.a @@ -63,12 +64,17 @@ driver: mv cosp2_test ../driver/run # Dependencies for libary -cosp.o : cosp_kinds.o cosp_modis_interface.o cosp_constants.o cosp_rttov_interfaceSTUB.o \ +cosp.o : cosp_kinds.o cosp_modis_interface.o cosp_constants.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_rttov_interfaceSTUB.o quickbeam.o MISR_simulator.o lidar_simulator.o \ + cosp_parasol_interface.o cosp_rttov_v13.o \ + cosp_rttov_interface_v13.o quickbeam.o MISR_simulator.o lidar_simulator.o \ parasol.o icarus.o cosp_grLidar532_interface.o cosp_atlid_interface.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 @@ -87,8 +93,11 @@ cosp_grLidar532_interface.o : cosp_kinds.o cosp_atlid_interface.o : cosp_kinds.o cosp_cloudsat_interface.o : cosp_kinds.o cosp_config.o quickbeam.o quickbeam.o : cosp_kinds.o cosp_stats.o -cosp_rttov_interfaceSTUB.o : cosp_kinds.o cosp_config.o cosp_rttovSTUB.o -cosp_rttovSTUB.o : cosp_kinds.o cosp_config.o cosp_constants.o +cosp_rttov_interface_v13.o : cosp_kinds.o cosp_config.o cosp_rttov_v13.o +cosp_rttov_v13.o : cosp_kinds.o cosp_config.o cosp_constants.o + +# cosp_rttov_interfaceSTUB.o : cosp_kinds.o cosp_config.o cosp_rttovSTUB.o +# cosp_rttovSTUB.o : cosp_kinds.o cosp_config.o cosp_constants.o # Example subcolumn generaton and mapping to optical properties, following COSP 1.4 SUBCOL_OBJS = mo_rng.o scops.o prec_scops.o cosp_utils.o cosp_optics.o quickbeam_optics.o array_lib.o math_lib.o mrgrnk.o optics_lib.o cosp_errorHandling.o From 7b95061889c895178f3d98fea7c406a0b8e78109 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 8 Feb 2023 16:58:21 -0700 Subject: [PATCH 005/159] makefile works without RTTOV but does not yet include RTTOV dependencies. --- build/Makefile | 58 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/build/Makefile b/build/Makefile index c8ba6b2ddb..eee3f2f634 100644 --- a/build/Makefile +++ b/build/Makefile @@ -9,6 +9,13 @@ ISCCP_PATH = $(SIM_PATH)/icarus MISR_PATH = $(SIM_PATH)/MISR_simulator MODIS_PATH = $(SIM_PATH)/MODIS_simulator PARASOL_PATH = $(SIM_PATH)/parasol + +# RTTOV variables. You may need to change this. JKS +RTTOV_PATH = /glade/u/home/jonahshaw/w/RTTOV +RTTOV_LIB_PATH = $(RTTOV_PATH)/lib +RTTOV_INC_PATH = $(RTTOV_PATH)/include +RTTOV_MOD_PATH = $(RTTOV_PATH)/mod + VPATH = $(SRC_PATH):$(HOOKS):$(SIM_PATH):$(RT_PATH):$(RS_PATH):$(CS_PATH):$(ISCCP_PATH):$(MISR_PATH):$(MODIS_PATH):$(PARASOL_PATH) # Example subcolumn generaton and mapping to optical properties, following COSP 1.4 @@ -43,8 +50,7 @@ COSP_OBJS = cosp.o cosp_config.o cosp_stats.o cosp_constants.o cosp_errorHandlin cosp_isccp_interface.o icarus.o cosp_misr_interface.o MISR_simulator.o \ cosp_modis_interface.o modis_simulator.o cosp_parasol_interface.o parasol.o \ cosp_calipso_interface.o lidar_simulator.o cosp_cloudsat_interface.o quickbeam.o \ - cosp_rttov_interface_v13.o cosp_rttov_v13.o cosp_grLidar532_interface.o cosp_atlid_interface.o -# cosp_rttov_interfaceSTUB.o cosp_rttovSTUB.o cosp_grLidar532_interface.o cosp_atlid_interface.o + cosp_rttov_interfaceSTUB.o cosp_rttovSTUB.o cosp_grLidar532_interface.o cosp_atlid_interface.o LIBRARY = libcosp.a @@ -56,6 +62,18 @@ $(LIBRARY): $(COSP_OBJS) # lib: $(LIBRARY) +### Library for COSP-RTTOV build +COSP_RTTOV_OBJS = cosp.o cosp_config.o cosp_stats.o cosp_constants.o cosp_errorHandling.o cosp_kinds.o \ + cosp_isccp_interface.o icarus.o cosp_misr_interface.o MISR_simulator.o \ + cosp_modis_interface.o modis_simulator.o cosp_parasol_interface.o parasol.o \ + cosp_calipso_interface.o lidar_simulator.o cosp_cloudsat_interface.o quickbeam.o \ + cosp_rttov_interface_v13.o cosp_rttov_v13.o cosp_grLidar532_interface.o cosp_atlid_interface.o + +LIBRARY_RTTOV = libcosp_rttov.a + +$(LIBRARY_RTTOV): $(COSP_RTTOV_OBJS) + ar -rvs $(LIBRARY_RTTOV) $(COSP_RTTOV_OBJS) + clean: rm -f *.optrpt *.mod *.o *.a fort.* cosp2_test @@ -63,18 +81,26 @@ driver: make cosp2_test mv cosp2_test ../driver/run -# Dependencies for libary -cosp.o : cosp_kinds.o cosp_modis_interface.o cosp_constants.o \ +driver_rttov: + make cosp2_rttov_test + mv cosp2_rttov_test ../driver/run + +# Dependencies for normal COSP 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_rttov_interfaceSTUB.o quickbeam.o MISR_simulator.o lidar_simulator.o \ + parasol.o icarus.o cosp_grLidar532_interface.o cosp_atlid_interface.o + +# Dependencies for COSP-RTTOV libary +cosp_rttov.o : cosp_kinds.o cosp_modis_interface.o cosp_constants.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_rttov_v13.o \ cosp_rttov_interface_v13.o quickbeam.o MISR_simulator.o lidar_simulator.o \ parasol.o icarus.o cosp_grLidar532_interface.o cosp_atlid_interface.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 @@ -93,17 +119,22 @@ cosp_grLidar532_interface.o : cosp_kinds.o cosp_atlid_interface.o : cosp_kinds.o cosp_cloudsat_interface.o : cosp_kinds.o cosp_config.o quickbeam.o quickbeam.o : cosp_kinds.o cosp_stats.o +cosp_rttov_interfaceSTUB.o : cosp_kinds.o cosp_config.o cosp_rttovSTUB.o +cosp_rttovSTUB.o : cosp_kinds.o cosp_config.o cosp_constants.o + +# Will need to be updated cosp_rttov_interface_v13.o : cosp_kinds.o cosp_config.o cosp_rttov_v13.o cosp_rttov_v13.o : cosp_kinds.o cosp_config.o cosp_constants.o -# cosp_rttov_interfaceSTUB.o : cosp_kinds.o cosp_config.o cosp_rttovSTUB.o -# cosp_rttovSTUB.o : cosp_kinds.o cosp_config.o cosp_constants.o - # Example subcolumn generaton and mapping to optical properties, following COSP 1.4 SUBCOL_OBJS = mo_rng.o scops.o prec_scops.o cosp_utils.o cosp_optics.o quickbeam_optics.o array_lib.o math_lib.o mrgrnk.o optics_lib.o cosp_errorHandling.o libsubcol.a: $(SUBCOL_OBJS) libcosp.a ar -rvs libsubcol.a $(SUBCOL_OBJS) +# Is this right? +libsubcol_rttov.a: $(SUBCOL_OBJS) libcosp_rttov.a + ar -rvs libsubcol_rttov.a $(SUBCOL_OBJS) + array_lib.o : cosp_kinds.o mrgrnk.o : cosp_kinds.o math_lib.o : cosp_kinds.o cosp_errorHandling.o @@ -119,3 +150,8 @@ mo_rng.o : cosp_kinds.o cosp2_io.o : cosp_kinds.o cosp_config.o cosp.o cosp2_test.o : cosp2_io.o libcosp.a libsubcol.a cosp2_test : cosp2_test.o cosp2_io.o + +# Offline driver with RTTOV +cosp2_rttov_io.o : cosp_kinds.o cosp_config.o cosp_rttov.o +cosp2_rttov_test.o : cosp2_rttov_io.o libcosp_rttov.a libsubcol_rttov.a +cosp2_rttov_test : cosp2_rttov_test.o cosp2_rttov_io.o \ No newline at end of file From 893cf60099b0ac404c0a779976d4ae70e13942c8 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Thu, 9 Feb 2023 15:09:36 -0700 Subject: [PATCH 006/159] first attempt to make cosp_rttov_interface_v13 conditionally dependent on cosp_rttov_v13 --- src/simulator/cosp_rttov_interface_v13.F90 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index b7a6ec65a6..04a99d52c4 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -33,13 +33,18 @@ MODULE MOD_COSP_RTTOV_INTERFACE USE COSP_KINDS, ONLY: wp USE MOD_COSP_CONFIG, ONLY: RTTOV_MAX_CHANNELS,rttovDir +! JKS +#ifdef RTTOV use mod_cosp_rttov, only: platform,satellite,sensor,nChannels,iChannel,coef_rttov, & coef_scatt,opts,opts_scatt,construct_rttov_coeffilename, & construct_rttov_scatfilename +#endif IMPLICIT NONE +! JKS +#ifdef RTTOV #include "rttov_read_coefs.interface" #include "rttov_read_scattcoeffs.interface" - +#endif ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! TYPE rttov_in ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -109,6 +114,8 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI sensor = instrumentIN iChannel = channelsIN +! JKS +#ifdef RTTOV ! Options common to RTTOV clear-sky Tb calculation opts%interpolation%addinterp = .true. ! allow interpolation of input profile opts%rt_all%use_q2m = .true. @@ -135,6 +142,7 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI ! trim(construct_rttov_scatfilename(platform,satellite,sensor)) ! Can't pass filename to rttov_read_scattcoeffs!!!!! !call rttov_read_scattcoeffs (errorstatus, coef_rttov%coef, coef_scatt,) +#endif END SUBROUTINE COSP_RTTOV_INIT ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From 6279ced2d474b09c3be0e3f58f7f0760abd764f5 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Thu, 9 Feb 2023 15:25:37 -0700 Subject: [PATCH 007/159] Make COSP conditionally dependent on cosp_rttov_v13 and thus the RTTOV library. --- src/cosp.F90 | 2 ++ src/simulator/cosp_rttov_interface_v13.F90 | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cosp.F90 b/src/cosp.F90 index 8594451859..db02ca930a 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -1817,7 +1817,9 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La if (Lisccp) call cosp_isccp_init(isccp_top_height,isccp_top_height_direction) if (Lmodis) call cosp_modis_init() if (Lmisr) call cosp_misr_init() +#ifdef RTTOV if (Lrttov) call cosp_rttov_init() +#endif if (Lcloudsat) call cosp_cloudsat_init(cloudsat_radar_freq,cloudsat_k2, & cloudsat_use_gas_abs,cloudsat_do_ray,R_UNDEF,N_HYDRO, surface_radar, & rcfg,cloudsat_micro_scheme) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 04a99d52c4..1176b1b3ca 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -106,7 +106,9 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI ! Local variables character(len=256) :: coef_file,scat_file integer :: errorstatus - + +! JKS +#ifdef RTTOV ! Initialize fields in module memory (cosp_rttovXX.F90) nChannels = NchanIN platform = platformIN @@ -114,8 +116,7 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI sensor = instrumentIN iChannel = channelsIN -! JKS -#ifdef RTTOV + ! Options common to RTTOV clear-sky Tb calculation opts%interpolation%addinterp = .true. ! allow interpolation of input profile opts%rt_all%use_q2m = .true. From 0d02f641db1ca317546873a531edaeb4dacff3b0 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Thu, 9 Feb 2023 15:26:08 -0700 Subject: [PATCH 008/159] Makefile now builds with the condtionally dependent cosp_rttov_interface_v13 file --- build/Makefile | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/build/Makefile b/build/Makefile index eee3f2f634..94518cf408 100644 --- a/build/Makefile +++ b/build/Makefile @@ -43,6 +43,10 @@ LDFLAGS += -L. -lcosp -lsubcol %: %.o $(F90) $(F90FLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) +# Special rule for the RTTOV file. +cosp_rttov_v13.o : cosp_rttov_v13.F90 + $(F90) $(F90FLAGS) -c -I $(RTTOV_INC_PATH) -I $(RTTOV_MOD_PATH) $< + # # The COSP library # @@ -50,7 +54,10 @@ COSP_OBJS = cosp.o cosp_config.o cosp_stats.o cosp_constants.o cosp_errorHandlin cosp_isccp_interface.o icarus.o cosp_misr_interface.o MISR_simulator.o \ cosp_modis_interface.o modis_simulator.o cosp_parasol_interface.o parasol.o \ cosp_calipso_interface.o lidar_simulator.o cosp_cloudsat_interface.o quickbeam.o \ - cosp_rttov_interfaceSTUB.o cosp_rttovSTUB.o cosp_grLidar532_interface.o cosp_atlid_interface.o + cosp_rttov_interface_v13.o cosp_rttovSTUB.o cosp_grLidar532_interface.o cosp_atlid_interface.o + +# cosp_rttov_interfaceSTUB.o cosp_rttovSTUB.o cosp_grLidar532_interface.o cosp_atlid_interface.o + LIBRARY = libcosp.a @@ -86,13 +93,15 @@ driver_rttov: mv cosp2_rttov_test ../driver/run # Dependencies for normal COSP libary -cosp.o : cosp_kinds.o cosp_modis_interface.o cosp_constants.o cosp_rttov_interfaceSTUB.o \ +cosp.o : cosp_kinds.o cosp_modis_interface.o cosp_constants.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_rttov_interfaceSTUB.o quickbeam.o MISR_simulator.o lidar_simulator.o \ + cosp_rttov_interface_v13.o quickbeam.o MISR_simulator.o lidar_simulator.o \ parasol.o icarus.o cosp_grLidar532_interface.o cosp_atlid_interface.o +# cosp_rttov_interfaceSTUB.o quickbeam.o MISR_simulator.o lidar_simulator.o \ + # Dependencies for COSP-RTTOV libary cosp_rttov.o : cosp_kinds.o cosp_modis_interface.o cosp_constants.o \ cosp_misr_interface.o cosp_isccp_interface.o cosp_calipso_interface.o \ @@ -122,8 +131,9 @@ quickbeam.o : cosp_kinds.o cosp_stats.o cosp_rttov_interfaceSTUB.o : cosp_kinds.o cosp_config.o cosp_rttovSTUB.o cosp_rttovSTUB.o : cosp_kinds.o cosp_config.o cosp_constants.o -# Will need to be updated -cosp_rttov_interface_v13.o : cosp_kinds.o cosp_config.o cosp_rttov_v13.o +# Will need to be updated. Conditionally removed rttov_interface dependence on cosp_rttov_v13 +cosp_rttov_interface_v13.o : cosp_kinds.o cosp_config.o +# cosp_rttov_interface_v13.o : cosp_kinds.o cosp_config.o cosp_rttov_v13.o cosp_rttov_v13.o : cosp_kinds.o cosp_config.o cosp_constants.o # Example subcolumn generaton and mapping to optical properties, following COSP 1.4 From 13bd0a26f8f386eb6d68f6a9e980e085bcdd5ee6 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Fri, 17 Feb 2023 16:55:27 -0700 Subject: [PATCH 009/159] Makefile progress after meeting with Dustin --- build/Makefile | 88 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 63 insertions(+), 25 deletions(-) diff --git a/build/Makefile b/build/Makefile index 94518cf408..0b078a898a 100644 --- a/build/Makefile +++ b/build/Makefile @@ -33,6 +33,13 @@ LDFLAGS += $(NC_LIB) -lnetcdff LDFLAGS += -L. -lcosp -lsubcol + +# This is triggering later, which is actually great! +ifdef RTTOV +LDFLAGS += -L${RTTOV_LIB_PATH} -lrttov13 +endif + + # Rules %.o: %.F90 $(F90) $(F90FLAGS) -c $< @@ -54,8 +61,9 @@ COSP_OBJS = cosp.o cosp_config.o cosp_stats.o cosp_constants.o cosp_errorHandlin cosp_isccp_interface.o icarus.o cosp_misr_interface.o MISR_simulator.o \ cosp_modis_interface.o modis_simulator.o cosp_parasol_interface.o parasol.o \ cosp_calipso_interface.o lidar_simulator.o cosp_cloudsat_interface.o quickbeam.o \ - cosp_rttov_interface_v13.o cosp_rttovSTUB.o cosp_grLidar532_interface.o cosp_atlid_interface.o + cosp_rttov_interface_v13.o cosp_grLidar532_interface.o cosp_atlid_interface.o +# cosp_rttov_interface_v13.o cosp_rttovSTUB.o cosp_grLidar532_interface.o cosp_atlid_interface.o # cosp_rttov_interfaceSTUB.o cosp_rttovSTUB.o cosp_grLidar532_interface.o cosp_atlid_interface.o @@ -69,37 +77,36 @@ $(LIBRARY): $(COSP_OBJS) # lib: $(LIBRARY) -### Library for COSP-RTTOV build -COSP_RTTOV_OBJS = cosp.o cosp_config.o cosp_stats.o cosp_constants.o cosp_errorHandling.o cosp_kinds.o \ - cosp_isccp_interface.o icarus.o cosp_misr_interface.o MISR_simulator.o \ - cosp_modis_interface.o modis_simulator.o cosp_parasol_interface.o parasol.o \ - cosp_calipso_interface.o lidar_simulator.o cosp_cloudsat_interface.o quickbeam.o \ - cosp_rttov_interface_v13.o cosp_rttov_v13.o cosp_grLidar532_interface.o cosp_atlid_interface.o - -LIBRARY_RTTOV = libcosp_rttov.a - -$(LIBRARY_RTTOV): $(COSP_RTTOV_OBJS) - ar -rvs $(LIBRARY_RTTOV) $(COSP_RTTOV_OBJS) - clean: rm -f *.optrpt *.mod *.o *.a fort.* cosp2_test +## I am not sure if this "unset" is working. I might need to specify the SHELL so export works everywhere. driver: make cosp2_test mv cosp2_test ../driver/run +# export RTTOV=TRUE +# unset RTTOV + driver_rttov: - make cosp2_rttov_test - mv cosp2_rttov_test ../driver/run + make driver + + +#driver_rttov: +# export RTTOV=TRUE +# make cosp2_rttov_test +# mv cosp2_rttov_test ../driver/run + # Dependencies for normal COSP libary cosp.o : cosp_kinds.o cosp_modis_interface.o cosp_constants.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_parasol_interface.o \ cosp_rttov_interface_v13.o quickbeam.o MISR_simulator.o lidar_simulator.o \ parasol.o icarus.o cosp_grLidar532_interface.o cosp_atlid_interface.o +# cosp_parasol_interface.o cosp_rttovSTUB.o \ # cosp_rttov_interfaceSTUB.o quickbeam.o MISR_simulator.o lidar_simulator.o \ # Dependencies for COSP-RTTOV libary @@ -128,22 +135,27 @@ cosp_grLidar532_interface.o : cosp_kinds.o cosp_atlid_interface.o : cosp_kinds.o cosp_cloudsat_interface.o : cosp_kinds.o cosp_config.o quickbeam.o quickbeam.o : cosp_kinds.o cosp_stats.o -cosp_rttov_interfaceSTUB.o : cosp_kinds.o cosp_config.o cosp_rttovSTUB.o +# cosp_rttov_interfaceSTUB.o : cosp_kinds.o cosp_config.o cosp_rttovSTUB.o cosp_rttovSTUB.o : cosp_kinds.o cosp_config.o cosp_constants.o # Will need to be updated. Conditionally removed rttov_interface dependence on cosp_rttov_v13 -cosp_rttov_interface_v13.o : cosp_kinds.o cosp_config.o +#cosp_rttov_interface_v13.o : cosp_kinds.o cosp_config.o + +ifdef RTTOV +cosp_rttov_interface_v13.o : cosp_kinds.o cosp_config.o cosp_rttov_v13.o +else +cosp_rttov_interface_v13.o : cosp_kinds.o cosp_config.o cosp_rttovSTUB.o +endif + # cosp_rttov_interface_v13.o : cosp_kinds.o cosp_config.o cosp_rttov_v13.o cosp_rttov_v13.o : cosp_kinds.o cosp_config.o cosp_constants.o + # Example subcolumn generaton and mapping to optical properties, following COSP 1.4 SUBCOL_OBJS = mo_rng.o scops.o prec_scops.o cosp_utils.o cosp_optics.o quickbeam_optics.o array_lib.o math_lib.o mrgrnk.o optics_lib.o cosp_errorHandling.o libsubcol.a: $(SUBCOL_OBJS) libcosp.a ar -rvs libsubcol.a $(SUBCOL_OBJS) -# Is this right? -libsubcol_rttov.a: $(SUBCOL_OBJS) libcosp_rttov.a - ar -rvs libsubcol_rttov.a $(SUBCOL_OBJS) array_lib.o : cosp_kinds.o mrgrnk.o : cosp_kinds.o @@ -161,7 +173,33 @@ cosp2_io.o : cosp_kinds.o cosp_config.o cosp.o cosp2_test.o : cosp2_io.o libcosp.a libsubcol.a cosp2_test : cosp2_test.o cosp2_io.o -# Offline driver with RTTOV -cosp2_rttov_io.o : cosp_kinds.o cosp_config.o cosp_rttov.o -cosp2_rttov_test.o : cosp2_rttov_io.o libcosp_rttov.a libsubcol_rttov.a -cosp2_rttov_test : cosp2_rttov_test.o cosp2_rttov_io.o \ No newline at end of file +# Offline driver with RTTOV is just adding the COSP-RTTOV file and the RTTOV library. +cosp2_rttov_test : cosp2_test.o cosp2_io.o cosp_rttov_v13.o + + +############### +### OLD +############### + +# OLD Offline driver with RTTOV +#cosp2_rttov_io.o : cosp_kinds.o cosp_config.o cosp_rttov.o +#cosp2_rttov_test.o : cosp2_rttov_io.o libcosp_rttov.a libsubcol_rttov.a +#cosp2_rttov_test : cosp2_rttov_test.o cosp2_rttov_io.o + + +### Library for COSP-RTTOV build +COSP_RTTOV_OBJS = cosp.o cosp_config.o cosp_stats.o cosp_constants.o cosp_errorHandling.o cosp_kinds.o \ + cosp_isccp_interface.o icarus.o cosp_misr_interface.o MISR_simulator.o \ + cosp_modis_interface.o modis_simulator.o cosp_parasol_interface.o parasol.o \ + cosp_calipso_interface.o lidar_simulator.o cosp_cloudsat_interface.o quickbeam.o \ + cosp_rttov_interface_v13.o cosp_rttov_v13.o cosp_grLidar532_interface.o cosp_atlid_interface.o + +LIBRARY_RTTOV = libcosp_rttov.a + +$(LIBRARY_RTTOV): $(COSP_RTTOV_OBJS) + ar -rvs $(LIBRARY_RTTOV) $(COSP_RTTOV_OBJS) + + + # Is this right? +libsubcol_rttov.a: $(SUBCOL_OBJS) libcosp_rttov.a + ar -rvs libsubcol_rttov.a $(SUBCOL_OBJS) \ No newline at end of file From 17ad877c1ca6f25b825b1d9b4e4f02c66fa11cf6 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Mon, 20 Feb 2023 09:36:54 -0700 Subject: [PATCH 010/159] Makefile is nearly final, some junk at the bottom, removed previously added conditional dependencies in cosp2_test.F90 and cosp.F90 --- build/Makefile | 136 ++++++++++-------- driver/src/{cosp2_test.f90 => cosp2_test.F90} | 18 ++- src/cosp.F90 | 8 +- 3 files changed, 96 insertions(+), 66 deletions(-) rename driver/src/{cosp2_test.f90 => cosp2_test.F90} (99%) diff --git a/build/Makefile b/build/Makefile index 0b078a898a..c35461580f 100644 --- a/build/Makefile +++ b/build/Makefile @@ -33,8 +33,6 @@ LDFLAGS += $(NC_LIB) -lnetcdff LDFLAGS += -L. -lcosp -lsubcol - -# This is triggering later, which is actually great! ifdef RTTOV LDFLAGS += -L${RTTOV_LIB_PATH} -lrttov13 endif @@ -50,7 +48,7 @@ endif %: %.o $(F90) $(F90FLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) -# Special rule for the RTTOV file. +# Special rule for the RTTOV file. Had an ifdef line but it wasn't necessary. cosp_rttov_v13.o : cosp_rttov_v13.F90 $(F90) $(F90FLAGS) -c -I $(RTTOV_INC_PATH) -I $(RTTOV_MOD_PATH) $< @@ -61,10 +59,14 @@ COSP_OBJS = cosp.o cosp_config.o cosp_stats.o cosp_constants.o cosp_errorHandlin cosp_isccp_interface.o icarus.o cosp_misr_interface.o MISR_simulator.o \ cosp_modis_interface.o modis_simulator.o cosp_parasol_interface.o parasol.o \ cosp_calipso_interface.o lidar_simulator.o cosp_cloudsat_interface.o quickbeam.o \ - cosp_rttov_interface_v13.o cosp_grLidar532_interface.o cosp_atlid_interface.o + cosp_grLidar532_interface.o cosp_atlid_interface.o -# cosp_rttov_interface_v13.o cosp_rttovSTUB.o cosp_grLidar532_interface.o cosp_atlid_interface.o -# cosp_rttov_interfaceSTUB.o cosp_rttovSTUB.o cosp_grLidar532_interface.o cosp_atlid_interface.o +# Add RTTOV files appropriately +ifdef RTTOV +COSP_OBJS += cosp_rttov_interface_v13.o cosp_rttov_v13.o +else +COSP_OBJS += cosp_rttov_interfaceSTUB.o cosp_rttovSTUB.o +endif LIBRARY = libcosp.a @@ -80,49 +82,37 @@ lib: $(LIBRARY) clean: rm -f *.optrpt *.mod *.o *.a fort.* cosp2_test -## I am not sure if this "unset" is working. I might need to specify the SHELL so export works everywhere. driver: make cosp2_test mv cosp2_test ../driver/run -# export RTTOV=TRUE -# unset RTTOV - +# I would like to set the env variable here, but it won't work. driver_rttov: make driver -#driver_rttov: -# export RTTOV=TRUE -# make cosp2_rttov_test -# mv cosp2_rttov_test ../driver/run - - # Dependencies for normal COSP libary -cosp.o : cosp_kinds.o cosp_modis_interface.o cosp_constants.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_rttov_interface_v13.o quickbeam.o MISR_simulator.o lidar_simulator.o \ - parasol.o icarus.o cosp_grLidar532_interface.o cosp_atlid_interface.o - -# cosp_parasol_interface.o cosp_rttovSTUB.o \ -# cosp_rttov_interfaceSTUB.o quickbeam.o MISR_simulator.o lidar_simulator.o \ +cosp.o : cosp_kinds.o cosp_modis_interface.o cosp_constants.o \ + cosp_misr_interface.o cosp_isccp_interface.o cosp_calipso_interface.o \ + cosp_cloudsat_interface.o cosp_stats.o \ + cosp_parasol_interface.o \ + quickbeam.o MISR_simulator.o lidar_simulator.o \ + parasol.o icarus.o cosp_grLidar532_interface.o cosp_atlid_interface.o + +# Conditionally add dependencies on the Stub or actual RTTOV simulator. +ifdef RTTOV +cosp.o: cosp_rttov_interface_v13.o cosp_rttov_v13.o +else +cosp.o: cosp_rttov_interfaceSTUB.o cosp_rttovSTUB.o +endif -# Dependencies for COSP-RTTOV libary -cosp_rttov.o : cosp_kinds.o cosp_modis_interface.o cosp_constants.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_rttov_v13.o \ - cosp_rttov_interface_v13.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_constants.o cosp_isccp_interface.o : cosp_kinds.o icarus.o -icarus.o : cosp_kinds.o cosp_constants.o cosp_stats.o +icarus.o : cosp_kinds.o cosp_constants.o cosp_stats.o cosp_misr_interface.o : cosp_kinds.o MISR_simulator.o : cosp_kinds.o cosp_config.o cosp_stats.o cosp_modis_interface.o : cosp_kinds.o cosp_config.o modis_simulator.o @@ -135,20 +125,12 @@ cosp_grLidar532_interface.o : cosp_kinds.o cosp_atlid_interface.o : cosp_kinds.o cosp_cloudsat_interface.o : cosp_kinds.o cosp_config.o quickbeam.o quickbeam.o : cosp_kinds.o cosp_stats.o -# cosp_rttov_interfaceSTUB.o : cosp_kinds.o cosp_config.o cosp_rttovSTUB.o -cosp_rttovSTUB.o : cosp_kinds.o cosp_config.o cosp_constants.o -# Will need to be updated. Conditionally removed rttov_interface dependence on cosp_rttov_v13 -#cosp_rttov_interface_v13.o : cosp_kinds.o cosp_config.o - -ifdef RTTOV +# RTTOV Simulator code dependencies (only one interface and one RTTOV simulator oare used at a time) cosp_rttov_interface_v13.o : cosp_kinds.o cosp_config.o cosp_rttov_v13.o -else -cosp_rttov_interface_v13.o : cosp_kinds.o cosp_config.o cosp_rttovSTUB.o -endif - -# cosp_rttov_interface_v13.o : cosp_kinds.o cosp_config.o cosp_rttov_v13.o cosp_rttov_v13.o : cosp_kinds.o cosp_config.o cosp_constants.o +cosp_rttov_interfaceSTUB.o : cosp_kinds.o cosp_config.o cosp_rttovSTUB.o +cosp_rttovSTUB.o : cosp_kinds.o cosp_config.o cosp_constants.o # Example subcolumn generaton and mapping to optical properties, following COSP 1.4 @@ -173,33 +155,71 @@ cosp2_io.o : cosp_kinds.o cosp_config.o cosp.o cosp2_test.o : cosp2_io.o libcosp.a libsubcol.a cosp2_test : cosp2_test.o cosp2_io.o -# Offline driver with RTTOV is just adding the COSP-RTTOV file and the RTTOV library. -cosp2_rttov_test : cosp2_test.o cosp2_io.o cosp_rttov_v13.o - ############### ### OLD ############### +# Offline driver with RTTOV is just adding the COSP-RTTOV file and the RTTOV library. +#cosp2_rttov_test : cosp2_test.o cosp2_io.o cosp_rttov_v13.o + + # OLD Offline driver with RTTOV #cosp2_rttov_io.o : cosp_kinds.o cosp_config.o cosp_rttov.o #cosp2_rttov_test.o : cosp2_rttov_io.o libcosp_rttov.a libsubcol_rttov.a #cosp2_rttov_test : cosp2_rttov_test.o cosp2_rttov_io.o +# Dependencies for COSP-RTTOV libary +#cosp_rttov.o : cosp_kinds.o cosp_modis_interface.o cosp_constants.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_rttov_v13.o \ +# cosp_rttov_interface_v13.o quickbeam.o MISR_simulator.o lidar_simulator.o \ +# parasol.o icarus.o cosp_grLidar532_interface.o cosp_atlid_interface.o + + ### Library for COSP-RTTOV build -COSP_RTTOV_OBJS = cosp.o cosp_config.o cosp_stats.o cosp_constants.o cosp_errorHandling.o cosp_kinds.o \ - cosp_isccp_interface.o icarus.o cosp_misr_interface.o MISR_simulator.o \ - cosp_modis_interface.o modis_simulator.o cosp_parasol_interface.o parasol.o \ - cosp_calipso_interface.o lidar_simulator.o cosp_cloudsat_interface.o quickbeam.o \ - cosp_rttov_interface_v13.o cosp_rttov_v13.o cosp_grLidar532_interface.o cosp_atlid_interface.o +#COSP_RTTOV_OBJS = cosp.o cosp_config.o cosp_stats.o cosp_constants.o cosp_errorHandling.o cosp_kinds.o \ +# cosp_isccp_interface.o icarus.o cosp_misr_interface.o MISR_simulator.o \ +# cosp_modis_interface.o modis_simulator.o cosp_parasol_interface.o parasol.o \ +# cosp_calipso_interface.o lidar_simulator.o cosp_cloudsat_interface.o quickbeam.o \ +# cosp_rttov_interface_v13.o cosp_rttov_v13.o cosp_grLidar532_interface.o cosp_atlid_interface.o -LIBRARY_RTTOV = libcosp_rttov.a +#LIBRARY_RTTOV = libcosp_rttov.a -$(LIBRARY_RTTOV): $(COSP_RTTOV_OBJS) - ar -rvs $(LIBRARY_RTTOV) $(COSP_RTTOV_OBJS) +#$(LIBRARY_RTTOV): $(COSP_RTTOV_OBJS) +# ar -rvs $(LIBRARY_RTTOV) $(COSP_RTTOV_OBJS) - # Is this right? -libsubcol_rttov.a: $(SUBCOL_OBJS) libcosp_rttov.a - ar -rvs libsubcol_rttov.a $(SUBCOL_OBJS) \ No newline at end of file +# Is this right? +#libsubcol_rttov.a: $(SUBCOL_OBJS) libcosp_rttov.a +# ar -rvs libsubcol_rttov.a $(SUBCOL_OBJS) + +# Will need to be updated. Conditionally removed rttov_interface dependence on cosp_rttov_v13 +#cosp_rttov_interface_v13.o : cosp_kinds.o cosp_config.o + +#ifdef RTTOV +#cosp_rttov_interface_v13.o : cosp_kinds.o cosp_config.o cosp_rttov_v13.o +#else +#cosp_rttov_interface_v13.o : cosp_kinds.o cosp_config.o cosp_rttovSTUB.o +#endif + +#cosp_rttov_interface_v13.o : cosp_kinds.o cosp_config.o cosp_rttov_v13.o +#cosp_rttov_v13.o : cosp_kinds.o cosp_config.o cosp_constants.o + +#ifdef RTTOV +#COSP_OBJS = cosp.o cosp_config.o cosp_stats.o cosp_constants.o cosp_errorHandling.o cosp_kinds.o \ +# cosp_isccp_interface.o icarus.o cosp_misr_interface.o MISR_simulator.o \ +# cosp_modis_interface.o modis_simulator.o cosp_parasol_interface.o parasol.o \ +# cosp_calipso_interface.o lidar_simulator.o cosp_cloudsat_interface.o quickbeam.o \ +# cosp_grLidar532_interface.o cosp_atlid_interface.o \ +# cosp_rttov_interface_v13.o cosp_rttov_v13.o +#else +#COSP_OBJS = cosp.o cosp_config.o cosp_stats.o cosp_constants.o cosp_errorHandling.o cosp_kinds.o \ +# cosp_isccp_interface.o icarus.o cosp_misr_interface.o MISR_simulator.o \ +# cosp_modis_interface.o modis_simulator.o cosp_parasol_interface.o parasol.o \ +# cosp_calipso_interface.o lidar_simulator.o cosp_cloudsat_interface.o quickbeam.o \ +# cosp_grLidar532_interface.o cosp_atlid_interface.o \ +# cosp_rttov_interfaceSTUB.o cosp_rttovSTUB.o +#endif \ No newline at end of file diff --git a/driver/src/cosp2_test.f90 b/driver/src/cosp2_test.F90 similarity index 99% rename from driver/src/cosp2_test.f90 rename to driver/src/cosp2_test.F90 index 93a63c1b35..555df68435 100755 --- a/driver/src/cosp2_test.f90 +++ b/driver/src/cosp2_test.F90 @@ -1019,6 +1019,18 @@ subroutine construct_cospstateIN(npoints,nlevels,nchan,y) y%fl_snow(nPoints,nLevels),y%fl_rain(nPoints,nLevels),y%seaice(npoints), & y%tca(nPoints,nLevels),y%hgt_matrix_half(npoints,nlevels)) +! allocate(y%sunlit(npoints),y%skt(npoints),y%land(npoints),y%at(npoints,nlevels), & +! y%pfull(npoints,nlevels),y%phalf(npoints,nlevels+1),y%qv(npoints,nlevels), & +! y%hgt_matrix(npoints,nlevels),y%hgt_matrix_half(npoints,nlevels), & +! y%surfelev(npoints)) +!#ifdef RTTOV +! allocate(y%o3(npoints,nlevels),y%u_sfc(npoints),y%v_sfc(npoints), & +! y%lat(npoints),y%lon(nPoints),y%emis_sfc(nchan), & +! y%cloudIce(nPoints,nLevels),y%cloudLiq(nPoints,nLevels), & +! y%fl_snow(nPoints,nLevels),y%fl_rain(nPoints,nLevels),y%seaice(npoints), & +! y%tca(nPoints,nLevels)) +!#endif + end subroutine construct_cospstateIN ! ###################################################################################### @@ -1385,8 +1397,10 @@ subroutine destroy_cospstateIN(y) if (allocated(y%pfull)) deallocate(y%pfull) if (allocated(y%phalf)) deallocate(y%phalf) if (allocated(y%qv)) deallocate(y%qv) - if (allocated(y%o3)) deallocate(y%o3) if (allocated(y%hgt_matrix)) deallocate(y%hgt_matrix) + if (allocated(y%hgt_matrix_half)) deallocate(y%hgt_matrix_half) + if (allocated(y%surfelev)) deallocate(y%surfelev) + if (allocated(y%o3)) deallocate(y%o3) if (allocated(y%u_sfc)) deallocate(y%u_sfc) if (allocated(y%v_sfc)) deallocate(y%v_sfc) if (allocated(y%lat)) deallocate(y%lat) @@ -1398,8 +1412,6 @@ subroutine destroy_cospstateIN(y) if (allocated(y%fl_rain)) deallocate(y%fl_rain) if (allocated(y%fl_snow)) deallocate(y%fl_snow) if (allocated(y%tca)) deallocate(y%tca) - if (allocated(y%hgt_matrix_half)) deallocate(y%hgt_matrix_half) - if (allocated(y%surfelev)) deallocate(y%surfelev) end subroutine destroy_cospstateIN diff --git a/src/cosp.F90 b/src/cosp.F90 index db02ca930a..a23d8fed88 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -65,9 +65,9 @@ MODULE MOD_COSP USE MOD_LIDAR_SIMULATOR, ONLY: lidar_subcolumn, lidar_column USE MOD_MODIS_SIM, ONLY: modis_subcolumn, modis_column USE MOD_PARASOL, ONLY: parasol_subcolumn, parasol_column - use mod_cosp_rttov, ONLY: rttov_column USE MOD_COSP_STATS, ONLY: COSP_LIDAR_ONLY_CLOUD,COSP_CHANGE_VERTICAL_GRID, & COSP_DIAG_WARMRAIN + use mod_cosp_rttov, ONLY: rttov_column IMPLICIT NONE @@ -1817,9 +1817,7 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La if (Lisccp) call cosp_isccp_init(isccp_top_height,isccp_top_height_direction) if (Lmodis) call cosp_modis_init() if (Lmisr) call cosp_misr_init() -#ifdef RTTOV if (Lrttov) call cosp_rttov_init() -#endif if (Lcloudsat) call cosp_cloudsat_init(cloudsat_radar_freq,cloudsat_k2, & cloudsat_use_gas_abs,cloudsat_do_ray,R_UNDEF,N_HYDRO, surface_radar, & rcfg,cloudsat_micro_scheme) @@ -2565,7 +2563,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, if (associated(cospOUT%rttov_tbs)) cospOUT%rttov_tbs(:,:) = R_UNDEF endif endif - + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! PART 1: Check input array values for out-of-bounds values. When an out-of-bound value ! is encountered, COSP outputs that are dependent on that input are filled with @@ -3015,7 +3013,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, if (associated(cospOUT%rttov_tbs)) cospOUT%rttov_tbs(:,:) = R_UNDEF endif endif - + ! COSP_INPUTS if (any([Lisccp_subcolumn,Lisccp_column])) then if (cospIN%emsfc_lw .lt. 0. .OR. cospIN%emsfc_lw .gt. 1.) then From 3bfaddd5823e5308db39020b0665b008d497c737 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 21 Feb 2023 13:29:51 -0700 Subject: [PATCH 011/159] Removed conditional dependence on environment variables since the Makefile has changed cosp_rttov_interface_v13.F90 will not be compiled unless RTTOV is being built into COSP, so I no longer need #ifdef RTTOV statements in this file. --- src/simulator/cosp_rttov_interface_v13.F90 | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 1176b1b3ca..d27637a5b1 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -107,8 +107,6 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI character(len=256) :: coef_file,scat_file integer :: errorstatus -! JKS -#ifdef RTTOV ! Initialize fields in module memory (cosp_rttovXX.F90) nChannels = NchanIN platform = platformIN @@ -143,7 +141,6 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI ! trim(construct_rttov_scatfilename(platform,satellite,sensor)) ! Can't pass filename to rttov_read_scattcoeffs!!!!! !call rttov_read_scattcoeffs (errorstatus, coef_rttov%coef, coef_scatt,) -#endif END SUBROUTINE COSP_RTTOV_INIT ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From 7f6575047b5f1eb526b60e4278f9b70c6d36ca1c Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 21 Feb 2023 13:31:58 -0700 Subject: [PATCH 012/159] Removed remaining #ifdef statements --- src/simulator/cosp_rttov_interface_v13.F90 | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index d27637a5b1..e249185a25 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -33,18 +33,14 @@ MODULE MOD_COSP_RTTOV_INTERFACE USE COSP_KINDS, ONLY: wp USE MOD_COSP_CONFIG, ONLY: RTTOV_MAX_CHANNELS,rttovDir -! JKS -#ifdef RTTOV use mod_cosp_rttov, only: platform,satellite,sensor,nChannels,iChannel,coef_rttov, & coef_scatt,opts,opts_scatt,construct_rttov_coeffilename, & construct_rttov_scatfilename -#endif IMPLICIT NONE -! JKS -#ifdef RTTOV + #include "rttov_read_coefs.interface" #include "rttov_read_scattcoeffs.interface" -#endif + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! TYPE rttov_in ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From cee901f7dccbe683a5e25fddd3ac8d5680981ec2 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Mon, 27 Feb 2023 17:26:49 -0700 Subject: [PATCH 013/159] typo in comment --- build/Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build/Makefile b/build/Makefile index c35461580f..182c7d18cb 100644 --- a/build/Makefile +++ b/build/Makefile @@ -49,6 +49,11 @@ endif $(F90) $(F90FLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) # Special rule for the RTTOV file. Had an ifdef line but it wasn't necessary. + +# JKS is this needed because of the load_coefficient calls? Can I remove this by restructuring? +cosp_rttov_interface_v13.o : cosp_rttov_interface_v13.F90 + $(F90) $(F90FLAGS) -c -I $(RTTOV_INC_PATH) -I $(RTTOV_MOD_PATH) $< + cosp_rttov_v13.o : cosp_rttov_v13.F90 $(F90) $(F90FLAGS) -c -I $(RTTOV_INC_PATH) -I $(RTTOV_MOD_PATH) $< @@ -126,7 +131,7 @@ cosp_atlid_interface.o : cosp_kinds.o cosp_cloudsat_interface.o : cosp_kinds.o cosp_config.o quickbeam.o quickbeam.o : cosp_kinds.o cosp_stats.o -# RTTOV Simulator code dependencies (only one interface and one RTTOV simulator oare used at a time) +# RTTOV Simulator code dependencies (only one interface and one RTTOV simulator are used at a time) cosp_rttov_interface_v13.o : cosp_kinds.o cosp_config.o cosp_rttov_v13.o cosp_rttov_v13.o : cosp_kinds.o cosp_config.o cosp_constants.o cosp_rttov_interfaceSTUB.o : cosp_kinds.o cosp_config.o cosp_rttovSTUB.o From 3e069309d8b006395bd66a179db544b574813da5 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Mon, 27 Feb 2023 17:27:37 -0700 Subject: [PATCH 014/159] =?UTF-8?q?I=20made=20changes=20to=20=E2=80=9Ccosp?= =?UTF-8?q?.F90=E2=80=9D=20and=20=E2=80=9Ccosp2=5Ftest.F90=E2=80=9D=20so?= =?UTF-8?q?=20that=20the=20cosp=5Finit=20passes=20the=20RTTOV=20instrument?= =?UTF-8?q?,=20channel,=20etc=20information=20into=20the=20cosp=5Frttov=5F?= =?UTF-8?q?init=20call.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- driver/src/cosp2_test.F90 | 14 ++++++- src/cosp.F90 | 80 +++++++++++++++++++++++++++++---------- 2 files changed, 73 insertions(+), 21 deletions(-) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 555df68435..1f578e8488 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -393,7 +393,9 @@ program cosp2_test 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) + rcfg_cloudsat, use_vgrid, csat_vgrid, Nlvgrid, Nlevels, cloudsat_micro_scheme, & + rttov_platform, rttov_satellite, rttov_Instrument, rttov_Nchannels, & ! JKS added RTTOV inputs here + rttov_Channels) call cpu_time(driver_time(3)) !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -995,7 +997,15 @@ subroutine construct_cospIN(npoints,ncolumns,nlevels,y) y%asym(npoints, ncolumns,nlevels),& y%ss_alb(npoints, ncolumns,nlevels)) endif - + ! JKS add RTTOV arguments when constructing the cospIN object + if (Lrttov) then + y%NchanIN_rttov = rttov_Nchannels + y%platformIN_rttov = rttov_platform + y%satelliteIN_rttov = rttov_satellite + y%instrumentIN_rttov = rttov_Instrument + y%channelsIN_rttov = rttov_Channels + ! ^I could allocate this if I added "RTTOV_MAX_CHANNELS" at the beginning, but I don't think I need to. + endif end subroutine construct_cospIN diff --git a/src/cosp.F90 b/src/cosp.F90 index a23d8fed88..5ce04701b9 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -49,7 +49,8 @@ MODULE MOD_COSP ntau,modis_histTau,tau_binBounds, & modis_histTauEdges,tau_binEdges,nCloudsatPrecipClass,& modis_histTauCenters,tau_binCenters, & - cloudsat_preclvl,grLidar532_histBsct,atlid_histBsct + cloudsat_preclvl,grLidar532_histBsct,atlid_histBsct,& + RTTOV_MAX_CHANNELS ! JKS needed for RTTOV to be in cosp_optical_inputs USE MOD_COSP_MODIS_INTERFACE, ONLY: cosp_modis_init, modis_IN USE MOD_COSP_RTTOV_INTERFACE, ONLY: cosp_rttov_init, rttov_IN USE MOD_COSP_MISR_INTERFACE, ONLY: cosp_misr_init, misr_IN @@ -67,7 +68,8 @@ MODULE MOD_COSP USE MOD_PARASOL, ONLY: parasol_subcolumn, parasol_column USE MOD_COSP_STATS, ONLY: COSP_LIDAR_ONLY_CLOUD,COSP_CHANGE_VERTICAL_GRID, & COSP_DIAG_WARMRAIN - use mod_cosp_rttov, ONLY: rttov_column + use mod_cosp_rttov, ONLY: rttov_simulate ! JKS new function +! use mod_cosp_rttov, ONLY: rttov_column,rttov_simulate ! JKS new function IMPLICIT NONE @@ -133,7 +135,15 @@ MODULE MOD_COSP Ncolumns, & ! Number of columns. Nlevels, & ! Number of levels. Npart, & ! Number of cloud meteors for LIDAR simulators. - Nrefl ! Number of reflectances for PARASOL simulator + Nrefl, & ! Number of reflectances for PARASOL simulator +! RTTOV inputs JKS + NchanIN_rttov, & ! Number of RTTOV channels + platformIN_rttov, & ! RTTOV platform integer + satelliteIN_rttov, & ! RTTOV satellite integer + instrumentIN_rttov ! RTTOV instrument integer +! integer,allocatable,dimension(RTTOV_MAX_CHANNELS) :: & + integer,dimension(RTTOV_MAX_CHANNELS) :: & ! JKS + channelsIN_rttov ! RTTOV channels for the specified instrument real(wp) :: & emsfc_lw ! Surface emissivity @ 11micron real(wp),allocatable,dimension(:,:,:) :: & @@ -290,7 +300,7 @@ MODULE MOD_COSP modis_Optical_Thickness_vs_ReffICE => null(), & ! Tau/ReffICE joint histogram modis_Optical_Thickness_vs_ReffLIQ => null() ! Tau/ReffLIQ joint histogram - ! RTTOV outputs + ! RTTOV outputs - JKS consider clear-sky and cloudy-sky values here real(wp),pointer :: & rttov_tbs(:,:) => null() ! Brightness Temperature @@ -726,6 +736,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) endif endif + ! JKS: Will need to add cloud liquid and ice parameter (r_eff) if (Lrttov_column) then rttovIN%nPoints => Npoints rttovIN%nLevels => cospIN%nLevels @@ -1518,18 +1529,40 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! RTTOV if (lrttov_column) then - call rttov_column(rttovIN%nPoints,rttovIN%nLevels,rttovIN%nSubCols,rttovIN%q, & - rttovIN%p,rttovIN%t,rttovIN%o3,rttovIN%ph,rttovIN%h_surf, & - rttovIN%u_surf,rttovIN%v_surf,rttovIN%p_surf,rttovIN%t_skin, & - rttovIN%t2m,rttovIN%q2m,rttovIN%lsmask,rttovIN%longitude, & - rttovIN%latitude,rttovIN%seaice,rttovIN%co2,rttovIN%ch4, & - rttovIN%n2o,rttovIN%co,rttovIN%zenang,lrttov_cleanUp, & - cospOUT%rttov_tbs(ij:ik,:),cosp_simulator(nError+1), & - ! Optional arguments for surface emissivity calculation - month=rttovIN%month) - ! Optional arguments to rttov for all-sky calculation - ! rttovIN%month, rttovIN%tca,rttovIN%cldIce,rttovIN%cldLiq, & - ! rttovIN%fl_rain,rttovIN%fl_snow) + +! JKS building new call +! call rttov_column(rttovIN%nPoints,rttovIN%nLevels,rttovIN%nSubCols,rttovIN%q, & +! rttovIN%p,rttovIN%t,rttovIN%o3,rttovIN%ph,rttovIN%h_surf, & +! rttovIN%u_surf,rttovIN%v_surf,rttovIN%p_surf,rttovIN%t_skin, & +! rttovIN%t2m,rttovIN%q2m,rttovIN%lsmask,rttovIN%longitude, & +! rttovIN%latitude,rttovIN%seaice,rttovIN%co2,rttovIN%ch4, & +! rttovIN%n2o,rttovIN%co,rttovIN%zenang,lrttov_cleanUp, & +! cospOUT%rttov_tbs(ij:ik,:),cosp_simulator(nError+1), & +! ! Optional arguments for surface emissivity calculation +! month=rttovIN%month) +! ! Optional arguments to rttov for all-sky calculation +! ! rttovIN%month, rttovIN%tca,rttovIN%cldIce,rttovIN%cldLiq, & +! ! rttovIN%fl_rain,rttovIN%fl_snow) + + ! JKS new RTTOV subroutine for v13 + !call rttov_simulate(rttovIN,cospOUT%rttov_tbs(ij:ik,:),cosp_simulator(nError+1)) !,& + + call rttov_simulate(rttovIN%nPoints,rttovIN%nLevels,rttovIN%nSubCols,rttovIN%q, & + rttovIN%p,rttovIN%t,rttovIN%o3,rttovIN%ph,rttovIN%h_surf, & + rttovIN%u_surf,rttovIN%v_surf,rttovIN%p_surf,rttovIN%t_skin, & + rttovIN%t2m,rttovIN%q2m,rttovIN%lsmask,rttovIN%longitude, & + rttovIN%latitude,rttovIN%seaice,rttovIN%co2,rttovIN%ch4, & + rttovIN%n2o,rttovIN%co,rttovIN%zenang,lrttov_cleanUp, & +! Previously optional emissivity arguments + rttovIN%surfem,rttovIN%month, & +! Previously optional cloud arguments + rttovIN%tca,rttovIN%cldIce,rttovIN%cldLiq, & + rttovIN%fl_rain,rttovIN%fl_snow, & +! Outputs + cospOUT%rttov_tbs(ij:ik,:),cosp_simulator(nError+1)) + +! month=rttovIN%month) + endif !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1750,7 +1783,8 @@ end function COSP_SIMULATOR SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, Latlid, Lparasol, Lrttov, & cloudsat_radar_freq, cloudsat_k2, cloudsat_use_gas_abs, cloudsat_do_ray, & isccp_top_height, isccp_top_height_direction, surface_radar, rcfg, lusevgrid, & - luseCSATvgrid, Nvgrid, Nlevels, cloudsat_micro_scheme) + luseCSATvgrid, Nvgrid, Nlevels, cloudsat_micro_scheme, & + NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN) ! INPUTS logical,intent(in) :: Lisccp,Lmodis,Lmisr,Lcloudsat,Lcalipso,LgrLidar532,Latlid,Lparasol,Lrttov @@ -1761,7 +1795,13 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La isccp_top_height_direction, & ! Nlevels, & ! Nvgrid, & ! Number of levels for new L3 grid - surface_radar ! + surface_radar, & ! + NchanIN, & ! RTTOV arguments here and below JKS + platformIN, & + satelliteIN, & + instrumentIN + integer,dimension(RTTOV_MAX_CHANNELS) :: & + channelsIN ! RTTOV: Channel numbers real(wp),intent(in) :: & cloudsat_radar_freq, & ! cloudsat_k2 ! @@ -1817,7 +1857,9 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La if (Lisccp) call cosp_isccp_init(isccp_top_height,isccp_top_height_direction) if (Lmodis) call cosp_modis_init() if (Lmisr) call cosp_misr_init() - if (Lrttov) call cosp_rttov_init() + if (Lrttov) call cosp_rttov_init(NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN) ! JKS arguments must be available +! if (Lrttov) call cosp_rttov_init() ! JKS arguments must be available + if (Lcloudsat) call cosp_cloudsat_init(cloudsat_radar_freq,cloudsat_k2, & cloudsat_use_gas_abs,cloudsat_do_ray,R_UNDEF,N_HYDRO, surface_radar, & rcfg,cloudsat_micro_scheme) From 7fe34d5a5ca31b50949bf8f56f560977de9503ef Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 28 Feb 2023 11:35:58 -0700 Subject: [PATCH 015/159] Update STUB to work with changes to cosp_rttov_init and cosp.F90 --- src/simulator/cosp_rttov_interfaceSTUB.F90 | 32 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/simulator/cosp_rttov_interfaceSTUB.F90 b/src/simulator/cosp_rttov_interfaceSTUB.F90 index 654a8df619..77e4a89606 100644 --- a/src/simulator/cosp_rttov_interfaceSTUB.F90 +++ b/src/simulator/cosp_rttov_interfaceSTUB.F90 @@ -32,6 +32,7 @@ ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MODULE MOD_COSP_RTTOV_INTERFACE USE COSP_KINDS, ONLY: wp + USE MOD_COSP_CONFIG, ONLY: RTTOV_MAX_CHANNELS,rttovDir IMPLICIT NONE ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! TYPE rttov_in @@ -41,6 +42,7 @@ MODULE MOD_COSP_RTTOV_INTERFACE nPoints, & ! Number of profiles to simulate nLevels, & ! Number of levels nSubCols, & ! Number of subcolumns + nChannels, & ! Number of channels to simulate month ! Month (needed for surface emissivity calculation) real(wp),pointer :: & zenang, & ! Satellite zenith angle @@ -82,9 +84,35 @@ MODULE MOD_COSP_RTTOV_INTERFACE !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_init !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_INIT() - + SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN) + integer,intent(in) :: & + NchanIN, & ! Number of channels + platformIN, & ! Satellite platform + satelliteIN, & ! Satellite + instrumentIN ! Instrument + integer,intent(in),dimension(RTTOV_MAX_CHANNELS) :: & + channelsIN ! RTTOV channels END SUBROUTINE COSP_RTTOV_INIT + + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE cosp_rttov_simulate + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN, & ! Inputs + Tb,error) ! Outputs + + type(rttov_in),intent(in) :: & + rttovIN + real(wp),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! + Tb ! RTTOV brightness temperature. + character(len=128) :: & + error ! Error messages (only populated if error encountered) + + + ! How do I want the interface to function? How should it to be consistent with the rest of COSP? + + END SUBROUTINE COSP_RTTOV_SIMULATE + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! END MODULE ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From 97c25ff708f92078e30b82879094f97110d4dfad Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 28 Feb 2023 14:04:01 -0700 Subject: [PATCH 016/159] Cleaned cosp_rttov_v13 of old code. --- src/simulator/rttov/cosp_rttov_v13.F90 | 949 +++---------------------- 1 file changed, 104 insertions(+), 845 deletions(-) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 94d82379c5..04e6025ba5 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -29,30 +29,79 @@ ! History ! March 2016 - M. Johnston - Original version ! April 2016 - D. Swales - Modified for use in COSPv2.0 +! JKS fill this in when working :) + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% module mod_cosp_rttov - use rttov_const, only : errorstatus_success, errorstatus_fatal - use rttov_types, only : rttov_options,rttov_coefs,profile_type, & - transmission_type,radiance_type,rttov_chanprof, & - rttov_emissivity,profile_cloud_type,rttov_scatt_coef, & - rttov_options_scatt - use rttov_const, only : surftype_sea, surftype_land, surftype_seaice + use rttov_const, only : errorstatus_success, errorstatus_fatal, & + platform_name,inst_name +! Use RTTOV v13 types here, more may be needed + use rttov_types, only : rttov_options,rttov_coefs,rttov_profile, & + rttov_transmission,rttov_radiance,rttov_chanprof, & + rttov_emissivity,rttov_reflectance,rttov_opt_param +! use rttov_types, only : rttov_options,rttov_coefs,profile_type, & +! transmission_type,radiance_type,rttov_chanprof, & +! rttov_emissivity,profile_cloud_type,rttov_scatt_coef, & +! rttov_options_scatt + use rttov_const, only : surftype_sea, surftype_land, surftype_seaice, & + errorstatus_success,errorstatus_fatal, & + platform_name,inst_name, & + sensor_id_mw,sensor_id_po use rttov_unix_env, only : rttov_exit use cosp_kinds, only : wp use mod_cosp_config, only : RTTOV_MAX_CHANNELS,N_HYDRO,rttovDir use cosp_phys_constants, only : mdry=>amd,mO3=>amO3,mco2=>amCO2,mCH4=>amCH4, & mn2o=>amN2O,mco=>amCO + + + ! The rttov_emis_atlas_data type must be imported separately + use mod_rttov_emis_atlas, ONLY : & + rttov_emis_atlas_data, & + atlas_type_ir, atlas_type_mw + + ! The rttov_brdf_atlas_data type must be imported separately + use mod_rttov_brdf_atlas, ONLY : rttov_brdf_atlas_data + + ! jpim, jprb and jplm are the RTTOV integer, real and logical KINDs + use parkind1, ONLY : jpim, jprb, jplm + + use rttov_unix_env, ONLY : rttov_exit + implicit none + + +! Old includes +!#include "rttov_direct.interface" +!#include "rttov_alloc_prof.interface" +!#include "rttov_alloc_rad.interface" +!#include "rttov_alloc_transmission.interface" +!#include "rttov_dealloc_coefs.interface" +!#include "rttov_user_options_checkinput.interface" +!#include "rttov_read_coefs.interface" +!#include "rttov_get_emis.interface" +!#include "rttov_boundaryconditions.interface" + +! New includes for v13 (will need to clean up others) #include "rttov_direct.interface" -#include "rttov_alloc_prof.interface" -#include "rttov_alloc_rad.interface" -#include "rttov_alloc_transmission.interface" +#include "rttov_parallel_direct.interface" +#include "rttov_read_coefs.interface" +#include "rttov_read_scattcoeffs.interface" #include "rttov_dealloc_coefs.interface" +#include "rttov_alloc_direct.interface" +#include "rttov_init_emis_refl.interface" #include "rttov_user_options_checkinput.interface" -#include "rttov_read_coefs.interface" -#include "rttov_get_emis.interface" -#include "rttov_boundaryconditions.interface" +#include "rttov_print_opts.interface" +#include "rttov_print_profile.interface" +#include "rttov_skipcommentline.interface" + +! Includes when directly inputting cloud optical parameters +#include "rttov_init_opt_param.interface" +#include "rttov_bpr_init.interface" +#include "rttov_bpr_calc.interface" +#include "rttov_bpr_dealloc.interface" +#include "rttov_legcoef_calc.interface" + ! Module parameters integer, parameter :: maxlim = 10000 @@ -70,27 +119,36 @@ module mod_cosp_rttov ! Scattering coefficients (read in once during initialization) type(rttov_coefs) :: & coef_rttov - type(rttov_scatt_coef) :: & - coef_scatt +! JKS - KISS +! type(rttov_scatt_coef) :: & +! coef_scatt ! RTTOV setup and options (set during initialization) type(rttov_options) :: & opts ! defaults to everything optional switched off - type(rttov_options_scatt) :: & - opts_scatt + +! JKS - KISS +! type(rttov_options_scatt) :: & +! opts_scatt contains ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE rttov_column + ! SUBROUTINE rttov_simulate - JKS ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine rttov_column(nPoints,nLevels,nSubCols,q,p,t,o3,ph,h_surf,u_surf,v_surf, & - p_surf,t_skin,t2m,q2m,lsmask,lon,lat,seaice,co2,ch4,n2o,co, & - zenang,lCleanup, & - ! Outputs - Tb,error, & - ! Optional arguments for surface emissivity calculation. - surfem,month, & - ! Optional arguments for all-sky calculation. - tca,ciw,clw,rain,snow) + subroutine rttov_simulate(nPoints,nLevels,nSubCols,q,p,t,o3,ph,h_surf,u_surf,v_surf, & + p_surf,t_skin,t2m,q2m,lsmask,lon,lat,seaice,co2,ch4,n2o,co, & + zenang,lCleanup, & + ! Optional arguments for surface emissivity calculation. + surfem,month, & + ! Optional arguments for all-sky calculation. + tca,ciw,clw,rain,snow, & + ! Outputs + Tb,error) + +! coef_rttov, & ! JKS added coef_rttov + ! Optional arguments for all-sky calculation. +! tca,ciw,clw,rain,snow) + + ! Inputs integer,intent(in) :: & nPoints, & ! Number of gridpoints @@ -123,7 +181,16 @@ subroutine rttov_column(nPoints,nLevels,nSubCols,q,p,t,o3,ph,h_surf,u_surf,v_sur ph ! Pressure @ half-levels (Pa) logical,intent(in) :: & lCleanup ! Flag to determine whether to deallocate RTTOV types - + + ! Cloud fields + real(wp),dimension(nPoints,nLevels),intent(in) :: & + tca ! Total column cloud amount (0-1) + real(wp),dimension(nPoints,nSubCols,nLevels),intent(in) :: & + ciw, & ! Cloud ice + clw, & ! Cloud liquid + rain, & ! Precipitation flux (kg/m2/s) + snow ! Precipitation flux (kg/m2/s) + ! Optional inputs (Needed for surface emissivity calculation) integer,optional :: & month ! Month (needed to determine table to load) @@ -131,837 +198,29 @@ subroutine rttov_column(nPoints,nLevels,nSubCols,q,p,t,o3,ph,h_surf,u_surf,v_sur surfem ! Surface emissivity for each RTTOV channel ! Optional inputs (Needed for all-sky calculation) - real(wp),dimension(nPoints,nLevels),optional :: & - tca ! Total column cloud amount (0-1) - real(wp),dimension(nPoints,nSubCols,nLevels),optional :: & - ciw, & ! Cloud ice - clw, & ! Cloud liquid - rain, & ! Precipitation flux (kg/m2/s) - snow ! Precipitation flux (kg/m2/s) +! real(wp),dimension(nPoints,nLevels),optional :: & +! tca ! Total column cloud amount (0-1) +! real(wp),dimension(nPoints,nSubCols,nLevels),optional :: & +! ciw, & ! Cloud ice +! clw, & ! Cloud liquid +! rain, & ! Precipitation flux (kg/m2/s) +! snow ! Precipitation flux (kg/m2/s) ! Outputs real(wp),dimension(nPoints,nChannels) :: & Tb ! RTTOV brightness temperature. character(len=128) :: & error ! Error messages (only populated if error encountered) - - ! Local variables - integer :: & - nloop,rmod,il,istart,istop,za,i,j,subcol,errorstatus,npts_it - integer,dimension(60) :: & - alloc_status - real(wp),dimension(nPoints) :: & - sh_surf - real(wp),dimension(nPoints,nLevels) :: & - sh,totalice - real(wp),dimension(nSubCols,nPoints,nChannels) :: & - Tbs ! Subcolumn brightness temperature - logical :: & - use_totalice, mmr_snowrain, cfrac - logical :: & - lallSky, & ! Control for type of brightness temperature calculation - ! (False(default) => clear-sky brightness temperature, True => All-sky) - lsfcEmis ! Control for surface emissivity calculation (true => compute surface emissivity, - ! provided that the field "month" is available) - -#include "rttov_read_coefs.interface" -#include "rttov_read_scattcoeffs.interface" -#include "rttov_user_options_checkinput.interface" -#include "rttov_dealloc_coefs.interface" -#include "rttov_dealloc_scattcoeffs.interface" -#include "rttov_setup_emis_atlas.interface" -#include "rttov_deallocate_emis_atlas.interface" -#include "rttov_print_opts.interface" -#include "rttov_print_profile.interface" -#include "rttov_boundaryconditions.interface" ! Initialize some things - totalice = 0._wp - Tbs(:,:,:) = 0._wp Tb(:,:) = 0._wp error = '' - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Setup for call to RTTOV - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! First, check to see if we are doing an all-sky or clear-sky calculation brightness - ! temperature - lallSky = .false. - if (present(tca) .and. present(clw) .and. present(ciw) .and. present(rain) & - .and. present(snow)) lallSky=.true. - - ! Check to see if we need to compute the surface emissivity (defualt is to compute - ! surface emissivity using the atlas tables) - lsfcEmis = .true. - if (present(surfem)) lsfcEmis = .false. - - ! We also need the month for the emissivity atlas, so check... - if (.not. present(month)) lsfcEmis = .false. - - if (lsfcEmis .eq. .false. .and. .not. present(surfem)) then - error = 'ERROR (rttov_column): User did not provide surface emissivity and did not '//& - 'request the surface emissivity to be calculated!!!' - return - endif - - ! Convert specific humidity to ppmv - sh = ( q / ( q + eps * ( 1._wp - q ) ) ) * 1e6 - sh_surf = ( q2m / ( q2m + eps * ( 1._wp - q2m ) ) ) * 1e6 - - ! Settings unique to all-sky call. - use_totalice = .false. - mmr_snowrain = .true. - cfrac = .true. - opts_scatt%lusercfrac = cfrac - - ! RTTOV can handle only about 100 profiles at a time (fixme: check this with roger), - ! so we are putting a loop of 100 - nloop = npoints / maxlim - rmod = mod( npoints, maxlim ) - if( rmod .ne. 0 ) then - nloop = nloop + 1 - endif - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Initialize emissivity atlas data for chosen sensor. - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - call rttov_setup_emis_atlas(errorstatus,opts,month,coef_rttov,path=trim(rttovDir)//"emis_data/") - if (errorstatus /= errorstatus_success) then - error = 'ERROR (rttov_column): Error reading emis atlas data!' - return - endif - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Some quality control prior to RTTOV call - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Ensure the options and coefficients are consistent - if(opts_scatt%config%do_checkinput) then - call rttov_user_options_checkinput(errorstatus, opts, coef_rttov) - if (errorstatus /= errorstatus_success) then - error = 'ERROR (rttov_column): Error when checking input data!' - return - endif - endif - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Call to RTTOV - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Looping over maxlim number of profiles - do il = 1, nloop - istart = (il - 1) * maxlim + 1 - istop = min(il * maxlim, npoints) - if( ( il .eq. nloop ) .and. ( rmod .ne. 0 ) ) then - npts_it = rmod - else - npts_it = maxlim - endif - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Clear-sky brightness temperature - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - if (.not. lallSky) then - call rttov_multprof(nChannels,iChannel,surfem,npts_it,nLevels,platform, & - satellite,sensor,opts,coef_rttov,zenang, & - p(istart:istop,:)/100._wp,t(istart:istop,:), & - sh(istart:istop,:),(mdry/mo3)*o3(istart:istop,:)*1e6, & - (mdry/mco2)*co2*1e6,(mdry/mch4)*ch4*1e6,(mdry/mn2o)*n2o*1e6,& - (mdry/mco)*co*1e6,h_surf(istart:istop),u_surf(istart:istop),& - v_surf(istart:istop),t_skin(istart:istop), & - p_surf(istart:istop)/100.,t2m(istart:istop), & - sh_surf(istart:istop),lsmask(istart:istop), & - seaice(istart:istop),lat(istart:istop),lon(istart:istop), & - Tb(istart:istop,:)) - endif - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! All-sky brightness temperature - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - if (lallSky) then - ! Loop over all subcolumns - do subcol = 1, nSubCols - ! Call RTTOV - call cosp_rttov_mwscatt(nChannels,iChannel,surfem,nPoints,nlevels,platform, & - satellite,sensor,opts,opts_scatt,coef_rttov, & - coef_scatt,zenang,p(istart:istop,:)/100._wp, & - ph(istart:istop,:)/100._wp,t(istart:istop, :), & - sh(istart:istop, :), & - (mdry/mo3)*o3(istart:istop,:)*1e6, & - clw(istart:istop,subcol,:), & - ciw(istart:istop,subcol,:),tca(istart:istop, :), & - totalice(istart:istop,:),snow(istart:istop,subcol,:),& - rain(istart:istop,subcol,:),(mdry/mco2)*co2*1e6, & - (mdry/mch4)*ch4*1e6,(mdry/mn2o)*n2o*1e6, & - (mdry/mco)*co*1e6,h_surf(istart:istop), & - u_surf(istart:istop),v_surf(istart:istop), & - t_skin(istart:istop), p_surf(istart:istop)/100., & - t2m(istart:istop),sh_surf(istart:istop), & - lsmask(istart:istop),seaice(istart:istop), & - lat(istart:istop),lon(istart:istop), use_totalice, & - mmr_snowrain,cfrac,Tbs(subcol,istart:istop,:)) - enddo - endif - enddo - - ! For all-sky calculation we need to average together all of the cloudy subcolumns. - if (lallSky) then - do subcol = 1, nSubCols - Tb = Tb + tbs(subcol,:,:) - enddo - Tb = Tb/nSubCols - endif - - ! Free up space - if (lCleanup) then - call rttov_dealloc_coefs(errorstatus,coef_rttov) - call rttov_deallocate_emis_atlas(coef_rttov) - if (lallSky) call rttov_dealloc_scattcoeffs(coef_scatt) - endif - end subroutine rttov_column - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE rttov_multprof - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine rttov_multprof( & - nch_in, & ! number of channels - ichan_in, & ! channel indices - surfem_in, & ! surface emissivity values - prf_num_in, & ! number of profiles to simulate - nlevels_in, & ! number of pressure levels - plat_in, & ! platform number - sat_in, & ! satellite number - sens_in, & ! instrument number - opts, & - coef_rttov, & - zenang_in, & ! zenith angle - p_in, & ! pressure [hpa] - t_in, & ! temperature [ k ] - q_in, & ! specific humidity [ ppmv ] - o3_in, & ! ozone vmr [ ppmv ] - co2_in, & ! co2 vmr [ ppmv ] *this is a single value* - ch4_in, & ! ch4 vmr [ ppmv ] *this is a single value* - n2o_in, & ! n2o vmr [ ppmv ] *this is a single value* - co_in, & ! co vmr [ ppmv ] *this is a single value* - h_surf, & ! surface height [ m ] - u_surf, & ! u wind at 10 m [ m/s ] - v_surf, & ! v wind at 10 m [ m/s ] - t_skin, & ! skin temperatre [ k ] - p_surf, & ! surface pressure - t_surf, & ! 1.5 m temperature [ k ] - q_surf, & ! 1.5 m specific humidity [ ppmv ] - lsmask, & ! land sea mask - seaice, & ! seaice fraction - latitude, & ! latitude [ deg north ] - longitude, & ! longitude [ deg east ] - tbs & ! brightness temperature [ k ] (output) - ) - - !------ input arguments. no rttov kinds should be used here ----------------- - integer, intent(in) :: nch_in ! number of channels to be computed - integer, intent(in) :: ichan_in(nch_in) ! indices of selected channels - real(wp), intent(in) :: surfem_in(nch_in) ! surface emissivities for the channels - integer, intent(in) :: prf_num_in - integer, intent(in) :: nlevels_in - integer, intent(in) :: plat_in ! satellite platform - integer, intent(in) :: sat_in ! satellite number - integer, intent(in) :: sens_in ! satellite sensor - real(wp), intent(in) :: zenang_in ! satellite zenith angle - - type(rttov_options) :: opts - type(rttov_coefs) :: coef_rttov - - real(wp), intent(in) :: p_in(prf_num_in, nlevels_in) ! pressure profiles - real(wp), intent(in) :: t_in(prf_num_in, nlevels_in) ! temperature profiles - real(wp), intent(in) :: q_in(prf_num_in, nlevels_in) ! humidity profiles - real(wp), intent(in) :: o3_in(prf_num_in, nlevels_in) ! ozone profiles - - ! the following trace gases contain constant values - real(wp), intent(in) :: co2_in ! carbon dioxide - real(wp), intent(in) :: ch4_in ! methane - real(wp), intent(in) :: n2o_in ! n2o - real(wp), intent(in) :: co_in ! carbon monoxide - real(wp), intent(in) :: h_surf(prf_num_in) ! surface height - real(wp), intent(in) :: u_surf(prf_num_in) ! u component of surface wind - real(wp), intent(in) :: v_surf(prf_num_in) ! v component of surface wind - real(wp), intent(in) :: t_skin(prf_num_in) ! surface skin temperature - real(wp), intent(in) :: p_surf(prf_num_in) ! surface pressure - real(wp), intent(in) :: t_surf(prf_num_in) ! 1.5 m temperature - real(wp), intent(in) :: q_surf(prf_num_in) ! 1.5 m specific humidity - real(wp), intent(in) :: lsmask(prf_num_in) ! land-sea mask - real(wp), intent(in) :: seaice(prf_num_in) ! sea-ice fraction - real(wp), intent(in) :: latitude(prf_num_in) ! latitude - real(wp), intent(in) :: longitude(prf_num_in) ! longitude - - real(wp), intent(inout) :: tbs(prf_num_in, nch_in) ! tbs (in the right format) - - !------ local variables. use only rttov kinds or derived types. - ! logical variables are declared with the same kind - ! as integers, as they are affected inthe same way by flags like -qintsize=8 - - ! type(rttov_options) :: opts ! options structure - ! type(rttov_coefs), allocatable :: coefs(:) ! coefficients structure - type(rttov_chanprof), allocatable :: chanprof(:) ! input channel/profile list - type(profile_type), allocatable :: profiles(:) ! input profiles - logical, allocatable :: calcemis(:) ! flag to indicate calculation of emissivity within rttov - type(rttov_emissivity), allocatable :: emissivity(:) ! input/output surface emissivity - type(transmission_type) :: transmission ! output transmittances - type(radiance_type) :: radiance ! output radiances - - integer, allocatable :: instrument(:,:) ! instrument id (3 x n_instruments) - integer, allocatable :: nchan(:) ! number of channels per instrument - integer, allocatable :: ichan(:,:) ! channel list per instrument - - integer :: asw - integer :: mxchn - integer :: nrttovid ! maximum number of instruments - integer :: no_id ! instrument loop index - integer :: i, j, jch - integer :: nprof ! number of calls to rttov - integer :: nch ! intermediate variable - integer :: errorstatus - integer :: ich, ich_temp, nchanprof, nchannels, chan - integer :: alloc_status(60) - - real(wp), allocatable :: input_emissivity (:) - - character (len=14) :: nameofroutine = 'rttov_multprof' - - logical :: refrac, solrad, laerosl, lclouds, lsun, all_channels - - ! local variables for input arguments that need type casting to avoid type-mismatch with - ! rttov kinds. this happens with some compiler flags (-qintsize=8). - integer :: prof_num - integer :: nlevels - - ! -------------------------------------------------------------------------- - ! 0. initialise cosp-specific things - ! -------------------------------------------------------------------------- - - ! type-casting of input arguments that need to be passed to rttov - prof_num = prf_num_in - nlevels = nlevels_in - nprof = prof_num - - ! currently we plan to calculate only 1 instrument per call - nrttovid = 1 - mxchn = nch_in - - errorstatus = 0 - alloc_status(:) = 0 - - ! allocate(coefs(nrttovid), stat = alloc_status(1)) - - ! allocate(instrument(3, nrttovid), stat = alloc_status(4)) - - !maximum number of channels allowed for one instrument is mxchn - ! allocate(surfem(nch_in, nrttovid), stat = alloc_status(11)) - allocate(ichan(nch_in, nrttovid), stat = alloc_status(12)) - call rttov_error('ichan mem allocation error for profile array' , lalloc = .true.) - - - do no_id = 1, nrttovid - ichan(:, no_id) = ichan_in - enddo - - asw = 1 ! switch for allocation passed into rttov subroutines - - ! allocate input profile arrays - allocate(profiles(nprof), stat = alloc_status(1)) - call rttov_error('Profile mem allocation error' , lalloc = .true.) - - call rttov_alloc_prof( & - errorstatus, & - nprof, & - profiles, & - nlevels, & - opts, & - asw, & - coefs = coef_rttov, & - init = .true.) - call rttov_error('Profile 2 mem allocation error' , lalloc = .true.) - ! -------------------------------------------------------------------------- - ! 5. store profile data in profile type - ! -------------------------------------------------------------------------- - do i = 1, nprof - profiles(i)%p(:) = p_in(i, :) - profiles(i)%t(:) = t_in(i, :) - profiles(i)%q(:) = q_in(i, :) - - where(profiles(i)%q(:) < 1e-4) - profiles(i)%q(:) = 1e-4 - end where - - profiles(i)%cfraction = 0. - profiles(i)%ctp = 500. - - ! 2m parameters - profiles(i)%s2m%p = p_surf(i) - profiles(i)%s2m%t = t_surf(i) - profiles(i)%s2m%q = q_surf(i) - profiles(i)%s2m%u = u_surf(i) ! dar: hard-coded at 2ms-1? - profiles(i)%s2m%v = v_surf(i) ! dar: hard-coded at 2ms-1? - profiles(i)%s2m%wfetc = 10000. ! dar: default? - - ! skin variables for emissivity calculations - profiles(i)%skin%t = t_skin(i) - - ! fastem coefficients - for mw calculations - profiles(i)%skin%fastem(1) = 3.0 - profiles(i)%skin%fastem(2) = 5.0 - profiles(i)%skin%fastem(3) = 15.0 - profiles(i)%skin%fastem(4) = 0.1 - profiles(i)%skin%fastem(5) = 0.3 - - profiles(i)%zenangle = zenang_in ! pass in from cosp - - profiles(i)%azangle = 0. ! hard-coded in rttov9 int - - profiles(i)%latitude = latitude(i) - profiles(i)%longitude = longitude(i) - profiles(i)%elevation = h_surf(i) - - profiles(i)%sunzenangle = 0. ! hard-coded in rttov9 int - profiles(i)%sunazangle = 0. ! hard-coded in rttov9 int - - ! surface type - ! land-sea mask indicates proportion of land in grid - if (lsmask(i) < 0.5) then - profiles(i)%skin%surftype = surftype_sea - else - profiles(i)%skin%surftype = surftype_land - endif - ! sea-ice fraction - if (seaice(i) >= 0.5) then - profiles(i)%skin%surftype = surftype_seaice - endif - - ! dar: hard-coded to 1 (=ocean water) in rttov 9 int - profiles(i)%skin%watertype = 1 - profiles(i) %idg = 0. - profiles(i) %ish = 0. - enddo - ! end of 5. - - ich_temp = 1 - nchannels = nch_in - do no_id = 1, nrttovid - - ! -------------------------------------------------------------------------- - ! 3. build the list of profile/channel indices in chanprof - ! -------------------------------------------------------------------------- - - allocate(nchan(nprof)) ! number of channels per profile - nchan(:) = size(ichan(:,no_id)) ! = nch_in - - ! size of chanprof array is total number of channels over all profiles - ! square in this case - here same channels done for all profiles - nchanprof = sum(nchan(:)) - - ! pack channels and input emissivity arrays - allocate(chanprof(nchanprof)) - ! allocate(emis(nchanprof)) - chanprof(:)%chan =0 - - nch = 0 - do j = 1, nprof - do jch = 1, nchan(j) - nch = nch + 1 - chanprof(nch)%prof = j - if(ichan(jch, no_id) < 1) then - errorstatus = errorstatus_fatal - call rttov_error('Sensor channel number must be 1 or greater' , lalloc = .true.) - else - chanprof(nch)%chan = ichan(jch, no_id) - endif - enddo - enddo - ! end of 3. - - ! allocate output radiance arrays - call rttov_alloc_rad( & - errorstatus, & - nchanprof, & - radiance, & - nlevels - 1, & ! nlayers - asw) - call rttov_error('allocation error for radiance arrays' , lalloc = .true.) - - ! allocate transmittance structure - call rttov_alloc_transmission( & - errorstatus, & - transmission, & - nlevels - 1, & - nchanprof, & - asw, & - init=.true.) - call rttov_error('allocation error for transmission arrays' , lalloc = .true.) - - ! allocate arrays for surface emissivity - allocate(calcemis(nchanprof), stat=alloc_status(1)) - allocate(emissivity(nchanprof), stat=alloc_status(2)) - call rttov_error('mem allocation error for emissivity arrays' , lalloc = .true.) - - call rttov_get_emis( & - & errorstatus, & - & opts, & - & chanprof, & - & profiles, & - & coef_rttov, & - !& resolution=resolution, & ! *** MW atlas native - ! resolution is 0.25 degree lat/lon; if you know better - ! value for satellite footprint (larger than this) then - ! you can specify it here - & emissivity=emissivity(:)%emis_in) - ! & emissivity(:)%emis_in) - - call rttov_error('Get emissivity error' , lalloc = .true.) - calcemis(:) = .false. - ! calculate emissivity for missing and ocean location (fastem) - where (emissivity(:)%emis_in <= 0.0) - calcemis(:) = .true. - endwhere - - call rttov_direct( & - errorstatus, &! out - chanprof, & - opts, & - profiles, &! in - coef_rttov, &! in - transmission, &! out - radiance, & - calcemis = calcemis, &! in - emissivity = emissivity) ! inout - call rttov_error('rttov_direct error', lalloc = .true.) - - tbs(1:prof_num , ich_temp:ich_temp + size(ichan(:,no_id)) - 1) = & - transpose(reshape(radiance%bt(1:nchanprof), (/ size(ichan(:,no_id)), prof_num/) )) - - ich_temp = ich_temp + size(ichan(:,no_id)) - - ! -------------------------------------------------------------------------- - ! 8. deallocate all rttov arrays and structures - ! -------------------------------------------------------------------------- - deallocate (nchan, stat=alloc_status(3)) - deallocate (chanprof, stat=alloc_status(4)) - deallocate (emissivity, stat=alloc_status(5)) - deallocate (calcemis, stat=alloc_status(6)) - call rttov_error('rttov array deallocation error', lalloc = .true.) - - asw = 0 ! switch for deallocation passed into rttov subroutines - - ! deallocate radiance arrays - call rttov_alloc_rad(errorstatus, nchannels, radiance, nlevels - 1, asw) - call rttov_error('radiance deallocation error', lalloc = .true.) - - ! deallocate transmission arrays - call rttov_alloc_transmission(errorstatus, transmission, nlevels - 1, nchannels, asw) - call rttov_error('transmission deallocation error', lalloc = .true.) - - enddo - - ! deallocate profile arrays - call rttov_alloc_prof(errorstatus, nprof, profiles, nlevels, opts, asw) - call rttov_error('profile deallocation error', lalloc = .true.) - - deallocate(profiles, stat=alloc_status(1)) - call rttov_error('mem deallocation error for profile array', lalloc= .true.) - - contains - - subroutine rttov_error(msg, lalloc) - character(*) :: msg - logical :: lalloc - - if(lalloc) then - if (any(alloc_status /= 0)) then - write(*,*) msg - errorstatus = 1 - call rttov_exit(errorstatus) - endif - else - if (errorstatus /= errorstatus_success) then - write(*,*) msg - call rttov_exit(errorstatus) - endif - endif - end subroutine rttov_error - - end subroutine rttov_multprof - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - !----------------- subroutine cosp_rttov_mwscatt --------------- - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - subroutine cosp_rttov_mwscatt(& - nch_in, & ! number of channels - ichan_in, & ! channel indices - surfem_in, & ! surface emissivity values - prf_num_in, & ! number of profiles to simulate - nlevels_in, & ! number of pressure levels - plat_in, & ! platform number - sat_in, & ! satellite number - sens_in, & ! instrument number - opts, & - opts_scatt, & - coef_rttov, & - coef_scatt, & - zenang_in, & ! zenith angle - p_in, & ! pressure [hpa] - ph_in, & ! pressure on half levels [hpa] - t_in, & ! temperature [ k ] - q_in, & ! specific humidity [ ppmv ] - o3_in, & ! ozone vmr [ ppmv ] - clw_in, & ! cloud water [0-1] - ciw_in, & ! cloud ice [0-1] - cc_in, & ! effective cloud fraction [0-1] - totalice_in,& ! total ice, except snow [kg/kg] or [kg/m2/s] - sp_in, & ! solid precip with snow [kg/kg] or [kg/m2/s] - rain_in, & ! total liquid water [kg/kg] or [kg/m2/s] - co2_in, & ! co2 vmr [ ppmv ] *this is a single value* - ch4_in, & ! ch4 vmr [ ppmv ] *this is a single value* - n2o_in, & ! n2o vmr [ ppmv ] *this is a single value* - co_in, & ! co vmr [ ppmv ] *this is a single value* - h_surf, & ! surface height [ m ] - u_surf, & ! u wind at 10 m [ m/s ] - v_surf, & ! v wind at 10 m [ m/s ] - t_skin, & ! skin temperatre [ k ] - p_surf, & ! surface pressure - t_surf, & ! 1.5 m temperature [ k ] - q_surf, & ! 1.5 m specific humidity [ ppmv ] - lsmask, & ! land sea mask - seaice, & ! seaice fraction - latitude, & ! latitude [ deg north ] - longitude, & ! longitude [ deg east ] - use_totalice,& ! separate ice and snow, or total ice hydrometeor types - mmr_snowrain,& ! set units for snow and rain: if true units are kg/kg (the default) - cfrac, & ! opts_scatt%lusercfrac=true., supply the effective cloud fraction - tbs & ! brightness temperature [ k ] (output) - ) - - - - - - implicit none - - !------ input arguments. no rttov kinds should be used here ----------------- - integer, intent(in) :: nch_in ! number of channels to be computed - integer, intent(in) :: ichan_in(nch_in) ! indices of selected channels - real(wp), intent(in) :: surfem_in(nch_in) ! surface emissivities for the channels - integer, intent(in) :: prf_num_in - integer, intent(in) :: nlevels_in - integer, intent(in) :: plat_in ! satellite platform - integer, intent(in) :: sat_in ! satellite number - integer, intent(in) :: sens_in ! satellite sensor - real(wp), intent(in) :: zenang_in ! satellite zenith angle - - type(rttov_options) :: opts - type(rttov_options_scatt) :: opts_scatt - type(rttov_coefs) :: coef_rttov - type(rttov_scatt_coef) :: coef_scatt - - real(wp), intent(in) :: p_in(prf_num_in, nlevels_in) ! pressure profiles - real(wp), intent(in) :: t_in(prf_num_in, nlevels_in) ! temperature profiles - real(wp), intent(in) :: q_in(prf_num_in, nlevels_in) ! humidity profiles - real(wp), intent(in) :: o3_in(prf_num_in, nlevels_in) ! ozone profiles - real(wp), intent(in) :: clw_in(prf_num_in, nlevels_in) - real(wp), intent(in) :: ciw_in(prf_num_in, nlevels_in) - real(wp), intent(in) :: cc_in(prf_num_in, nlevels_in) - real(wp), intent(in) :: totalice_in(prf_num_in, nlevels_in) - real(wp), intent(in) :: sp_in(prf_num_in, nlevels_in) - real(wp), intent(in) :: rain_in(prf_num_in, nlevels_in) - real(wp), intent(in) :: ph_in(prf_num_in, nlevels_in+1) - - ! the following trace gases contain constant values - real(wp), intent(in) :: co2_in ! carbon dioxide - real(wp), intent(in) :: ch4_in ! methane - real(wp), intent(in) :: n2o_in ! n2o - real(wp), intent(in) :: co_in ! carbon monoxide - real(wp), intent(in) :: h_surf(prf_num_in) ! surface height - real(wp), intent(in) :: u_surf(prf_num_in) ! u component of surface wind - real(wp), intent(in) :: v_surf(prf_num_in) ! v component of surface wind - real(wp), intent(in) :: t_skin(prf_num_in) ! surface skin temperature - real(wp), intent(in) :: p_surf(prf_num_in) ! surface pressure - real(wp), intent(in) :: t_surf(prf_num_in) ! 1.5 m temperature - real(wp), intent(in) :: q_surf(prf_num_in) ! 1.5 m specific humidity - real(wp), intent(in) :: lsmask(prf_num_in) ! land-sea mask - real(wp), intent(in) :: seaice(prf_num_in) ! seaice fraction - real(wp), intent(in) :: latitude(prf_num_in) ! latitude - real(wp), intent(in) :: longitude(prf_num_in) ! longitude - logical, intent(in) :: cfrac, use_totalice, mmr_snowrain - - real(wp), intent(inout) :: tbs(prf_num_in, nch_in) ! tbs (in the right format) - !****************** local variables ********************************************** - logical , allocatable :: calcemis (:) - type(rttov_emissivity) , allocatable :: emissivity (:) - integer , allocatable :: frequencies (:) - type(rttov_chanprof) , allocatable :: chanprof (:) ! channel and profile indices - type(profile_type) , allocatable :: profiles (:) - type(profile_cloud_type) , allocatable :: cld_profiles(:) - - integer, allocatable :: ichan(:,:) ! channel list per instrument - - integer :: errorstatus - type (radiance_type) :: radiance - ! type (rttov_options) :: opts ! defaults to everything optional switched off - ! type (rttov_options_scatt) :: opts_scatt - ! type (rttov_coefs) :: coef_rttov - ! type (rttov_scatt_coef) :: coef_scatt - - ! integer, allocatable :: instrument (:,:) - integer :: j,k,asw - integer :: nchanxnprof, ninstruments - real(wp) :: zenangle - character (len=256) :: outstring - integer :: alloc_status(60) - -#include "rttov_init_rad.interface" -#include "rttov_scatt_setupindex.interface" -#include "rttov_scatt.interface" -#include "rttov_alloc_rad.interface" -#include "rttov_alloc_prof.interface" -#include "rttov_alloc_scatt_prof.interface" -#include "rttov_get_emis.interface" -#include "rttov_boundaryconditions.interface" - - errorstatus = 0 - alloc_status(:) = 0 - ninstruments = 1 ! number of sensors or platforms - - allocate(ichan(nch_in, ninstruments), stat = alloc_status(3)) - - do j = 1, ninstruments - ichan(:, j) = ichan_in - enddo - - nchanxnprof = prf_num_in * nch_in ! total channels to simulate * profiles - - allocate (chanprof(nchanxnprof)) - allocate (frequencies(nchanxnprof)) - allocate (emissivity(nchanxnprof)) - allocate (calcemis(nchanxnprof)) - allocate (profiles(prf_num_in)) - allocate (cld_profiles(prf_num_in)) - - ! request rttov / fastem to calculate surface emissivity - calcemis = .true. - emissivity % emis_in = 0.0 - - ! setup indices - call rttov_scatt_setupindex ( & - & prf_num_in, & ! in - & nch_in, & ! in - & coef_rttov%coef, & ! in - & nchanxnprof, & ! in - & chanprof, & ! out - & frequencies) ! out - - ! allocate profiles (input) and radiance (output) structures - asw = 1 - call rttov_alloc_prof( errorstatus,prf_num_in,profiles,nlevels_in,opts,asw, init = .true.) - call rttov_alloc_scatt_prof(prf_num_in,cld_profiles, nlevels_in, .false., 1, init = .true.) - call rttov_alloc_rad(errorstatus,nchanxnprof,radiance,nlevels_in-1,asw) - - ! fill the profile structures with data - do j = 1, prf_num_in - profiles(j)%latitude = latitude(j) - profiles(j)%longitude = longitude(j) - profiles(j)%elevation = h_surf(j) - profiles(j)%sunzenangle = 0.0 ! hard-coded in rttov9 int - profiles(j)%sunazangle = 0.0 ! hard-coded in rttov9 int - profiles(j)%azangle = 0.0 - profiles(j)%zenangle = zenang_in - profiles(j)%s2m%t = t_surf(j) - profiles(j)%s2m%q = q_surf(j) - profiles(j)%s2m%u = u_surf(j) - profiles(j)%s2m%v = v_surf(j) - profiles(j)%s2m%wfetc = 10000. - profiles(j)%skin%t = t_skin(j) - profiles(j)%skin%watertype = 1 ! ocean water - if (lsmask(j) < 0.5) then - profiles(j)%skin%surftype = surftype_sea - else - profiles(j)%skin%surftype = surftype_land - endif - if (seaice(j) >= 0.5) then - profiles(j)%skin%surftype = surftype_seaice - endif - profiles(j)%skin%fastem(1) = 3.0 - profiles(j)%skin%fastem(2) = 5.0 - profiles(j)%skin%fastem(3) = 15.0 - profiles(j)%skin%fastem(4) = 0.1 - profiles(j)%skin%fastem(5) = 0.3 - profiles(j)%cfraction = 0.0 - profiles(j)%ctp = 500.0 ! not used but still required by rttov - profiles(j)%p(:) = p_in(j,:) - profiles(j)%t(:) = t_in(j,:) - profiles(j)%q(:) = q_in(j,:) - profiles(j)%idg = 0. - profiles(j)%ish = 0. - where(profiles(j)%q(:) < 1e-4) - profiles(j)%q(:) = 1e-4 - end where - cld_profiles(j)%ph(:) = ph_in(j,:) - cld_profiles(j)%cc(:) = cc_in(j,:) - cld_profiles(j)%clw(:) = clw_in(j,:) - cld_profiles(j)%ciw(:) = ciw_in(j,:) - cld_profiles(j)%rain(:) = rain_in(j,:) - cld_profiles(j)%sp(:) = sp_in(j,:) - profiles(j)%s2m%p = cld_profiles(j)%ph(nlevels_in+1) - enddo - - call rttov_get_emis( & - & errorstatus, & - & opts, & - & chanprof, & - & profiles, & - & coef_rttov, & - ! & resolution=resolution, & ! *** MW atlas native resolution is - ! 0.25 degree lat/lon; if you know better value for satellite - ! footprint (larger than this) then you can specify it here - & emissivity=emissivity(:)%emis_in) - if (errorstatus /= errorstatus_success) then - write(*,*) 'In COSP_RTTOV11: Error RTTOV_GET_EMIS!' - call rttov_exit(errorstatus) - endif - - calcemis(:) = .false. - where (emissivity(:)%emis_in <= 0.) - calcemis(:) = .true. - endwhere - - call rttov_scatt (& - & errorstatus, &! out - & opts_scatt, &! in - & nlevels_in, &! in - & chanprof, &! in - & frequencies, &! in - & profiles, &! in - & cld_profiles, &! in - & coef_rttov, &! in - & coef_scatt, &! in - & calcemis, &! in - & emissivity, &! in - & radiance) ! out - - if (errorstatus /= errorstatus_success) then - write(*,*) 'In COSP_RTTOV11: Error RTTOV_SCATT!' - call rttov_exit(errorstatus) - endif +! Current inputs: rttovIN,cospOUT%rttov_tbs(ij:ik,:),cosp_simulator(nError+1) - !write(*,*) 'Checking emissivities: ', maxval(emissivity(:)%emis_out), \ - ! minval(emissivity(:)%emis_out) - tbs(1:prf_num_in,1:1+size(ichan(:,1))-1) = & - transpose(reshape(radiance%bt(1:nchanxnprof),(/ size(ichan(:,1)),prf_num_in/) )) +! JKS new function end + end subroutine rttov_simulate - ! deallocate all storage - asw = 0 - ! call rttov_dealloc_coefs(errorstatus,coef_rttov) - ! call rttov_dealloc_scattcoeffs(coef_scatt) - call rttov_alloc_prof(errorstatus,prf_num_in,profiles,nlevels_in,opts,asw) - call rttov_alloc_scatt_prof(prf_num_in,cld_profiles,nlevels_in,.false.,asw) - call rttov_alloc_rad(errorstatus,nchanxnprof,radiance,nlevels_in-1,asw) - deallocate(ichan,chanprof,frequencies,emissivity,calcemis) !instrument, - !*************************************************************************** - !-------- end section -------- - !*************************************************************************** - end subroutine cosp_rttov_mwscatt function construct_rttov_coeffilename(platform,satellite,instrument) ! Inputs integer,intent(in) :: platform,satellite,instrument From 57d0cc438217165e66df30debcba87cd12d80c57 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 28 Feb 2023 14:05:01 -0700 Subject: [PATCH 017/159] Added option setting and coefficient file loading to cosp_rttov_init. Allocation added to cosp_rttov_simulate --- src/simulator/cosp_rttov_interface_v13.F90 | 348 +++++++++++++++++++-- 1 file changed, 325 insertions(+), 23 deletions(-) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index e249185a25..ef9257da28 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -34,21 +34,85 @@ MODULE MOD_COSP_RTTOV_INTERFACE USE COSP_KINDS, ONLY: wp USE MOD_COSP_CONFIG, ONLY: RTTOV_MAX_CHANNELS,rttovDir use mod_cosp_rttov, only: platform,satellite,sensor,nChannels,iChannel,coef_rttov, & - coef_scatt,opts,opts_scatt,construct_rttov_coeffilename, & + opts,construct_rttov_coeffilename, & construct_rttov_scatfilename +! coef_scatt,opts,opts_scatt,construct_rttov_coeffilename, & + + ! rttov_const contains useful RTTOV constants + USE rttov_const, ONLY : & + errorstatus_success, & + errorstatus_fatal, & + platform_name, & + inst_name + + ! rttov_types contains definitions of all RTTOV data types + USE rttov_types, ONLY : & + rttov_options, & + rttov_coefs, & + rttov_profile, & + rttov_transmission, & + rttov_radiance, & + rttov_chanprof, & + rttov_emissivity, & + rttov_reflectance + + ! jpim, jprb and jplm are the RTTOV integer, real and logical KINDs + USE parkind1, ONLY : jpim, jprb, jplm + + USE rttov_unix_env, ONLY : rttov_exit + IMPLICIT NONE +#include "rttov_direct.interface" +#include "rttov_parallel_direct.interface" #include "rttov_read_coefs.interface" -#include "rttov_read_scattcoeffs.interface" +#include "rttov_dealloc_coefs.interface" +#include "rttov_alloc_direct.interface" +#include "rttov_init_emis_refl.interface" +#include "rttov_user_options_checkinput.interface" +#include "rttov_print_opts.interface" +#include "rttov_print_profile.interface" +#include "rttov_skipcommentline.interface" + + !-------------------------- + ! + INTEGER(KIND=jpim), PARAMETER :: iup = 20 ! unit for input profile file + INTEGER(KIND=jpim), PARAMETER :: ioout = 21 ! unit for output + + ! RTTOV variables/structures + !==================== +! JKS these are already imported from "mod_cosp_rttov" +! TYPE(rttov_options) :: opts ! Options structure +! TYPE(rttov_coefs) :: coefs ! Coefficients structure + + TYPE(rttov_chanprof), POINTER :: chanprof(:) => NULL() ! Input channel/profile list + LOGICAL(KIND=jplm), POINTER :: calcemis(:) => NULL() ! Flag to indicate calculation of emissivity within RTTOV + TYPE(rttov_emissivity), POINTER :: emissivity(:) => NULL() ! Input/output surface emissivity + LOGICAL(KIND=jplm), POINTER :: calcrefl(:) => NULL() ! Flag to indicate calculation of BRDF within RTTOV + TYPE(rttov_reflectance), POINTER :: reflectance(:) => NULL() ! Input/output surface BRDF + TYPE(rttov_profile), POINTER :: profiles(:) => NULL() ! Input profiles + TYPE(rttov_transmission) :: transmission ! Output transmittances + TYPE(rttov_radiance) :: radiance ! Output radiances + + INTEGER(KIND=jpim) :: errorstatus ! Return error status of RTTOV subroutine calls + + INTEGER(KIND=jpim) :: alloc_status + +! Old +!#include "rttov_read_coefs.interface" +!#include "rttov_read_scattcoeffs.interface" ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! TYPE rttov_in ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + ! JKS - add additional COSP inputs here. type rttov_in integer,pointer :: & nPoints, & ! Number of profiles to simulate nLevels, & ! Number of levels nSubCols, & ! Number of subcolumns + nChannels, & ! Number of channels to simulate month ! Month (needed for surface emissivity calculation) real(wp),pointer :: & zenang, & ! Satellite zenith angle @@ -85,23 +149,34 @@ MODULE MOD_COSP_RTTOV_INTERFACE fl_rain, & ! Precipitation flux (startiform+convective rain) (kg/m2/s) fl_snow ! Precipitation flux (stratiform+convective snow) end type rttov_in + CONTAINS !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_init !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN) + SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN,nlevels) integer,intent(in) :: & NchanIN, & ! Number of channels platformIN, & ! Satellite platform satelliteIN, & ! Satellite - instrumentIN ! Instrument + instrumentIN, & ! Instrument + nlevels integer,intent(in),dimension(RTTOV_MAX_CHANNELS) :: & channelsIN ! RTTOV channels ! Local variables - character(len=256) :: coef_file,scat_file - integer :: errorstatus + character(len=256) :: & + coef_file, & + scat_file, & + rttov_coefDir, & + rttov_predDir, & + rttov_cldaerDir, & + OD_coef_filepath, & + aer_coef_file, & + cld_coef_file, & + aer_coef_filepath, & + cld_coef_filepath ! Initialize fields in module memory (cosp_rttovXX.F90) nChannels = NchanIN @@ -110,27 +185,194 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI sensor = instrumentIN iChannel = channelsIN + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 1. Initialise RTTOV options structure + ! ------------------------------------------------------ + ! See page 157 of RTTOV v13 user guide for documentation + ! Initializing all options to defaults for consistency + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + ! General configuration options + opts%config%do_checkinput = .true. + opts%config%apply_reg_limits = .false. ! True in v11 + opts%config%verbose = .true. + opts%config%opdep13_gas_clip = .true. + + ! General Radiative Transfer Options + ! Gas profiles + opts%rt_all%ozone_data = .true. + opts%rt_all%so2_data = .true. + + ! Well-mixed gases + opts%rt_all%co2_data = .true. + opts%rt_all%n2o_data = .true. + opts%rt_all%co_data = .true. + opts%rt_all%ch4_data = .true. + + ! Other general RT options (initializing to defaults for completeness) + opts%rt_all%do_lambertian = .false. + opts%rt_all%switchrad = .false. + opts%rt_all%rad_down_lin_tau = .true. + opts%rt_all%use_t2m_opdep = .true. + opts%rt_all%use_q2m = .true. + opts%rt_all%use_tskin_eff = .false. + opts%rt_all%addrefrac = .true. + opts%rt_all%plane_parallel = .false. + opts%rt_all%transmittances_only = .false. + + ! MW-only radiative transfer options: + ! JKS make this optional? + opts%rt_mw%clw_data = .false. + opts%rt_mw%clw_scheme = 2 ! Default = 2/Rosenkranz + opts%rt_mw%clw_cloud_top = 322 ! Default is 322 hPa + opts%rt_mw%fastem_version = 6 ! Default FASTEM-6 + opts%rt_mw%supply_foam_fraction = .false. + + ! UV/visible/IR-only radiative transfer options + opts%rt_ir%addsolar = .false. + opts%rt_ir%rayleigh_max_wavelength = 2._wp ! 2um + opts%rt_ir%rayleigh_min_pressure = 0._wp ! 0 hPa + opts%rt_ir%rayleigh_single_scatt = .true. + opts%rt_ir%rayleigh_depol = .true. ! Default false, recommended true + opts%rt_ir%do_nlte_correction = .false. + opts%rt_ir%solar_sea_brdf_model = 2 + opts%rt_ir%ir_sea_emis_model = 2 + opts%rt_ir%addaerosl = .false. + opts%rt_ir%addclouds = .false. + opts%rt_ir%user_aer_opt_param = .false. ! User specifies the aerosol scattering optical parameters + opts%rt_ir%user_cld_opt_param = .false. ! User specifies the cloud scattering optical parameters + opts%rt_ir%grid_box_avg_cloud = .true. + opts%rt_ir%cldcol_threshold = -1._wp + opts%rt_ir%cloud_overlap = 1 ! Maximum-random overlap + opts%rt_ir%cc_low_cloud_top = 750_wp ! 750 hPa. Only applies when cloud_overlap=2. + opts%rt_ir%ir_scatt_model = 2 + opts%rt_ir%vis_scatt_model = 1 + opts%rt_ir%dom_nstreams = 8 + opts%rt_ir%dom_accuracy = 0._wp ! only applies when addclouds or addaerosl is true and DOM is selected as a scattering solver. + opts%rt_ir%dom_opdep_threshold = 0._wp + opts%rt_ir%dom_rayleigh = .false. + + ! Principal Components-only radiative transfer options: + opts%rt_ir%pc%addpc = .false. + opts%rt_ir%pc%npcscores = -1 + opts%rt_ir%pc%addradrec = .false. + opts%rt_ir%pc%ipcbnd = 1 + opts%rt_ir%pc%ipcreg = 1 ! The index of the required set of PC predictors + + ! Options related to interpolation and the vertical grid: + opts%interpolation%addinterp = .true. + opts%interpolation%interp_mode = 1 +! opts%interpolation%reg_limit_extrap = .true. ! Depreciated + opts%interpolation%lgradp = .false. +! opts%interpolation%spacetop = .true. ! Depreciated + + ! Options related to HTFRTC: + opts%htfrtc_opts%htfrtc = .false. + opts%htfrtc_opts%n_pc_in = -1 + opts%htfrtc_opts%reconstruct = .false. + opts%htfrtc_opts%simple_cloud = .false. + opts%htfrtc_opts%overcast = .false. + + ! Developer options that may be useful: + opts%dev%do_opdep_calc = .true. + + ! JKS To-do: include opts_scatt settings (user guide pg 161) + + + ! Old configured options ! Options common to RTTOV clear-sky Tb calculation - opts%interpolation%addinterp = .true. ! allow interpolation of input profile - opts%rt_all%use_q2m = .true. - opts%config%do_checkinput = .false. - opts%config%verbose = .false. - opts%rt_all%addrefrac = .true. ! include refraction in path calc - opts%interpolation%reg_limit_extrap = .true. +! opts%interpolation%addinterp = .true. ! allow interpolation of input profile +! opts%rt_all%use_q2m = .true. +! opts%config%do_checkinput = .false. +! opts%config%verbose = .false. +! opts%rt_all%addrefrac = .true. ! include refraction in path calc +! opts%interpolation%reg_limit_extrap = .true. + +! opts%rt_mw%clw_data = .true. ! Options common to RTTOV clear-sky Tb calculation - opts_scatt%config%do_checkinput = .false. - opts_scatt%config%verbose = .false. - opts_scatt%config%apply_reg_limits = .true. - opts_scatt%interp_mode = 1 - opts_scatt%reg_limit_extrap = .true. - opts_scatt%use_q2m = .true. - opts%rt_mw%clw_data = .true. - + + ! These scattering options are depreciated in v13 +! opts_scatt%config%do_checkinput = .false. +! opts_scatt%config%verbose = .false. +! opts_scatt%config%apply_reg_limits = .true. +! opts_scatt%interp_mode = 1 +! opts_scatt%reg_limit_extrap = .true. +! opts_scatt%use_q2m = .true. + + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 2. Read coefficients (from RTTOV example files) + ! ------------------------------------------------------ + ! Using the GUI to figure out files that work together could be helpful here. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + ! Construct optical depth and cloud coefficient files + + ! rttovDir should be "/glade/u/home/jonahshaw/w/RTTOV/" passed from namelist + + ! Hardcoding these other paths for now, they should be input later. + rttov_coefDir = "rtcoef_rttov13/" ! directory for coefficient in RTTOV v13 + rttov_predDir = "rttov13pred54L/" ! example directory for predictors. This should be input + rttov_cldaerDir = "cldaer_visir/" ! This should be input. Also "cldaer_ir". + + ! Optical depth file + OD_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(rttov_predDir)// & + trim(construct_rttov_coeffilename(platform,satellite,sensor)) + + ! Example coefficient files (hardcoded) + aer_coef_file = "scaercoef_eos_2_airs_cams_chou-only.H5" + cld_coef_file = "sccldcoef_eos_2_airs_chou-only.H5" + + ! Coefficient files from the "construct_rttov_scatfilename" function. Not sure if working. +! aer_coef_file = construct_rttov_scatfilename(platform,satellite,sensor) +! cld_coef_file = construct_rttov_scatfilename(platform,satellite,sensor) + + ! Cloud and Aerosol scattering (and absorption?) file(s) + aer_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(rttov_cldaerDir)// & + trim(aer_coef_file) + cld_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(rttov_cldaerDir)// & + trim(cld_coef_file) + + ! Read optical depth and cloud coefficient files together + call rttov_read_coefs(errorstatus, coef_rttov, opts, & + file_coef=OD_coef_filepath, & + file_scaer=aer_coef_filepath, & + file_sccld=cld_coef_filepath) + + if (errorstatus /= errorstatus_success) then + write(*,*) 'fatal error reading coefficients' + call rttov_exit(errorstatus) + endif + + ! Ensure input number of channels is not higher than number stored in coefficient file + if (nchannels > coef_rttov % coef % fmv_chn) then + nchannels = coef_rttov % coef % fmv_chn + endif + + ! Ensure the options and coefficients are consistent + call rttov_user_options_checkinput(errorstatus, opts, coef_rttov) + if (errorstatus /= errorstatus_success) then + write(*,*) 'error in rttov options' + call rttov_exit(errorstatus) + endif + + ! Old code + ! coef_file = trim(rttovDir)//"rtcoef_rttov11/rttov7pred54L/"// & + ! trim(construct_rttov_coeffilename(platform,satellite,sensor)) + + ! Read in scattering (clouds+aerosol) coefficient file. *ONLY NEEDED IF DOING RTTOV ALL-SKY.* + !scat_file = trim(rttovDir)//"rtcoef_rttov11/cldaer/"//& + ! trim(construct_rttov_scatfilename(platform,satellite,sensor)) + ! Can't pass filename to rttov_read_scattcoeffs!!!!! + !call rttov_read_scattcoeffs (errorstatus, coef_rttov%coef, coef_scatt,) + +!!!! Old version + ! Read in scattering coefficient file. - coef_file = trim(rttovDir)//"rtcoef_rttov11/rttov7pred54L/"// & - trim(construct_rttov_coeffilename(platform,satellite,sensor)) - call rttov_read_coefs(errorstatus,coef_rttov, opts, file_coef=trim(coef_file)) +! coef_file = trim(rttovDir)//"rtcoef_rttov11/rttov7pred54L/"// & +! trim(construct_rttov_coeffilename(platform,satellite,sensor)) +! call rttov_read_coefs(errorstatus,coef_rttov, opts, file_coef=trim(coef_file)) ! Read in scattering (clouds+aerosol) coefficient file. *ONLY NEEDED IF DOING RTTOV ALL-SKY.* !scat_file = trim(rttovDir)//"rtcoef_rttov11/cldaer/"//& @@ -139,6 +381,66 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI !call rttov_read_scattcoeffs (errorstatus, coef_rttov%coef, coef_scatt,) END SUBROUTINE COSP_RTTOV_INIT + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE cosp_rttov_simulate + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN, & ! Inputs + Tb,error) ! Outputs + + type(rttov_in),intent(in) :: & + rttovIN + real(wp),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! + Tb ! RTTOV brightness temperature. + character(len=128) :: & + error ! Error messages (only populated if error encountered) + + integer(kind=jpim) :: nchanprof ! JKS - jpim is RTTOV integer type + + integer :: errorstatus + ! How do I want the interface to function? How should it to be consistent with the rest of COSP? + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 3. Allocate RTTOV input and output structures + ! ------------------------------------------------------ + ! Largely from RTTOV documentation. + ! This only needs to be performed once if all chunks are the same size, right? <-- We don't know chunk sizes at init, so this must be in the main loop. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + ! Determine the total number of radiances to simulate (nchanprof). + ! We aren't doing subcolumn sampling (RTTOV already does this and it would be slow) +! nchanprof = nchannels * nprof + nchanprof = rttovIN%nChannels * rttovIN%nPoints + + ! Allocate structures for rttov_direct + CALL rttov_alloc_direct( & + errorstatus, & + 1_jpim, & ! 1 => allocate +! nprof, & + rttovIN%nPoints, & + nchanprof, & +! nlevels, & + rttovIN%nLevels, & + chanprof, & + opts, & + profiles, & + coef_rttov, & +! coefs, & + transmission, & + radiance, & + calcemis=calcemis, & + emissivity=emissivity, & + calcrefl=calcrefl, & + reflectance=reflectance, & + init=.TRUE._jplm) + IF (errorstatus /= errorstatus_success) THEN + WRITE(*,*) 'allocation error for rttov_direct structures' + CALL rttov_exit(errorstatus) + ENDIF + + + END SUBROUTINE COSP_RTTOV_SIMULATE + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! END MODULE ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From e34833e642069374b46a9459f22e6fcd8b5864e7 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 28 Feb 2023 14:07:01 -0700 Subject: [PATCH 018/159] Call cosp_rttov_simulate from cosp.F90. Call goes through cosp_rttov_interface_v13 --- driver/src/cosp2_test.F90 | 2 +- src/cosp.F90 | 45 +++++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 1f578e8488..0b77b3b151 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -999,7 +999,7 @@ subroutine construct_cospIN(npoints,ncolumns,nlevels,y) endif ! JKS add RTTOV arguments when constructing the cospIN object if (Lrttov) then - y%NchanIN_rttov = rttov_Nchannels + y%nChannels_rttov = rttov_Nchannels y%platformIN_rttov = rttov_platform y%satelliteIN_rttov = rttov_satellite y%instrumentIN_rttov = rttov_Instrument diff --git a/src/cosp.F90 b/src/cosp.F90 index 5ce04701b9..cc47ef8560 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -52,7 +52,7 @@ MODULE MOD_COSP cloudsat_preclvl,grLidar532_histBsct,atlid_histBsct,& RTTOV_MAX_CHANNELS ! JKS needed for RTTOV to be in cosp_optical_inputs USE MOD_COSP_MODIS_INTERFACE, ONLY: cosp_modis_init, modis_IN - USE MOD_COSP_RTTOV_INTERFACE, ONLY: cosp_rttov_init, rttov_IN + USE MOD_COSP_RTTOV_INTERFACE, ONLY: cosp_rttov_init, cosp_rttov_simulate, rttov_IN USE MOD_COSP_MISR_INTERFACE, ONLY: cosp_misr_init, misr_IN USE MOD_COSP_ISCCP_INTERFACE, ONLY: cosp_isccp_init, isccp_IN USE MOD_COSP_CALIPSO_INTERFACE, ONLY: cosp_calipso_init, calipso_IN @@ -68,7 +68,7 @@ MODULE MOD_COSP USE MOD_PARASOL, ONLY: parasol_subcolumn, parasol_column USE MOD_COSP_STATS, ONLY: COSP_LIDAR_ONLY_CLOUD,COSP_CHANGE_VERTICAL_GRID, & COSP_DIAG_WARMRAIN - use mod_cosp_rttov, ONLY: rttov_simulate ! JKS new function +! use mod_cosp_rttov, ONLY: rttov_simulate ! JKS new function ! use mod_cosp_rttov, ONLY: rttov_column,rttov_simulate ! JKS new function IMPLICIT NONE @@ -137,7 +137,7 @@ MODULE MOD_COSP Npart, & ! Number of cloud meteors for LIDAR simulators. Nrefl, & ! Number of reflectances for PARASOL simulator ! RTTOV inputs JKS - NchanIN_rttov, & ! Number of RTTOV channels + nChannels_rttov, & ! Number of RTTOV channels platformIN_rttov, & ! RTTOV platform integer satelliteIN_rttov, & ! RTTOV satellite integer instrumentIN_rttov ! RTTOV instrument integer @@ -741,6 +741,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) rttovIN%nPoints => Npoints rttovIN%nLevels => cospIN%nLevels rttovIN%nSubCols => cospIN%nColumns + rttovIN%nChannels => cospIN%nChannels_rttov rttovIN%zenang => cospgridIN%zenang rttovIN%co2 => cospgridIN%co2 rttovIN%ch4 => cospgridIN%ch4 @@ -1530,6 +1531,9 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! RTTOV if (lrttov_column) then + ! JKS new RTTOV subroutine for v13 called from the RTTOV interface. + call cosp_rttov_simulate(rttovIN,cospOUT%rttov_tbs(ij:ik,:),cosp_simulator(nError+1)) + ! JKS building new call ! call rttov_column(rttovIN%nPoints,rttovIN%nLevels,rttovIN%nSubCols,rttovIN%q, & ! rttovIN%p,rttovIN%t,rttovIN%o3,rttovIN%ph,rttovIN%h_surf, & @@ -1544,25 +1548,20 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! ! rttovIN%month, rttovIN%tca,rttovIN%cldIce,rttovIN%cldLiq, & ! ! rttovIN%fl_rain,rttovIN%fl_snow) - ! JKS new RTTOV subroutine for v13 - !call rttov_simulate(rttovIN,cospOUT%rttov_tbs(ij:ik,:),cosp_simulator(nError+1)) !,& - - call rttov_simulate(rttovIN%nPoints,rttovIN%nLevels,rttovIN%nSubCols,rttovIN%q, & - rttovIN%p,rttovIN%t,rttovIN%o3,rttovIN%ph,rttovIN%h_surf, & - rttovIN%u_surf,rttovIN%v_surf,rttovIN%p_surf,rttovIN%t_skin, & - rttovIN%t2m,rttovIN%q2m,rttovIN%lsmask,rttovIN%longitude, & - rttovIN%latitude,rttovIN%seaice,rttovIN%co2,rttovIN%ch4, & - rttovIN%n2o,rttovIN%co,rttovIN%zenang,lrttov_cleanUp, & -! Previously optional emissivity arguments - rttovIN%surfem,rttovIN%month, & -! Previously optional cloud arguments - rttovIN%tca,rttovIN%cldIce,rttovIN%cldLiq, & - rttovIN%fl_rain,rttovIN%fl_snow, & -! Outputs - cospOUT%rttov_tbs(ij:ik,:),cosp_simulator(nError+1)) - -! month=rttovIN%month) - +! call rttov_simulate(rttovIN%nPoints,rttovIN%nLevels,rttovIN%nSubCols,rttovIN%q, & +! rttovIN%p,rttovIN%t,rttovIN%o3,rttovIN%ph,rttovIN%h_surf, & +! rttovIN%u_surf,rttovIN%v_surf,rttovIN%p_surf,rttovIN%t_skin, & +! rttovIN%t2m,rttovIN%q2m,rttovIN%lsmask,rttovIN%longitude, & +! rttovIN%latitude,rttovIN%seaice,rttovIN%co2,rttovIN%ch4, & +! rttovIN%n2o,rttovIN%co,rttovIN%zenang,lrttov_cleanUp, & +!! Previously optional emissivity arguments +! rttovIN%surfem,rttovIN%month, & +!! Previously optional cloud arguments +! rttovIN%tca,rttovIN%cldIce,rttovIN%cldLiq, & +! rttovIN%fl_rain,rttovIN%fl_snow, & +!! Outputs +! cospOUT%rttov_tbs(ij:ik,:),cosp_simulator(nError+1)) + endif !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1857,7 +1856,7 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La if (Lisccp) call cosp_isccp_init(isccp_top_height,isccp_top_height_direction) if (Lmodis) call cosp_modis_init() if (Lmisr) call cosp_misr_init() - if (Lrttov) call cosp_rttov_init(NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN) ! JKS arguments must be available + if (Lrttov) call cosp_rttov_init(NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN,Nlevels) ! JKS arguments must be available ! if (Lrttov) call cosp_rttov_init() ! JKS arguments must be available if (Lcloudsat) call cosp_cloudsat_init(cloudsat_radar_freq,cloudsat_k2, & From 7911cda9714027b6ecc6621851b018220f06f257 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 28 Feb 2023 17:06:00 -0700 Subject: [PATCH 019/159] Begin reading COSP inputs to RTTOV columns in cosp_rttov_interface_v13. --- src/cosp.F90 | 4 +- src/simulator/cosp_rttov_interface_v13.F90 | 184 +++++++++++++++++++-- 2 files changed, 175 insertions(+), 13 deletions(-) diff --git a/src/cosp.F90 b/src/cosp.F90 index cc47ef8560..80f0211a5a 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -769,8 +769,8 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) rttovIN%tca => cospgridIN%tca rttovIN%cldIce => cospgridIN%cloudIce rttovIN%cldLiq => cospgridIN%cloudLiq - rttovIN%fl_rain => cospgridIN%fl_rain - rttovIN%fl_snow => cospgridIN%fl_snow + rttovIN%fl_rain => cospgridIN%fl_rain ! JKS remove? + rttovIN%fl_snow => cospgridIN%fl_snow ! JKS remove? endif !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index ef9257da28..1b2c8f5186 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -43,8 +43,10 @@ MODULE MOD_COSP_RTTOV_INTERFACE errorstatus_success, & errorstatus_fatal, & platform_name, & - inst_name - + inst_name, & + surftype_sea, & + surftype_land, & + surftype_seaice ! rttov_types contains definitions of all RTTOV data types USE rttov_types, ONLY : & rttov_options, & @@ -383,7 +385,7 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI END SUBROUTINE COSP_RTTOV_INIT !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE cosp_rttov_simulate + ! SUBROUTINE cosp_rttov_simulate - JKS should this move to cosp_rttov_v13? !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN, & ! Inputs Tb,error) ! Outputs @@ -391,11 +393,28 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN, & ! Inputs type(rttov_in),intent(in) :: & rttovIN real(wp),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! - Tb ! RTTOV brightness temperature. + Tb ! RTTOV brightness temperature. character(len=128) :: & - error ! Error messages (only populated if error encountered) - + error ! Error messages (only populated if error encountered) + + ! Internal variables. Trace gas columns in units of (kg/kg) + real(wp),dimension(rttovIN%nLevels) :: & ! wp or jprb? + co2_column, & + ch4_column, & + n2o_column, & + co_column +! array ( : , : , : ) = 0.0d0 + + ! variables for input + !==================== + integer(kind=jpim) :: nthreads + integer(kind=jpim) :: dosolar integer(kind=jpim) :: nchanprof ! JKS - jpim is RTTOV integer type + integer(kind=jpim), allocatable :: channel_list(:) + + ! Loop variables + integer(kind=jpim) :: i, j, jch + integer(kind=jpim) :: nch integer :: errorstatus ! How do I want the interface to function? How should it to be consistent with the rest of COSP? @@ -413,7 +432,7 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN, & ! Inputs nchanprof = rttovIN%nChannels * rttovIN%nPoints ! Allocate structures for rttov_direct - CALL rttov_alloc_direct( & + call rttov_alloc_direct( & errorstatus, & 1_jpim, & ! 1 => allocate ! nprof, & @@ -433,12 +452,155 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN, & ! Inputs calcrefl=calcrefl, & reflectance=reflectance, & init=.TRUE._jplm) - IF (errorstatus /= errorstatus_success) THEN - WRITE(*,*) 'allocation error for rttov_direct structures' - CALL rttov_exit(errorstatus) - ENDIF + if (errorstatus /= errorstatus_success) then + write(*,*) 'allocation error for rttov_direct structures' + call rttov_exit(errorstatus) + endif + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 4. Build the list of profile/channel indices in chanprof + ! ------------------------------------------------------ + ! Largely from RTTOV documentation. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + nch = 0_jpim + do j = 1, rttovIN%nPoints + do jch = 1, rttovIN%nChannels + nch = nch + 1_jpim + chanprof(nch)%prof = j + chanprof(nch)%chan = channel_list(jch) + end do + end do + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 5. Read profile data + ! ------------------------------------------------------ + ! Largely from cosp_rttov_v11.F90 file. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + ! Create a new subroutine in cosp_rttov_v13 and call it to return the profiles + + !call rttov_profile_setup(rttovIN,profiles) + + ! Store profile data from rttovIN in profile type. + ! See RTTOV user guide pg 163 for description of "profiles" type + +! "The rttov_profile structure is composed of the atmospheric part +! and two other structures for 2 meter air and skin surface. +! If you are not able to provide ozone, CO2, etc profiles the flags +! ozone_data, co2_data and so on in the options structure should be +! set to false." + + ! Want to set these up as arrays of size (nLevels,nPoints) with + ! constant values. Not sure how to do it efficiently. i.e. no loops + + ! Set-up trace gas columns do implied do statements (not working) +! co2_column = (rttovIN%co2, i=1,rttovIN%nLevels) +! ch4_column = (rttovIN%ch4, i=1,rttovIN%nLevels) +! n2o_column = (rttovIN%n2o, i=1,rttovIN%nLevels) +! co_column = (rttovIN%co, i=1,rttovIN%nLevels) + + ! Trace gas concentrations (constant in input, go outside loop) + ! This won't work because the columns should be 2D. +! profiles(:)%co2 = co2_column +! profiles(:)%n2o = n2o_column +! profiles(:)%co = co_column +! profiles(:)%ch4 = ch4_column + + profiles%gas_units = 1 ! kg/kg over moist air (default) + profiles%mmr_cldaer = .true. ! kg/kg for cloud and aerosol (default) + + profiles%clw_scheme = 2. ! Deff scheme avoids cloud types +! profiles%clwde_scheme = 1. ! Not implemented? + profiles%ice_scheme = 1. ! Baum or Baran + profiles%icede_param = 2. ! Wyser + + do i = 1, rttovIN%nPoints + profiles(i)%p(:) = rttovIN%p(i, :) + profiles(i)%t(:) = rttovIN%t(i, :) + profiles(i)%q(:) = rttovIN%q(i, :) + + ! JKS not sure if I should keep this + where(profiles(i)%q(:) < 1e-4) + profiles(i)%q(:) = 1e-4 + end where + + ! Old code for simple cloud schemes only +! profiles(i)%cfraction = 0. +! profiles(i)%ctp = 500. + + ! Add handling of more complex cloud schemes + + ! Gas profiles + profiles(i)%o3 = rttovIN%o3(i, :) +! profiles(i)%so2 = ? + + ! Other stuff implementation not clear +! profiles(i)%clw = ! Cloud liquid water (kg/kg) – MW only, +! profiles(i)%aerosols(naertyp,nlayers) = ! Aerosols in different modes + + ! Cloud scheme stuff + profiles(i)%cloud(1,:) = rttovIN%cldLiq ! Cloud water mixing ratio (all in the first type for Deff) + profiles(i)%cloud(6,:) = rttovIN%cldIce ! Cloud ice mixing ratio (1 type). See pg 74. + +! profiles(i)%cloud(ncldtyp,nlayers) = ! Cloud types +! profiles(i)%cfrac = ! Cloud fraction for each layer +! profiles(i)%clwde = ! Cloud water effective diameter +! profiles(i)%icede = ! Cloud ice effective diameter + + + + ! 2m parameters + profiles(i)%s2m%p = rttovIN%p_surf(i) + profiles(i)%s2m%t = rttovIN%t2m(i) ! JKS or rttovIN%t_skin + profiles(i)%s2m%q = rttovIN%q2m(i) ! Should be the same as gas units (kg/kg) + profiles(i)%s2m%u = rttovIN%u_surf(i) + profiles(i)%s2m%v = rttovIN%v_surf(i) + profiles(i)%s2m%wfetc = 10000. ! only used by sea surface solar BRDF model. + + ! skin variables for emissivity calculations + profiles(i)%skin%t = rttovIN%t_skin(i) + + ! fastem coefficients - for mw calculations + profiles(i)%skin%fastem(1) = 3.0 + profiles(i)%skin%fastem(2) = 5.0 + profiles(i)%skin%fastem(3) = 15.0 + profiles(i)%skin%fastem(4) = 0.1 + profiles(i)%skin%fastem(5) = 0.3 + + ! Viewing angles + profiles(i)%zenangle = rttovIN%zenang ! pass in from cosp + profiles(i)%azangle = 0. ! hard-coded in rttov9 int JKS-? + + profiles(i)%latitude = rttovIN%latitude(i) + profiles(i)%longitude = rttovIN%longitude(i) + profiles(i)%elevation = rttovIN%h_surf(i) + + ! Solar angles. JKS - get this from COSP? Doesn't seem to be passed in. + profiles(i)%sunzenangle = 0. ! hard-coded in rttov9 int + profiles(i)%sunazangle = 0. ! hard-coded in rttov9 int + + ! surface type + ! land-sea mask (lsmask) indicates proportion of land in grid + if (rttovIN%lsmask(i) < 0.5) then + profiles(i)%skin%surftype = surftype_sea + else + profiles(i)%skin%surftype = surftype_land + endif + ! sea-ice fraction + if (rttovIN%seaice(i) >= 0.5) then + profiles(i)%skin%surftype = surftype_seaice + endif + + ! dar: hard-coded to 1 (=ocean water) in rttov 9 int + profiles(i)%skin%watertype = 1 + !profiles(i) %idg = 0. ! Depreciated? + !profiles(i) %ish = 0. ! Depreciated? + end do + + + ! JKS To-do: set up scattering profiles (MW only) (rttov_profile_cloud) + END SUBROUTINE COSP_RTTOV_SIMULATE ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From 9bdb8e1258860d83074d12fa005996981d31ca2d Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 1 Mar 2023 16:15:16 -0700 Subject: [PATCH 020/159] Corrected tca variable description --- src/cosp.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cosp.F90 b/src/cosp.F90 index 80f0211a5a..a138f78241 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -119,7 +119,7 @@ MODULE MOD_COSP lon ! Longitude (deg) real(wp),allocatable,dimension(:,:) :: & o3, & ! Ozone (kg/kg) - tca, & ! Total column cloud fraction (0-1) + tca, & ! Total layer cloud fraction (0-1) cloudIce, & ! Cloud ice water mixing ratio (kg/kg) cloudLiq, & ! Cloud liquid water mixing ratio (kg/kg) fl_rain, & ! Precipitation (rain) flux (kg/m2/s) From 845920e8ec4b0c10d0952955507120ed147030d8 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 1 Mar 2023 16:18:57 -0700 Subject: [PATCH 021/159] Keep STUB files functioning. --- src/simulator/cosp_rttov_interfaceSTUB.F90 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/simulator/cosp_rttov_interfaceSTUB.F90 b/src/simulator/cosp_rttov_interfaceSTUB.F90 index 77e4a89606..ff27dde3c6 100644 --- a/src/simulator/cosp_rttov_interfaceSTUB.F90 +++ b/src/simulator/cosp_rttov_interfaceSTUB.F90 @@ -84,12 +84,13 @@ MODULE MOD_COSP_RTTOV_INTERFACE !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_init !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN) + SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN,nlevels) integer,intent(in) :: & - NchanIN, & ! Number of channels - platformIN, & ! Satellite platform - satelliteIN, & ! Satellite - instrumentIN ! Instrument + NchanIN, & ! Number of channels + platformIN, & ! Satellite platform + satelliteIN, & ! Satellite + instrumentIN, & ! Instrument + nlevels integer,intent(in),dimension(RTTOV_MAX_CHANNELS) :: & channelsIN ! RTTOV channels END SUBROUTINE COSP_RTTOV_INIT From 1b84171a896013fb0f5f33f8f86587951aa96384 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Fri, 3 Mar 2023 16:24:20 -0700 Subject: [PATCH 022/159] All steps of running RTTOV are in a single function "simulate_rttov" in the rttov_interface file. --- src/simulator/cosp_rttov_interface_v13.F90 | 464 ++++++++++++++------- 1 file changed, 323 insertions(+), 141 deletions(-) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 1b2c8f5186..9837ade5e4 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -98,7 +98,9 @@ MODULE MOD_COSP_RTTOV_INTERFACE INTEGER(KIND=jpim) :: errorstatus ! Return error status of RTTOV subroutine calls - INTEGER(KIND=jpim) :: alloc_status + INTEGER(KIND=jpim) :: alloc_status(60) +! integer :: alloc_status_cosp(60) + ! Old !#include "rttov_read_coefs.interface" @@ -387,36 +389,46 @@ END SUBROUTINE COSP_RTTOV_INIT !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_simulate - JKS should this move to cosp_rttov_v13? !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN, & ! Inputs + SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN, & ! Inputs Tb,error) ! Outputs - type(rttov_in),intent(in) :: & - rttovIN - real(wp),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! - Tb ! RTTOV brightness temperature. - character(len=128) :: & - error ! Error messages (only populated if error encountered) - - ! Internal variables. Trace gas columns in units of (kg/kg) - real(wp),dimension(rttovIN%nLevels) :: & ! wp or jprb? - co2_column, & - ch4_column, & - n2o_column, & - co_column -! array ( : , : , : ) = 0.0d0 - - ! variables for input - !==================== - integer(kind=jpim) :: nthreads - integer(kind=jpim) :: dosolar - integer(kind=jpim) :: nchanprof ! JKS - jpim is RTTOV integer type - integer(kind=jpim), allocatable :: channel_list(:) + type(rttov_in),intent(in) :: & + rttovIN + real(wp),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! + Tb ! RTTOV brightness temperature. + character(len=128) :: & + error ! Error messages (only populated if error encountered) + + ! Internal variables. Trace gas columns in units of (kg/kg) + real(wp),dimension(rttovIN%nLevels) :: & ! wp or jprb? + co2_column, & + ch4_column, & + n2o_column, & + co_column + logical :: & + rttov_simulate_cld, & + rttov_simulate_aer + + + ! variables for input + !==================== + integer(kind=jpim) :: nthreads + integer(kind=jpim) :: dosolar + integer(kind=jpim) :: nchanprof ! JKS - jpim is RTTOV integer type + integer(kind=jpim), allocatable :: channel_list(:) ! JKS this needs to be specified - ! Loop variables - integer(kind=jpim) :: i, j, jch - integer(kind=jpim) :: nch + ! Loop variables + integer(kind=jpim) :: i, j, jch + integer(kind=jpim) :: nch + + integer :: errorstatus + integer :: ich, ich_temp, chan - integer :: errorstatus + + ! Initialize some things + Tb(:,:) = 0._wp + error = '' + ! How do I want the interface to function? How should it to be consistent with the rest of COSP? ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -429,48 +441,47 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN, & ! Inputs ! Determine the total number of radiances to simulate (nchanprof). ! We aren't doing subcolumn sampling (RTTOV already does this and it would be slow) ! nchanprof = nchannels * nprof - nchanprof = rttovIN%nChannels * rttovIN%nPoints - - ! Allocate structures for rttov_direct - call rttov_alloc_direct( & - errorstatus, & - 1_jpim, & ! 1 => allocate -! nprof, & - rttovIN%nPoints, & - nchanprof, & -! nlevels, & - rttovIN%nLevels, & - chanprof, & - opts, & - profiles, & - coef_rttov, & -! coefs, & - transmission, & - radiance, & - calcemis=calcemis, & - emissivity=emissivity, & - calcrefl=calcrefl, & - reflectance=reflectance, & - init=.TRUE._jplm) - if (errorstatus /= errorstatus_success) then - write(*,*) 'allocation error for rttov_direct structures' - call rttov_exit(errorstatus) - endif + nchanprof = rttovIN%nChannels * rttovIN%nPoints + + ! Allocate structures for rttov_direct + call rttov_alloc_direct( & + errorstatus, & + 1_jpim, & ! 1 => allocate +! nprof, & + rttovIN%nPoints, & + nchanprof, & +! nlevels, & + rttovIN%nLevels, & + chanprof, & + opts, & + profiles, & + coef_rttov, & +! coefs, & + transmission, & + radiance, & + calcemis=calcemis, & + emissivity=emissivity, & + calcrefl=calcrefl, & + reflectance=reflectance, & + init=.TRUE._jplm) + call rttov_error('allocation error for rttov_direct structures' , lalloc = .true.) ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 4. Build the list of profile/channel indices in chanprof ! ------------------------------------------------------ ! Largely from RTTOV documentation. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + ! COSP v11 code has an example for multiple instruments - nch = 0_jpim - do j = 1, rttovIN%nPoints - do jch = 1, rttovIN%nChannels - nch = nch + 1_jpim - chanprof(nch)%prof = j - chanprof(nch)%chan = channel_list(jch) - end do + nch = 0_jpim + do j = 1, rttovIN%nPoints + do jch = 1, rttovIN%nChannels + nch = nch + 1_jpim + chanprof(nch)%prof = j + chanprof(nch)%chan = channel_list(jch) end do + end do ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 5. Read profile data @@ -508,98 +519,269 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN, & ! Inputs ! profiles(:)%ch4 = ch4_column profiles%gas_units = 1 ! kg/kg over moist air (default) - profiles%mmr_cldaer = .true. ! kg/kg for cloud and aerosol (default) - - profiles%clw_scheme = 2. ! Deff scheme avoids cloud types -! profiles%clwde_scheme = 1. ! Not implemented? - profiles%ice_scheme = 1. ! Baum or Baran - profiles%icede_param = 2. ! Wyser do i = 1, rttovIN%nPoints - profiles(i)%p(:) = rttovIN%p(i, :) - profiles(i)%t(:) = rttovIN%t(i, :) - profiles(i)%q(:) = rttovIN%q(i, :) + profiles(i)%p(:) = rttovIN%p(i, :) + profiles(i)%t(:) = rttovIN%t(i, :) + profiles(i)%q(:) = rttovIN%q(i, :) - ! JKS not sure if I should keep this - where(profiles(i)%q(:) < 1e-4) - profiles(i)%q(:) = 1e-4 - end where + ! JKS not sure if I should keep this + where(profiles(i)%q(:) < 1e-4) + profiles(i)%q(:) = 1e-4 + end where - ! Old code for simple cloud schemes only -! profiles(i)%cfraction = 0. -! profiles(i)%ctp = 500. ! Add handling of more complex cloud schemes - ! Gas profiles - profiles(i)%o3 = rttovIN%o3(i, :) -! profiles(i)%so2 = ? + ! Gas profiles + profiles(i)%o3 = rttovIN%o3(i, :) +! profiles(i)%so2 = ! Sulfate not in COSP input files - ! Other stuff implementation not clear -! profiles(i)%clw = ! Cloud liquid water (kg/kg) – MW only, -! profiles(i)%aerosols(naertyp,nlayers) = ! Aerosols in different modes - - ! Cloud scheme stuff - profiles(i)%cloud(1,:) = rttovIN%cldLiq ! Cloud water mixing ratio (all in the first type for Deff) - profiles(i)%cloud(6,:) = rttovIN%cldIce ! Cloud ice mixing ratio (1 type). See pg 74. - -! profiles(i)%cloud(ncldtyp,nlayers) = ! Cloud types -! profiles(i)%cfrac = ! Cloud fraction for each layer -! profiles(i)%clwde = ! Cloud water effective diameter -! profiles(i)%icede = ! Cloud ice effective diameter - - - - ! 2m parameters - profiles(i)%s2m%p = rttovIN%p_surf(i) - profiles(i)%s2m%t = rttovIN%t2m(i) ! JKS or rttovIN%t_skin - profiles(i)%s2m%q = rttovIN%q2m(i) ! Should be the same as gas units (kg/kg) - profiles(i)%s2m%u = rttovIN%u_surf(i) - profiles(i)%s2m%v = rttovIN%v_surf(i) - profiles(i)%s2m%wfetc = 10000. ! only used by sea surface solar BRDF model. - - ! skin variables for emissivity calculations - profiles(i)%skin%t = rttovIN%t_skin(i) - - ! fastem coefficients - for mw calculations - profiles(i)%skin%fastem(1) = 3.0 - profiles(i)%skin%fastem(2) = 5.0 - profiles(i)%skin%fastem(3) = 15.0 - profiles(i)%skin%fastem(4) = 0.1 - profiles(i)%skin%fastem(5) = 0.3 - - ! Viewing angles - profiles(i)%zenangle = rttovIN%zenang ! pass in from cosp - profiles(i)%azangle = 0. ! hard-coded in rttov9 int JKS-? - - profiles(i)%latitude = rttovIN%latitude(i) - profiles(i)%longitude = rttovIN%longitude(i) - profiles(i)%elevation = rttovIN%h_surf(i) - - ! Solar angles. JKS - get this from COSP? Doesn't seem to be passed in. - profiles(i)%sunzenangle = 0. ! hard-coded in rttov9 int - profiles(i)%sunazangle = 0. ! hard-coded in rttov9 int - - ! surface type - ! land-sea mask (lsmask) indicates proportion of land in grid - if (rttovIN%lsmask(i) < 0.5) then - profiles(i)%skin%surftype = surftype_sea - else - profiles(i)%skin%surftype = surftype_land - endif - ! sea-ice fraction - if (rttovIN%seaice(i) >= 0.5) then - profiles(i)%skin%surftype = surftype_seaice - endif - - ! dar: hard-coded to 1 (=ocean water) in rttov 9 int - profiles(i)%skin%watertype = 1 - !profiles(i) %idg = 0. ! Depreciated? - !profiles(i) %ish = 0. ! Depreciated? + +! profiles(i)%aerosols(naertyp,nlayers) = ! Aerosols in different modes (see User Guide pg 80) + + + + ! 2m parameters + profiles(i)%s2m%p = rttovIN%p_surf(i) + profiles(i)%s2m%t = rttovIN%t2m(i) ! JKS or rttovIN%t_skin + profiles(i)%s2m%q = rttovIN%q2m(i) ! Should be the same as gas units (kg/kg) + profiles(i)%s2m%u = rttovIN%u_surf(i) + profiles(i)%s2m%v = rttovIN%v_surf(i) + profiles(i)%s2m%wfetc = 10000. ! only used by sea surface solar BRDF model. + + ! skin variables for emissivity calculations + profiles(i)%skin%t = rttovIN%t_skin(i) + + ! fastem coefficients - for mw calculations + profiles(i)%skin%fastem(1) = 3.0 + profiles(i)%skin%fastem(2) = 5.0 + profiles(i)%skin%fastem(3) = 15.0 + profiles(i)%skin%fastem(4) = 0.1 + profiles(i)%skin%fastem(5) = 0.3 + + ! Viewing angles + profiles(i)%zenangle = rttovIN%zenang ! pass in from cosp + profiles(i)%azangle = 0. ! hard-coded in rttov9 int JKS-? + + profiles(i)%latitude = rttovIN%latitude(i) + profiles(i)%longitude = rttovIN%longitude(i) + profiles(i)%elevation = rttovIN%h_surf(i) + + ! Solar angles. JKS - get this from COSP? Doesn't seem to be passed in. + profiles(i)%sunzenangle = 0. ! hard-coded in rttov9 int + profiles(i)%sunazangle = 0. ! hard-coded in rttov9 int + + ! surface type + ! land-sea mask (lsmask) indicates proportion of land in grid + if (rttovIN%lsmask(i) < 0.5) then + profiles(i)%skin%surftype = surftype_sea + else + profiles(i)%skin%surftype = surftype_land + endif + ! sea-ice fraction + if (rttovIN%seaice(i) >= 0.5) then + profiles(i)%skin%surftype = surftype_seaice + endif + + ! dar: hard-coded to 1 (=ocean water) in rttov 9 int + profiles(i)%skin%watertype = 1 + !profiles(i) %idg = 0. ! Depreciated? + !profiles(i) %ish = 0. ! Depreciated? end do + call rttov_error('error in profile initialization' , lalloc = .true.) + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Only add the cloud fields if simulating cloud. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + rttov_simulate_cld = .false. + if (rttov_simulate_cld) then + + ! Set cloud mass mixing ratio units + profiles%mmr_cldaer = .true. ! kg/kg for cloud and aerosol (default) + + profiles%clw_scheme = 2. ! Deff scheme avoids cloud types + ! profiles%clwde_scheme = 1. ! Not implemented? + profiles%ice_scheme = 1. !1:Baum 2:Baran(2014) 3:Baran(2018) + profiles%icede_param = 2. ! 2:Wyser(recommended). Only used if ice effective diameter not input + + do i = 1, rttovIN%nPoints + ! Cloud scheme stuff + profiles(i)%cfrac(:) = rttovIN%tca(i,:) ! Cloud fraction for each layer + profiles(i)%cloud(1,:) = rttovIN%cldLiq(i,:) ! Cloud water mixing ratio (all in the first type for Deff) + profiles(i)%cloud(6,:) = rttovIN%cldIce(i,:) ! Cloud ice mixing ratio (1 type). See pg 74. + + ! Example UKMO input has effective radii for multiple cloud types, making identification of a single + ! liquid droplet or ice crystal effective diameter difficult. + ! I opt to let RTTOV decide on the effective radius values, but more complex implementation + ! could do a more thorough conversion between UKMO output and RTTOV input + ! profiles(i)%clwde = ! Cloud water effective diameter + ! profiles(i)%icede = ! Cloud ice effective diameter + + ! Old code for simple cloud schemes only + ! profiles(i)%cfraction = 0. + ! profiles(i)%ctp = 500. + + ! Other options not implemented +! profiles(i)%clw = ! Cloud liquid water (kg/kg) – MW only, + end do + endif + call rttov_error('error in cloud profile initialization' , lalloc = .true.) + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Only add the aerosol fields if simulating aerosol. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + rttov_simulate_aer = .false. + if (rttov_simulate_aer) then + + ! Set aerosol mass mixing ratio units + profiles%mmr_cldaer = .true. ! kg/kg for cloud and aerosol (default) + + ! Read in aerosol profiles +! do i = 1, rttovIN%nPoints +! +! end do + endif + call rttov_error('error in aerosol profile initialization' , lalloc = .true.) + ! JKS To-do: set up scattering profiles (MW only) (rttov_profile_cloud) + + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 6. Specify surface emissivity and reflectance + ! ------------------------------------------------------ + ! From RTTOV example files. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + ! In this example we have no values for input emissivities or reflectances + ! so we initialise all inputs to zero + call rttov_init_emis_refl(emissivity, reflectance) + call rttov_error('error for emissivity/reflectance initialization' , lalloc = .true.) + + ! Calculate emissivity within RTTOV where the input emissivity value is + ! zero or less (all channels in this case) + calcemis(:) = (emissivity(:) % emis_in <= 0._jprb) + + ! Calculate reflectances within RTTOV where the input BRDF value is zero or + ! less (all channels in this case) + calcrefl(:) = (reflectance(:) % refl_in <= 0._jprb) + + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 7. Call RTTOV forward model (Woohoo!) + ! ------------------------------------------------------ + ! From RTTOV example files. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + nthreads = 1 ! Default not parallel for now. Can be optimized later. - JKS + + if (nthreads <= 1) then + call rttov_direct( & + errorstatus, &! out error flag + chanprof, &! in channel and profile index structure + opts, &! in options structure + profiles, &! in profile array + coef_rttov, &! in coefficients structure + transmission, &! inout computed transmittances + radiance, &! inout computed radiances + calcemis = calcemis, &! in flag for internal emissivity calcs + emissivity = emissivity, &! inout input/output emissivities per channel + calcrefl = calcrefl, &! in flag for internal BRDF calcs + reflectance = reflectance) ! inout input/output BRDFs per channel + else + call rttov_parallel_direct( & + errorstatus, &! out error flag + chanprof, &! in channel and profile index structure + opts, &! in options structure + profiles, &! in profile array + coef_rttov, &! in coefficients structure + transmission, &! inout computed transmittances + radiance, &! inout computed radiances + calcemis = calcemis, &! in flag for internal emissivity calcs + emissivity = emissivity, &! inout input/output emissivities per channel + calcrefl = calcrefl, &! in flag for internal BRDF calcs + reflectance = reflectance,&! inout input/output BRDFs per channel + nthreads = nthreads) ! in number of threads to use + endif + call rttov_error('rttov_direct error', lalloc = .true.) + +! if (errorstatus /= errorstatus_success) then +! write (*,*) 'rttov_direct error' +! call rttov_exit(errorstatus) +! endif + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 8. Save output data + ! ------------------------------------------------------ + ! + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Tb(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & + transpose(reshape(radiance%bt(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) + +! tbs(1:prof_num , ich_temp:ich_temp + size(ichan(:,no_id)) - 1) = & +! transpose(reshape(radiance%bt(1:nchanprof), (/ size(ichan(:,no_id)), prof_num/) )) + +! ich_temp = ich_temp + size(ichan(:,no_id)) + + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 9. Deallocate all RTTOV arrays and structures + ! ------------------------------------------------------ + ! From RTTOV example files. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + deallocate (channel_list, stat=alloc_status(1)) + if (alloc_status(1) /= 0) then + write(*,*) 'mem dellocation error' + endif + + ! Deallocate structures for rttov_direct + call rttov_alloc_direct( & + errorstatus, & + 0_jpim, & ! 0 => deallocate +! nprof, & + rttovIN%nPoints, & + nchanprof, & +! nlevels, & + rttovIN%nLevels, & + chanprof, & + opts, & + profiles, & + coef_rttov, & + transmission, & + radiance, & + calcemis=calcemis, & + emissivity=emissivity, & + calcrefl=calcrefl, & + reflectance=reflectance) + call rttov_error('deallocation error for rttov_direct structures', lalloc = .true.) + + call rttov_dealloc_coefs(errorstatus, coef_rttov) + call rttov_error('coefs deallocation error', lalloc = .true.) + + + ! subsub routines + contains + ! Wrapper function for exiting RTTOV and reporting the error + subroutine rttov_error(msg, lalloc) + character(*) :: msg + logical :: lalloc + + if(lalloc) then + if (any(alloc_status /= 0)) then + write(*,*) msg + errorstatus = 1 + call rttov_exit(errorstatus) + endif + else + if (errorstatus /= errorstatus_success) then + write(*,*) msg + call rttov_exit(errorstatus) + endif + endif + end subroutine rttov_error END SUBROUTINE COSP_RTTOV_SIMULATE From e0f4b7505a2213da6a5684e47292191aa861dace Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 7 Mar 2023 09:53:49 -0700 Subject: [PATCH 023/159] Move rttov_IN defined data type to cosp_rttov_XX.F90. Shifted DDT in both the STUB and main files. --- src/cosp.F90 | 3 +- src/simulator/cosp_rttov_interfaceSTUB.F90 | 47 +-------- src/simulator/cosp_rttov_interface_v13.F90 | 109 +++++++++------------ src/simulator/rttov/cosp_rttovSTUB.F90 | 47 +++++++++ src/simulator/rttov/cosp_rttov_v13.F90 | 51 +++++++++- 5 files changed, 149 insertions(+), 108 deletions(-) diff --git a/src/cosp.F90 b/src/cosp.F90 index a138f78241..52663a0ca0 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -52,7 +52,7 @@ MODULE MOD_COSP cloudsat_preclvl,grLidar532_histBsct,atlid_histBsct,& RTTOV_MAX_CHANNELS ! JKS needed for RTTOV to be in cosp_optical_inputs USE MOD_COSP_MODIS_INTERFACE, ONLY: cosp_modis_init, modis_IN - USE MOD_COSP_RTTOV_INTERFACE, ONLY: cosp_rttov_init, cosp_rttov_simulate, rttov_IN + USE MOD_COSP_RTTOV_INTERFACE, ONLY: cosp_rttov_init, cosp_rttov_simulate USE MOD_COSP_MISR_INTERFACE, ONLY: cosp_misr_init, misr_IN USE MOD_COSP_ISCCP_INTERFACE, ONLY: cosp_isccp_init, isccp_IN USE MOD_COSP_CALIPSO_INTERFACE, ONLY: cosp_calipso_init, calipso_IN @@ -66,6 +66,7 @@ MODULE MOD_COSP USE MOD_LIDAR_SIMULATOR, ONLY: lidar_subcolumn, lidar_column USE MOD_MODIS_SIM, ONLY: modis_subcolumn, modis_column USE MOD_PARASOL, ONLY: parasol_subcolumn, parasol_column + USE MOD_COSP_RTTOV, ONLY: rttov_IN USE MOD_COSP_STATS, ONLY: COSP_LIDAR_ONLY_CLOUD,COSP_CHANGE_VERTICAL_GRID, & COSP_DIAG_WARMRAIN ! use mod_cosp_rttov, ONLY: rttov_simulate ! JKS new function diff --git a/src/simulator/cosp_rttov_interfaceSTUB.F90 b/src/simulator/cosp_rttov_interfaceSTUB.F90 index ff27dde3c6..9919b01d16 100644 --- a/src/simulator/cosp_rttov_interfaceSTUB.F90 +++ b/src/simulator/cosp_rttov_interfaceSTUB.F90 @@ -33,52 +33,9 @@ MODULE MOD_COSP_RTTOV_INTERFACE USE COSP_KINDS, ONLY: wp USE MOD_COSP_CONFIG, ONLY: RTTOV_MAX_CHANNELS,rttovDir + USE MOD_COSP_RTTOV, ONLY: rttov_IN IMPLICIT NONE - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! TYPE rttov_in - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - type rttov_in - integer,pointer :: & - nPoints, & ! Number of profiles to simulate - nLevels, & ! Number of levels - nSubCols, & ! Number of subcolumns - nChannels, & ! Number of channels to simulate - month ! Month (needed for surface emissivity calculation) - real(wp),pointer :: & - zenang, & ! Satellite zenith angle - co2, & ! Carbon dioxide - ch4, & ! Methane - n2o, & ! n2o - co ! Carbon monoxide - real(wp),dimension(:),pointer :: & - surfem ! Surface emissivities for the channels - real(wp),dimension(:),pointer :: & - h_surf, & ! Surface height - u_surf, & ! U component of surface wind - v_surf, & ! V component of surface wind - t_skin, & ! Surface skin temperature - p_surf, & ! Surface pressure - t2m, & ! 2 m Temperature - q2m, & ! 2 m Specific humidity - lsmask, & ! land-sea mask - latitude, & ! Latitude - longitude, & ! Longitude - seaice ! Sea-ice? - real(wp),dimension(:,:),pointer :: & - p, & ! Pressure @ model levels - ph, & ! Pressure @ model half levels - t, & ! Temperature - q, & ! Specific humidity - o3 ! Ozone - - ! These fields below are needed ONLY for the RTTOV all-sky brightness temperature - real(wp),dimension(:,:),pointer :: & - tca, & ! Cloud fraction - cldIce, & ! Cloud ice - cldLiq, & ! Cloud liquid - fl_rain, & ! Precipitation flux (startiform+convective rain) (kg/m2/s) - fl_snow ! Precipitation flux (stratiform+convective snow) - end type rttov_in + CONTAINS !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 9837ade5e4..dc3a7cbfb9 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -34,7 +34,7 @@ MODULE MOD_COSP_RTTOV_INTERFACE USE COSP_KINDS, ONLY: wp USE MOD_COSP_CONFIG, ONLY: RTTOV_MAX_CHANNELS,rttovDir use mod_cosp_rttov, only: platform,satellite,sensor,nChannels,iChannel,coef_rttov, & - opts,construct_rttov_coeffilename, & + opts,construct_rttov_coeffilename,rttov_in, & construct_rttov_scatfilename ! coef_scatt,opts,opts_scatt,construct_rttov_coeffilename, & @@ -106,54 +106,6 @@ MODULE MOD_COSP_RTTOV_INTERFACE !#include "rttov_read_coefs.interface" !#include "rttov_read_scattcoeffs.interface" - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! TYPE rttov_in - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - ! JKS - add additional COSP inputs here. - type rttov_in - integer,pointer :: & - nPoints, & ! Number of profiles to simulate - nLevels, & ! Number of levels - nSubCols, & ! Number of subcolumns - nChannels, & ! Number of channels to simulate - month ! Month (needed for surface emissivity calculation) - real(wp),pointer :: & - zenang, & ! Satellite zenith angle - co2, & ! Carbon dioxide - ch4, & ! Methane - n2o, & ! n2o - co ! Carbon monoxide - real(wp),dimension(:),pointer :: & - surfem ! Surface emissivities for the channels - real(wp),dimension(:),pointer :: & - h_surf, & ! Surface height - u_surf, & ! U component of surface wind - v_surf, & ! V component of surface wind - t_skin, & ! Surface skin temperature - p_surf, & ! Surface pressure - t2m, & ! 2 m Temperature - q2m, & ! 2 m Specific humidity - lsmask, & ! land-sea mask - latitude, & ! Latitude - longitude, & ! Longitude - seaice ! Sea-ice? - real(wp),dimension(:,:),pointer :: & - p, & ! Pressure @ model levels - ph, & ! Pressure @ model half levels - t, & ! Temperature - q, & ! Specific humidity - o3 ! Ozone - - ! These fields below are needed ONLY for the RTTOV all-sky brightness temperature - real(wp),dimension(:,:),pointer :: & - tca, & ! Cloud fraction - cldIce, & ! Cloud ice - cldLiq, & ! Cloud liquid - fl_rain, & ! Precipitation flux (startiform+convective rain) (kg/m2/s) - fl_snow ! Precipitation flux (stratiform+convective snow) - end type rttov_in - CONTAINS !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -339,15 +291,18 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI trim(cld_coef_file) ! Read optical depth and cloud coefficient files together - call rttov_read_coefs(errorstatus, coef_rttov, opts, & + call rttov_read_coefs(errorstatus, coef_rttov, opts, & file_coef=OD_coef_filepath, & file_scaer=aer_coef_filepath, & file_sccld=cld_coef_filepath) - if (errorstatus /= errorstatus_success) then - write(*,*) 'fatal error reading coefficients' - call rttov_exit(errorstatus) - endif + ! We aren't checking an allocation steps so this seems more appropriate. + call rttov_error('fatal error reading coefficients' , lalloc = .false.) + ! Old error check +! if (errorstatus /= errorstatus_success) then +! write(*,*) 'fatal error reading coefficients' +! call rttov_exit(errorstatus) +! endif ! Ensure input number of channels is not higher than number stored in coefficient file if (nchannels > coef_rttov % coef % fmv_chn) then @@ -356,10 +311,14 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI ! Ensure the options and coefficients are consistent call rttov_user_options_checkinput(errorstatus, opts, coef_rttov) - if (errorstatus /= errorstatus_success) then - write(*,*) 'error in rttov options' - call rttov_exit(errorstatus) - endif + + ! We aren't checking an allocation steps so this seems more appropriate. + call rttov_error('error in rttov options' , lalloc = .false.) + ! Old error check +! if (errorstatus /= errorstatus_success) then +! write(*,*) 'error in rttov options' +! call rttov_exit(errorstatus) +! endif ! Old code ! coef_file = trim(rttovDir)//"rtcoef_rttov11/rttov7pred54L/"// & @@ -383,6 +342,28 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI ! trim(construct_rttov_scatfilename(platform,satellite,sensor)) ! Can't pass filename to rttov_read_scattcoeffs!!!!! !call rttov_read_scattcoeffs (errorstatus, coef_rttov%coef, coef_scatt,) + + + ! subsub routines + contains + ! Wrapper function for exiting RTTOV and reporting the error + subroutine rttov_error(msg, lalloc) + character(*) :: msg + logical :: lalloc + + if(lalloc) then + if (any(alloc_status /= 0)) then + write(*,*) msg + errorstatus = 1 + call rttov_exit(errorstatus) + endif + else + if (errorstatus /= errorstatus_success) then + write(*,*) msg + call rttov_exit(errorstatus) + endif + endif + end subroutine rttov_error END SUBROUTINE COSP_RTTOV_INIT @@ -464,7 +445,7 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN, & ! Inputs calcrefl=calcrefl, & reflectance=reflectance, & init=.TRUE._jplm) - call rttov_error('allocation error for rttov_direct structures' , lalloc = .true.) + call rttov_error('allocation error for rttov_direct structures' , lalloc = .false.) ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 4. Build the list of profile/channel indices in chanprof @@ -589,7 +570,9 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN, & ! Inputs !profiles(i) %idg = 0. ! Depreciated? !profiles(i) %ish = 0. ! Depreciated? end do - call rttov_error('error in profile initialization' , lalloc = .true.) + + ! JKS - nothing to check here, this will never trigger. + call rttov_error('error in profile initialization' , lalloc = .false.) ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Only add the cloud fields if simulating cloud. @@ -626,7 +609,9 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN, & ! Inputs ! profiles(i)%clw = ! Cloud liquid water (kg/kg) – MW only, end do endif - call rttov_error('error in cloud profile initialization' , lalloc = .true.) + + ! JKS - nothing to check here, this will never trigger. + call rttov_error('error in cloud profile initialization' , lalloc = .false.) ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -643,6 +628,8 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN, & ! Inputs ! ! end do endif + + ! JKS - nothing to check here, this will never trigger. call rttov_error('error in aerosol profile initialization' , lalloc = .true.) ! JKS To-do: set up scattering profiles (MW only) (rttov_profile_cloud) diff --git a/src/simulator/rttov/cosp_rttovSTUB.F90 b/src/simulator/rttov/cosp_rttovSTUB.F90 index 73a0018362..088f1be1ed 100644 --- a/src/simulator/rttov/cosp_rttovSTUB.F90 +++ b/src/simulator/rttov/cosp_rttovSTUB.F90 @@ -35,6 +35,7 @@ MODULE MOD_COSP_RTTOV use mod_cosp_config, only : RTTOV_MAX_CHANNELS,N_HYDRO,rttovDir use cosp_phys_constants, only : mdry=>amd,mO3=>amO3,mco2=>amCO2,mCH4=>amCH4, & mn2o=>amN2O,mco=>amCO + IMPLICIT NONE ! Module parameters @@ -50,6 +51,52 @@ MODULE MOD_COSP_RTTOV integer,dimension(RTTOV_MAX_CHANNELS) :: & iChannel ! RTTOV channel numbers + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! TYPE rttov_IN - Data type specific to inputs required by RTTOV + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + type rttov_IN + integer,pointer :: & + nPoints, & ! Number of profiles to simulate + nLevels, & ! Number of levels + nSubCols, & ! Number of subcolumns + nChannels, & ! Number of channels to simulate + month ! Month (needed for surface emissivity calculation) + real(wp),pointer :: & + zenang, & ! Satellite zenith angle + co2, & ! Carbon dioxide + ch4, & ! Methane + n2o, & ! n2o + co ! Carbon monoxide + real(wp),dimension(:),pointer :: & + surfem ! Surface emissivities for the channels + real(wp),dimension(:),pointer :: & + h_surf, & ! Surface height + u_surf, & ! U component of surface wind + v_surf, & ! V component of surface wind + t_skin, & ! Surface skin temperature + p_surf, & ! Surface pressure + t2m, & ! 2 m Temperature + q2m, & ! 2 m Specific humidity + lsmask, & ! land-sea mask + latitude, & ! Latitude + longitude, & ! Longitude + seaice ! Sea-ice? + real(wp),dimension(:,:),pointer :: & + p, & ! Pressure @ model levels + ph, & ! Pressure @ model half levels + t, & ! Temperature + q, & ! Specific humidity + o3 ! Ozone + + ! These fields below are needed ONLY for the RTTOV all-sky brightness temperature + real(wp),dimension(:,:),pointer :: & + tca, & ! Cloud fraction + cldIce, & ! Cloud ice + cldLiq, & ! Cloud liquid + fl_rain, & ! Precipitation flux (startiform+convective rain) (kg/m2/s) + fl_snow ! Precipitation flux (stratiform+convective snow) + end type rttov_IN + CONTAINS subroutine rttov_column(nPoints,nLevels,nSubCols,q,p,t,o3,ph,h_surf,u_surf,v_surf, & p_surf,t_skin,t2m,q2m,lsmask,lon,lat,seaice,co2,ch4,n2o,co, & diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 04e6025ba5..9ea6e27dcb 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -54,7 +54,6 @@ module mod_cosp_rttov use cosp_phys_constants, only : mdry=>amd,mO3=>amO3,mco2=>amCO2,mCH4=>amCH4, & mn2o=>amN2O,mco=>amCO - ! The rttov_emis_atlas_data type must be imported separately use mod_rttov_emis_atlas, ONLY : & rttov_emis_atlas_data, & @@ -129,6 +128,56 @@ module mod_cosp_rttov ! JKS - KISS ! type(rttov_options_scatt) :: & ! opts_scatt + + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! TYPE rttov_in + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + ! JKS - add additional COSP inputs here. + type rttov_IN + integer,pointer :: & + nPoints, & ! Number of profiles to simulate + nLevels, & ! Number of levels + nSubCols, & ! Number of subcolumns + nChannels, & ! Number of channels to simulate + month ! Month (needed for surface emissivity calculation) + real(wp),pointer :: & + zenang, & ! Satellite zenith angle + co2, & ! Carbon dioxide + ch4, & ! Methane + n2o, & ! n2o + co ! Carbon monoxide + real(wp),dimension(:),pointer :: & + surfem ! Surface emissivities for the channels + real(wp),dimension(:),pointer :: & + h_surf, & ! Surface height + u_surf, & ! U component of surface wind + v_surf, & ! V component of surface wind + t_skin, & ! Surface skin temperature + p_surf, & ! Surface pressure + t2m, & ! 2 m Temperature + q2m, & ! 2 m Specific humidity + lsmask, & ! land-sea mask + latitude, & ! Latitude + longitude, & ! Longitude + seaice ! Sea-ice? + real(wp),dimension(:,:),pointer :: & + p, & ! Pressure @ model levels + ph, & ! Pressure @ model half levels + t, & ! Temperature + q, & ! Specific humidity + o3 ! Ozone + + ! These fields below are needed ONLY for the RTTOV all-sky brightness temperature + real(wp),dimension(:,:),pointer :: & + tca, & ! Cloud fraction + cldIce, & ! Cloud ice + cldLiq, & ! Cloud liquid + fl_rain, & ! Precipitation flux (startiform+convective rain) (kg/m2/s) + fl_snow ! Precipitation flux (stratiform+convective snow) + end type rttov_IN + contains ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From c1bade1c71205dfaadc009923db2d07fede3a908 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 7 Mar 2023 10:24:50 -0700 Subject: [PATCH 024/159] fix trace gas profile set-up --- src/simulator/cosp_rttov_interface_v13.F90 | 30 +++++++--------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index dc3a7cbfb9..accf14489e 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -379,13 +379,6 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN, & ! Inputs Tb ! RTTOV brightness temperature. character(len=128) :: & error ! Error messages (only populated if error encountered) - - ! Internal variables. Trace gas columns in units of (kg/kg) - real(wp),dimension(rttovIN%nLevels) :: & ! wp or jprb? - co2_column, & - ch4_column, & - n2o_column, & - co_column logical :: & rttov_simulate_cld, & rttov_simulate_aer @@ -460,7 +453,7 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN, & ! Inputs do jch = 1, rttovIN%nChannels nch = nch + 1_jpim chanprof(nch)%prof = j - chanprof(nch)%chan = channel_list(jch) + chanprof(nch)%chan = channel_list(jch) ! channel_list should be specified end do end do @@ -485,19 +478,14 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN, & ! Inputs ! Want to set these up as arrays of size (nLevels,nPoints) with ! constant values. Not sure how to do it efficiently. i.e. no loops - - ! Set-up trace gas columns do implied do statements (not working) -! co2_column = (rttovIN%co2, i=1,rttovIN%nLevels) -! ch4_column = (rttovIN%ch4, i=1,rttovIN%nLevels) -! n2o_column = (rttovIN%n2o, i=1,rttovIN%nLevels) -! co_column = (rttovIN%co, i=1,rttovIN%nLevels) - - ! Trace gas concentrations (constant in input, go outside loop) - ! This won't work because the columns should be 2D. -! profiles(:)%co2 = co2_column -! profiles(:)%n2o = n2o_column -! profiles(:)%co = co_column -! profiles(:)%ch4 = ch4_column + + ! Initialize trace gas column concentrations (well-mixed so constant in input) + do j = 1, rttovIN%nlevels + profiles(:)%co2(j) = rttovIN%co2 + profiles(:)%n2o(j) = rttovIN%n2o + profiles(:)%co(j) = rttovIN%n2o + profiles(:)%ch4(j) = rttovIN%ch4 + end do profiles%gas_units = 1 ! kg/kg over moist air (default) From 67536788751da68aa5794b2d3a3a793fe96dc4d4 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 7 Mar 2023 11:41:11 -0700 Subject: [PATCH 025/159] Broke up and moved steps for running RTTOV to cosp_rttov_v13 --- src/simulator/cosp_rttov_interface_v13.F90 | 392 +---------------- src/simulator/rttov/cosp_rttov_v13.F90 | 477 +++++++++++++++++---- 2 files changed, 411 insertions(+), 458 deletions(-) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index accf14489e..89fbdc109c 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -368,11 +368,18 @@ end subroutine rttov_error END SUBROUTINE COSP_RTTOV_INIT !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE cosp_rttov_simulate - JKS should this move to cosp_rttov_v13? + ! SUBROUTINE cosp_rttov_simulate - Call subroutines in mod_cosp_rttov to run RTTOV !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN, & ! Inputs Tb,error) ! Outputs + use mod_cosp_rttov, only: & + rttov_allocate, & + rttov_construct_profiles, & + rttov_setup_emissivity_reflectance, & + rttov_call_direct, & + rttov_save_and_deallocate + type(rttov_in),intent(in) :: & rttovIN real(wp),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! @@ -382,381 +389,14 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN, & ! Inputs logical :: & rttov_simulate_cld, & rttov_simulate_aer - - - ! variables for input - !==================== - integer(kind=jpim) :: nthreads - integer(kind=jpim) :: dosolar - integer(kind=jpim) :: nchanprof ! JKS - jpim is RTTOV integer type - integer(kind=jpim), allocatable :: channel_list(:) ! JKS this needs to be specified - - ! Loop variables - integer(kind=jpim) :: i, j, jch - integer(kind=jpim) :: nch - - integer :: errorstatus - integer :: ich, ich_temp, chan - - - ! Initialize some things - Tb(:,:) = 0._wp - error = '' - - ! How do I want the interface to function? How should it to be consistent with the rest of COSP? - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! 3. Allocate RTTOV input and output structures - ! ------------------------------------------------------ - ! Largely from RTTOV documentation. - ! This only needs to be performed once if all chunks are the same size, right? <-- We don't know chunk sizes at init, so this must be in the main loop. - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - ! Determine the total number of radiances to simulate (nchanprof). - ! We aren't doing subcolumn sampling (RTTOV already does this and it would be slow) -! nchanprof = nchannels * nprof - nchanprof = rttovIN%nChannels * rttovIN%nPoints - - ! Allocate structures for rttov_direct - call rttov_alloc_direct( & - errorstatus, & - 1_jpim, & ! 1 => allocate -! nprof, & - rttovIN%nPoints, & - nchanprof, & -! nlevels, & - rttovIN%nLevels, & - chanprof, & - opts, & - profiles, & - coef_rttov, & -! coefs, & - transmission, & - radiance, & - calcemis=calcemis, & - emissivity=emissivity, & - calcrefl=calcrefl, & - reflectance=reflectance, & - init=.TRUE._jplm) - call rttov_error('allocation error for rttov_direct structures' , lalloc = .false.) - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! 4. Build the list of profile/channel indices in chanprof - ! ------------------------------------------------------ - ! Largely from RTTOV documentation. - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - ! COSP v11 code has an example for multiple instruments - - nch = 0_jpim - do j = 1, rttovIN%nPoints - do jch = 1, rttovIN%nChannels - nch = nch + 1_jpim - chanprof(nch)%prof = j - chanprof(nch)%chan = channel_list(jch) ! channel_list should be specified - end do - end do - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! 5. Read profile data - ! ------------------------------------------------------ - ! Largely from cosp_rttov_v11.F90 file. - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - ! Create a new subroutine in cosp_rttov_v13 and call it to return the profiles - - !call rttov_profile_setup(rttovIN,profiles) - - ! Store profile data from rttovIN in profile type. - ! See RTTOV user guide pg 163 for description of "profiles" type - -! "The rttov_profile structure is composed of the atmospheric part -! and two other structures for 2 meter air and skin surface. -! If you are not able to provide ozone, CO2, etc profiles the flags -! ozone_data, co2_data and so on in the options structure should be -! set to false." - - ! Want to set these up as arrays of size (nLevels,nPoints) with - ! constant values. Not sure how to do it efficiently. i.e. no loops - - ! Initialize trace gas column concentrations (well-mixed so constant in input) - do j = 1, rttovIN%nlevels - profiles(:)%co2(j) = rttovIN%co2 - profiles(:)%n2o(j) = rttovIN%n2o - profiles(:)%co(j) = rttovIN%n2o - profiles(:)%ch4(j) = rttovIN%ch4 - end do - - profiles%gas_units = 1 ! kg/kg over moist air (default) - - do i = 1, rttovIN%nPoints - profiles(i)%p(:) = rttovIN%p(i, :) - profiles(i)%t(:) = rttovIN%t(i, :) - profiles(i)%q(:) = rttovIN%q(i, :) - - ! JKS not sure if I should keep this - where(profiles(i)%q(:) < 1e-4) - profiles(i)%q(:) = 1e-4 - end where - - - ! Add handling of more complex cloud schemes - - ! Gas profiles - profiles(i)%o3 = rttovIN%o3(i, :) -! profiles(i)%so2 = ! Sulfate not in COSP input files - - -! profiles(i)%aerosols(naertyp,nlayers) = ! Aerosols in different modes (see User Guide pg 80) - - - - ! 2m parameters - profiles(i)%s2m%p = rttovIN%p_surf(i) - profiles(i)%s2m%t = rttovIN%t2m(i) ! JKS or rttovIN%t_skin - profiles(i)%s2m%q = rttovIN%q2m(i) ! Should be the same as gas units (kg/kg) - profiles(i)%s2m%u = rttovIN%u_surf(i) - profiles(i)%s2m%v = rttovIN%v_surf(i) - profiles(i)%s2m%wfetc = 10000. ! only used by sea surface solar BRDF model. - - ! skin variables for emissivity calculations - profiles(i)%skin%t = rttovIN%t_skin(i) - - ! fastem coefficients - for mw calculations - profiles(i)%skin%fastem(1) = 3.0 - profiles(i)%skin%fastem(2) = 5.0 - profiles(i)%skin%fastem(3) = 15.0 - profiles(i)%skin%fastem(4) = 0.1 - profiles(i)%skin%fastem(5) = 0.3 - - ! Viewing angles - profiles(i)%zenangle = rttovIN%zenang ! pass in from cosp - profiles(i)%azangle = 0. ! hard-coded in rttov9 int JKS-? - - profiles(i)%latitude = rttovIN%latitude(i) - profiles(i)%longitude = rttovIN%longitude(i) - profiles(i)%elevation = rttovIN%h_surf(i) - - ! Solar angles. JKS - get this from COSP? Doesn't seem to be passed in. - profiles(i)%sunzenangle = 0. ! hard-coded in rttov9 int - profiles(i)%sunazangle = 0. ! hard-coded in rttov9 int - - ! surface type - ! land-sea mask (lsmask) indicates proportion of land in grid - if (rttovIN%lsmask(i) < 0.5) then - profiles(i)%skin%surftype = surftype_sea - else - profiles(i)%skin%surftype = surftype_land - endif - ! sea-ice fraction - if (rttovIN%seaice(i) >= 0.5) then - profiles(i)%skin%surftype = surftype_seaice - endif - - ! dar: hard-coded to 1 (=ocean water) in rttov 9 int - profiles(i)%skin%watertype = 1 - !profiles(i) %idg = 0. ! Depreciated? - !profiles(i) %ish = 0. ! Depreciated? - end do - - ! JKS - nothing to check here, this will never trigger. - call rttov_error('error in profile initialization' , lalloc = .false.) - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Only add the cloud fields if simulating cloud. - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - rttov_simulate_cld = .false. - if (rttov_simulate_cld) then - - ! Set cloud mass mixing ratio units - profiles%mmr_cldaer = .true. ! kg/kg for cloud and aerosol (default) - - profiles%clw_scheme = 2. ! Deff scheme avoids cloud types - ! profiles%clwde_scheme = 1. ! Not implemented? - profiles%ice_scheme = 1. !1:Baum 2:Baran(2014) 3:Baran(2018) - profiles%icede_param = 2. ! 2:Wyser(recommended). Only used if ice effective diameter not input - - do i = 1, rttovIN%nPoints - ! Cloud scheme stuff - profiles(i)%cfrac(:) = rttovIN%tca(i,:) ! Cloud fraction for each layer - profiles(i)%cloud(1,:) = rttovIN%cldLiq(i,:) ! Cloud water mixing ratio (all in the first type for Deff) - profiles(i)%cloud(6,:) = rttovIN%cldIce(i,:) ! Cloud ice mixing ratio (1 type). See pg 74. - - ! Example UKMO input has effective radii for multiple cloud types, making identification of a single - ! liquid droplet or ice crystal effective diameter difficult. - ! I opt to let RTTOV decide on the effective radius values, but more complex implementation - ! could do a more thorough conversion between UKMO output and RTTOV input - ! profiles(i)%clwde = ! Cloud water effective diameter - ! profiles(i)%icede = ! Cloud ice effective diameter - - ! Old code for simple cloud schemes only - ! profiles(i)%cfraction = 0. - ! profiles(i)%ctp = 500. - - ! Other options not implemented -! profiles(i)%clw = ! Cloud liquid water (kg/kg) – MW only, - end do - endif - - ! JKS - nothing to check here, this will never trigger. - call rttov_error('error in cloud profile initialization' , lalloc = .false.) - - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Only add the aerosol fields if simulating aerosol. - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - rttov_simulate_aer = .false. - if (rttov_simulate_aer) then - - ! Set aerosol mass mixing ratio units - profiles%mmr_cldaer = .true. ! kg/kg for cloud and aerosol (default) - - ! Read in aerosol profiles -! do i = 1, rttovIN%nPoints -! -! end do - endif - - ! JKS - nothing to check here, this will never trigger. - call rttov_error('error in aerosol profile initialization' , lalloc = .true.) - - ! JKS To-do: set up scattering profiles (MW only) (rttov_profile_cloud) - - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! 6. Specify surface emissivity and reflectance - ! ------------------------------------------------------ - ! From RTTOV example files. - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - ! In this example we have no values for input emissivities or reflectances - ! so we initialise all inputs to zero - call rttov_init_emis_refl(emissivity, reflectance) - call rttov_error('error for emissivity/reflectance initialization' , lalloc = .true.) - - ! Calculate emissivity within RTTOV where the input emissivity value is - ! zero or less (all channels in this case) - calcemis(:) = (emissivity(:) % emis_in <= 0._jprb) - - ! Calculate reflectances within RTTOV where the input BRDF value is zero or - ! less (all channels in this case) - calcrefl(:) = (reflectance(:) % refl_in <= 0._jprb) - - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! 7. Call RTTOV forward model (Woohoo!) - ! ------------------------------------------------------ - ! From RTTOV example files. - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - nthreads = 1 ! Default not parallel for now. Can be optimized later. - JKS - - if (nthreads <= 1) then - call rttov_direct( & - errorstatus, &! out error flag - chanprof, &! in channel and profile index structure - opts, &! in options structure - profiles, &! in profile array - coef_rttov, &! in coefficients structure - transmission, &! inout computed transmittances - radiance, &! inout computed radiances - calcemis = calcemis, &! in flag for internal emissivity calcs - emissivity = emissivity, &! inout input/output emissivities per channel - calcrefl = calcrefl, &! in flag for internal BRDF calcs - reflectance = reflectance) ! inout input/output BRDFs per channel - else - call rttov_parallel_direct( & - errorstatus, &! out error flag - chanprof, &! in channel and profile index structure - opts, &! in options structure - profiles, &! in profile array - coef_rttov, &! in coefficients structure - transmission, &! inout computed transmittances - radiance, &! inout computed radiances - calcemis = calcemis, &! in flag for internal emissivity calcs - emissivity = emissivity, &! inout input/output emissivities per channel - calcrefl = calcrefl, &! in flag for internal BRDF calcs - reflectance = reflectance,&! inout input/output BRDFs per channel - nthreads = nthreads) ! in number of threads to use - endif - call rttov_error('rttov_direct error', lalloc = .true.) - -! if (errorstatus /= errorstatus_success) then -! write (*,*) 'rttov_direct error' -! call rttov_exit(errorstatus) -! endif - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! 8. Save output data - ! ------------------------------------------------------ - ! - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - Tb(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & - transpose(reshape(radiance%bt(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) - -! tbs(1:prof_num , ich_temp:ich_temp + size(ichan(:,no_id)) - 1) = & -! transpose(reshape(radiance%bt(1:nchanprof), (/ size(ichan(:,no_id)), prof_num/) )) - -! ich_temp = ich_temp + size(ichan(:,no_id)) - - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! 9. Deallocate all RTTOV arrays and structures - ! ------------------------------------------------------ - ! From RTTOV example files. - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - deallocate (channel_list, stat=alloc_status(1)) - if (alloc_status(1) /= 0) then - write(*,*) 'mem dellocation error' - endif - - ! Deallocate structures for rttov_direct - call rttov_alloc_direct( & - errorstatus, & - 0_jpim, & ! 0 => deallocate -! nprof, & - rttovIN%nPoints, & - nchanprof, & -! nlevels, & - rttovIN%nLevels, & - chanprof, & - opts, & - profiles, & - coef_rttov, & - transmission, & - radiance, & - calcemis=calcemis, & - emissivity=emissivity, & - calcrefl=calcrefl, & - reflectance=reflectance) - call rttov_error('deallocation error for rttov_direct structures', lalloc = .true.) - - call rttov_dealloc_coefs(errorstatus, coef_rttov) - call rttov_error('coefs deallocation error', lalloc = .true.) - - - ! subsub routines - contains - ! Wrapper function for exiting RTTOV and reporting the error - subroutine rttov_error(msg, lalloc) - character(*) :: msg - logical :: lalloc - - if(lalloc) then - if (any(alloc_status /= 0)) then - write(*,*) msg - errorstatus = 1 - call rttov_exit(errorstatus) - endif - else - if (errorstatus /= errorstatus_success) then - write(*,*) msg - call rttov_exit(errorstatus) - endif - endif - end subroutine rttov_error + integer(kind=jpim) :: nthreads ! Parallelization, should become an input + + ! Run each step for running RTTOV from mod_cosp_rttov + call rttov_allocate(rttovIN) + call rttov_construct_profiles(rttovIN) + call rttov_setup_emissivity_reflectance() + call rttov_call_direct(nthreads) + call rttov_save_and_deallocate(rttovIN,Tb) END SUBROUTINE COSP_RTTOV_SIMULATE diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 9ea6e27dcb..55d6ec49e6 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -124,11 +124,34 @@ module mod_cosp_rttov ! RTTOV setup and options (set during initialization) type(rttov_options) :: & opts ! defaults to everything optional switched off + + ! JKS should this be module-wide? +! type(rttov_IN) :: & +! rttovIN ! JKS - KISS ! type(rttov_options_scatt) :: & ! opts_scatt + ! module-wides variables for input + !==================== + integer(kind=jpim) :: nthreads + integer(kind=jpim) :: dosolar + integer(kind=jpim) :: nchanprof ! JKS - jpim is RTTOV integer type + integer(kind=jpim), allocatable :: channel_list(:) ! JKS this needs to be specified + + TYPE(rttov_chanprof), POINTER :: chanprof(:) => NULL() ! Input channel/profile list + LOGICAL(KIND=jplm), POINTER :: calcemis(:) => NULL() ! Flag to indicate calculation of emissivity within RTTOV + TYPE(rttov_emissivity), POINTER :: emissivity(:) => NULL() ! Input/output surface emissivity + LOGICAL(KIND=jplm), POINTER :: calcrefl(:) => NULL() ! Flag to indicate calculation of BRDF within RTTOV + TYPE(rttov_reflectance), POINTER :: reflectance(:) => NULL() ! Input/output surface BRDF + TYPE(rttov_profile), POINTER :: profiles(:) => NULL() ! Input profiles + TYPE(rttov_transmission) :: transmission ! Output transmittances + TYPE(rttov_radiance) :: radiance ! Output radiances + + INTEGER(KIND=jpim) :: errorstatus ! Return error status of RTTOV subroutine calls + + INTEGER(KIND=jpim) :: alloc_status(60) ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! TYPE rttov_in @@ -180,95 +203,385 @@ module mod_cosp_rttov contains - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE rttov_simulate - JKS - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine rttov_simulate(nPoints,nLevels,nSubCols,q,p,t,o3,ph,h_surf,u_surf,v_surf, & - p_surf,t_skin,t2m,q2m,lsmask,lon,lat,seaice,co2,ch4,n2o,co, & - zenang,lCleanup, & - ! Optional arguments for surface emissivity calculation. - surfem,month, & - ! Optional arguments for all-sky calculation. - tca,ciw,clw,rain,snow, & - ! Outputs - Tb,error) + ! Wrapper function for exiting RTTOV and reporting the error + subroutine rttov_error(msg, lalloc) + character(*) :: msg + logical :: lalloc + + if(lalloc) then + if (any(alloc_status /= 0)) then + write(*,*) msg + errorstatus = 1 + call rttov_exit(errorstatus) + endif + else + if (errorstatus /= errorstatus_success) then + write(*,*) msg + call rttov_exit(errorstatus) + endif + endif + end subroutine rttov_error -! coef_rttov, & ! JKS added coef_rttov - ! Optional arguments for all-sky calculation. -! tca,ciw,clw,rain,snow) + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE rttov_allocate - JKS + ! ------------------------------------------------------ + ! 3. Allocate RTTOV input and output structures + ! 4. Build the list of profile/channel indices in chanprof + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine rttov_allocate(rttovIN & + ) + + type(rttov_in),intent(in) :: & ! What is the best way to do this? Should rttovIN be a module-wide DDT? Yes. + rttovIN + + ! Loop variables + integer(kind=jpim) :: j, jch, nch +! integer(kind=jpim) :: nch + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 3. Allocate RTTOV input and output structures + ! ------------------------------------------------------ + ! Largely from RTTOV documentation. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + ! Determine the total number of radiances to simulate (nchanprof). + ! We aren't doing subcolumn sampling (RTTOV already does this and it would be slow) +! nchanprof = nchannels * nprof + nchanprof = rttovIN%nChannels * rttovIN%nPoints + + ! Allocate structures for rttov_direct + call rttov_alloc_direct( & + errorstatus, & + 1_jpim, & ! 1 => allocate +! nprof, & + rttovIN%nPoints, & + nchanprof, & +! nlevels, & + rttovIN%nLevels, & + chanprof, & + opts, & + profiles, & + coef_rttov, & +! coefs, & + transmission, & + radiance, & + calcemis=calcemis, & + emissivity=emissivity, & + calcrefl=calcrefl, & + reflectance=reflectance, & + init=.TRUE._jplm) + call rttov_error('allocation error for rttov_direct structures' , lalloc = .false.) + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 4. Build the list of profile/channel indices in chanprof + ! ------------------------------------------------------ + ! Largely from RTTOV documentation. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + nch = 0_jpim + do j = 1, rttovIN%nPoints + do jch = 1, rttovIN%nChannels + nch = nch + 1_jpim + chanprof(nch)%prof = j + chanprof(nch)%chan = channel_list(jch) ! channel_list should be specified + end do + end do + + end subroutine rttov_allocate + + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 5. rttov_construct_profiles: 5. Read profile data + ! ------------------------------------------------------ + ! Largely from cosp_rttov_v11.F90 file. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine rttov_construct_profiles(rttovIN & + ) + + type(rttov_in),intent(in) :: & ! What is the best way to do this? Should rttovIN be a module-wide DDT? Yes. + rttovIN + + ! Loop variables + integer(kind=jpim) :: i, j ! Use i to iterate over profile, j for levels. + + logical :: & + rttov_simulate_cld, & + rttov_simulate_aer + + ! Store profile data from rttovIN in profile type. + ! See RTTOV user guide pg 163 for description of "profiles" type + + ! "The rttov_profile structure is composed of the atmospheric part + ! and two other structures for 2 meter air and skin surface. + ! If you are not able to provide ozone, CO2, etc profiles the flags + ! ozone_data, co2_data and so on in the options structure should be + ! set to false." + + ! Initialize trace gas column concentrations (well-mixed so constant in input) + do j = 1, rttovIN%nlevels + profiles(:)%co2(j) = rttovIN%co2 + profiles(:)%n2o(j) = rttovIN%n2o + profiles(:)%co(j) = rttovIN%n2o + profiles(:)%ch4(j) = rttovIN%ch4 + end do + + profiles%gas_units = 1 ! kg/kg over moist air (default) + + do i = 1, rttovIN%nPoints + profiles(i)%p(:) = rttovIN%p(i, :) + profiles(i)%t(:) = rttovIN%t(i, :) + profiles(i)%q(:) = rttovIN%q(i, :) + + ! JKS not sure if I should keep this limiting of water vapor + where(profiles(i)%q(:) < 1e-4) + profiles(i)%q(:) = 1e-4 + end where + + ! Gas profiles + profiles(i)%o3 = rttovIN%o3(i, :) +! profiles(i)%so2 = ! Sulfate not in COSP input files + +! profiles(i)%aerosols(naertyp,nlayers) = ! Aerosols in different modes (see User Guide pg 80) + + ! 2m parameters + profiles(i)%s2m%p = rttovIN%p_surf(i) + profiles(i)%s2m%t = rttovIN%t2m(i) ! JKS or rttovIN%t_skin + profiles(i)%s2m%q = rttovIN%q2m(i) ! Should be the same as gas units (kg/kg) + profiles(i)%s2m%u = rttovIN%u_surf(i) + profiles(i)%s2m%v = rttovIN%v_surf(i) + profiles(i)%s2m%wfetc = 10000. ! only used by sea surface solar BRDF model. + + ! skin variables for emissivity calculations + profiles(i)%skin%t = rttovIN%t_skin(i) + + ! fastem coefficients - for mw calculations + profiles(i)%skin%fastem(1) = 3.0 + profiles(i)%skin%fastem(2) = 5.0 + profiles(i)%skin%fastem(3) = 15.0 + profiles(i)%skin%fastem(4) = 0.1 + profiles(i)%skin%fastem(5) = 0.3 + + ! Viewing angles + profiles(i)%zenangle = rttovIN%zenang ! pass in from cosp + profiles(i)%azangle = 0. ! hard-coded in rttov9 int JKS-? + + profiles(i)%latitude = rttovIN%latitude(i) + profiles(i)%longitude = rttovIN%longitude(i) + profiles(i)%elevation = rttovIN%h_surf(i) + + ! Solar angles. JKS - get this from COSP? Doesn't seem to be passed in. + profiles(i)%sunzenangle = 0. ! hard-coded in rttov9 int + profiles(i)%sunazangle = 0. ! hard-coded in rttov9 int + + ! surface type + ! land-sea mask (lsmask) indicates proportion of land in grid + if (rttovIN%lsmask(i) < 0.5) then + profiles(i)%skin%surftype = surftype_sea + else + profiles(i)%skin%surftype = surftype_land + endif + ! sea-ice fraction + if (rttovIN%seaice(i) >= 0.5) then + profiles(i)%skin%surftype = surftype_seaice + endif + + ! dar: hard-coded to 1 (=ocean water) in rttov 9 int + profiles(i)%skin%watertype = 1 + !profiles(i) %idg = 0. ! Depreciated? + !profiles(i) %ish = 0. ! Depreciated? + end do + + ! JKS - nothing to check here, this will never trigger. + call rttov_error('error in profile initialization' , lalloc = .false.) + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Only add the cloud fields if simulating cloud. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + rttov_simulate_cld = .false. + if (rttov_simulate_cld) then + + ! Set cloud mass mixing ratio units + profiles%mmr_cldaer = .true. ! kg/kg for cloud and aerosol (default) + + profiles%clw_scheme = 2. ! Deff scheme avoids cloud types + ! profiles%clwde_scheme = 1. ! Not implemented? + profiles%ice_scheme = 1. !1:Baum 2:Baran(2014) 3:Baran(2018) + profiles%icede_param = 2. ! 2:Wyser(recommended). Only used if ice effective diameter not input + + do i = 1, rttovIN%nPoints + ! Cloud scheme stuff + profiles(i)%cfrac(:) = rttovIN%tca(i,:) ! Cloud fraction for each layer + profiles(i)%cloud(1,:) = rttovIN%cldLiq(i,:) ! Cloud water mixing ratio (all in the first type for Deff) + profiles(i)%cloud(6,:) = rttovIN%cldIce(i,:) ! Cloud ice mixing ratio (1 type). See pg 74. + + ! Example UKMO input has effective radii for multiple cloud types, making identification of a single + ! liquid droplet or ice crystal effective diameter difficult. + ! I opt to let RTTOV decide on the effective radius values, but more complex implementation + ! could do a more thorough conversion between UKMO output and RTTOV input + ! profiles(i)%clwde = ! Cloud water effective diameter + ! profiles(i)%icede = ! Cloud ice effective diameter + + ! Old code for simple cloud schemes only + ! profiles(i)%cfraction = 0. + ! profiles(i)%ctp = 500. + + ! Other options not implemented +! profiles(i)%clw = ! Cloud liquid water (kg/kg) – MW only, + end do + endif + + ! JKS - nothing to check here, this will never trigger. + call rttov_error('error in cloud profile initialization' , lalloc = .false.) + + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Only add the aerosol fields if simulating aerosol. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + rttov_simulate_aer = .false. + if (rttov_simulate_aer) then + + ! Set aerosol mass mixing ratio units + profiles%mmr_cldaer = .true. ! kg/kg for cloud and aerosol (default) + + ! Read in aerosol profiles +! do i = 1, rttovIN%nPoints +! +! end do + endif + + ! JKS - nothing to check here, this will never trigger. + call rttov_error('error in aerosol profile initialization' , lalloc = .true.) + + ! JKS To-do: set up scattering profiles (MW only) (rttov_profile_cloud) - ! Inputs - integer,intent(in) :: & - nPoints, & ! Number of gridpoints - nLevels, & ! Number of vertical levels - nSubCols ! Number of subcolumns - real(wp),intent(in) :: & - co2, & ! CO2 mixing ratio (kg/kg) - ch4, & ! CH4 mixing ratio (kg/kg) - n2o, & ! N2O mixing ratio (kg/kg) - co, & ! CO mixing ratio (kg/kg) - zenang ! Satellite zenith angle - real(wp),dimension(nPoints),intent(in) :: & - h_surf, & ! Surface height (m) - u_surf, & ! Surface u-wind (m/s) - v_surf, & ! Surface v-wind (m/s) - p_surf, & ! Surface pressure (Pa) - t_skin, & ! Skin temperature (K) - t2m, & ! 2-meter temperature (K) - q2m, & ! 2-meter specific humidity (kg/kg) - lsmask, & ! Land/sea mask - lon, & ! Longitude (deg) - lat, & ! Latitude (deg) - seaice ! Seaice fraction (0-1) - real(wp),dimension(nPoints,nLevels),intent(in) :: & - q, & ! Specific humidity (kg/kg) - p, & ! Pressure(Pa) - t, & ! Temperature (K) - o3 ! Ozone - real(wp),dimension(nPoints,nLevels+1),intent(in) :: & - ph ! Pressure @ half-levels (Pa) - logical,intent(in) :: & - lCleanup ! Flag to determine whether to deallocate RTTOV types - - ! Cloud fields - real(wp),dimension(nPoints,nLevels),intent(in) :: & - tca ! Total column cloud amount (0-1) - real(wp),dimension(nPoints,nSubCols,nLevels),intent(in) :: & - ciw, & ! Cloud ice - clw, & ! Cloud liquid - rain, & ! Precipitation flux (kg/m2/s) - snow ! Precipitation flux (kg/m2/s) - - ! Optional inputs (Needed for surface emissivity calculation) - integer,optional :: & - month ! Month (needed to determine table to load) - real(wp),dimension(nChannels),optional :: & - surfem ! Surface emissivity for each RTTOV channel - - ! Optional inputs (Needed for all-sky calculation) -! real(wp),dimension(nPoints,nLevels),optional :: & -! tca ! Total column cloud amount (0-1) -! real(wp),dimension(nPoints,nSubCols,nLevels),optional :: & -! ciw, & ! Cloud ice -! clw, & ! Cloud liquid -! rain, & ! Precipitation flux (kg/m2/s) -! snow ! Precipitation flux (kg/m2/s) + end subroutine rttov_construct_profiles + - ! Outputs - real(wp),dimension(nPoints,nChannels) :: & - Tb ! RTTOV brightness temperature. - character(len=128) :: & - error ! Error messages (only populated if error encountered) + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 6. rttov_setup_emissivity_reflectance - Specify surface emissivity and reflectance + ! ------------------------------------------------------ + ! From RTTOV example files. Will need to be expanded on to pass in values. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine rttov_setup_emissivity_reflectance() + + ! In this example we have no values for input emissivities or reflectances + ! so we initialise all inputs to zero + call rttov_init_emis_refl(emissivity, reflectance) + call rttov_error('error for emissivity/reflectance initialization' , lalloc = .true.) + + ! Calculate emissivity within RTTOV where the input emissivity value is + ! zero or less (all channels in this case) + calcemis(:) = (emissivity(:) % emis_in <= 0._jprb) + + ! Calculate reflectances within RTTOV where the input BRDF value is zero or + ! less (all channels in this case) + calcrefl(:) = (reflectance(:) % refl_in <= 0._jprb) + + end subroutine rttov_setup_emissivity_reflectance + + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 7. rttov_call_direct - Call RTTOV forward model (Woohoo!) + ! ------------------------------------------------------ + ! From RTTOV example files. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine rttov_call_direct(nthreads) + + integer(kind=jpim) :: nthreads - ! Initialize some things - Tb(:,:) = 0._wp - error = '' + nthreads = 1 ! Default not parallel for now. Can be optimized later. - JKS + + if (nthreads <= 1) then + call rttov_direct( & + errorstatus, &! out error flag + chanprof, &! in channel and profile index structure + opts, &! in options structure + profiles, &! in profile array + coef_rttov, &! in coefficients structure + transmission, &! inout computed transmittances + radiance, &! inout computed radiances + calcemis = calcemis, &! in flag for internal emissivity calcs + emissivity = emissivity, &! inout input/output emissivities per channel + calcrefl = calcrefl, &! in flag for internal BRDF calcs + reflectance = reflectance) ! inout input/output BRDFs per channel + else + call rttov_parallel_direct( & + errorstatus, &! out error flag + chanprof, &! in channel and profile index structure + opts, &! in options structure + profiles, &! in profile array + coef_rttov, &! in coefficients structure + transmission, &! inout computed transmittances + radiance, &! inout computed radiances + calcemis = calcemis, &! in flag for internal emissivity calcs + emissivity = emissivity, &! inout input/output emissivities per channel + calcrefl = calcrefl, &! in flag for internal BRDF calcs + reflectance = reflectance,&! inout input/output BRDFs per channel + nthreads = nthreads) ! in number of threads to use + endif + call rttov_error('rttov_direct error', lalloc = .true.) + + end subroutine rttov_call_direct + + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! rttov_save_and_deallocate - 8. Save output data, 9. Deallocate all RTTOV arrays and structures + ! ------------------------------------------------------ + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine rttov_save_and_deallocate(rttovIN,Tb) + + type(rttov_in),intent(in) :: & + rttovIN + real(wp),dimension(rttovIN%nPoints,rttovIN%nChannels),intent(inout) :: & ! Can I do this? I guess so! + Tb ! RTTOV brightness temperature. + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 8. Save output data + ! ------------------------------------------------------ + ! JKS - Need to allow options for Tb and radiance for clear- and cloudy-skies + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + Tb(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & + transpose(reshape(radiance%bt(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 9. Deallocate all RTTOV arrays and structures + ! ------------------------------------------------------ + ! From RTTOV example files. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + deallocate (channel_list, stat=alloc_status(1)) + if (alloc_status(1) /= 0) then + write(*,*) 'mem dellocation error' + endif -! Current inputs: rttovIN,cospOUT%rttov_tbs(ij:ik,:),cosp_simulator(nError+1) + ! Deallocate structures for rttov_direct + call rttov_alloc_direct( & + errorstatus, & + 0_jpim, & ! 0 => deallocate +! nprof, & + rttovIN%nPoints, & + nchanprof, & +! nlevels, & + rttovIN%nLevels, & + chanprof, & + opts, & + profiles, & + coef_rttov, & + transmission, & + radiance, & + calcemis=calcemis, & + emissivity=emissivity, & + calcrefl=calcrefl, & + reflectance=reflectance) + call rttov_error('deallocation error for rttov_direct structures', lalloc = .true.) + + call rttov_dealloc_coefs(errorstatus, coef_rttov) + call rttov_error('coefs deallocation error', lalloc = .true.) + + end subroutine rttov_save_and_deallocate -! JKS new function end - end subroutine rttov_simulate function construct_rttov_coeffilename(platform,satellite,instrument) ! Inputs From 2896be6d382b615f73825bb87c8df9c3a5c4aae7 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 7 Mar 2023 11:56:17 -0700 Subject: [PATCH 026/159] Clean up old dependencies in rttov_interface_v13 --- src/simulator/cosp_rttov_interface_v13.F90 | 57 ++-------------------- 1 file changed, 5 insertions(+), 52 deletions(-) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 89fbdc109c..bbd88a7ef5 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -36,27 +36,16 @@ MODULE MOD_COSP_RTTOV_INTERFACE use mod_cosp_rttov, only: platform,satellite,sensor,nChannels,iChannel,coef_rttov, & opts,construct_rttov_coeffilename,rttov_in, & construct_rttov_scatfilename -! coef_scatt,opts,opts_scatt,construct_rttov_coeffilename, & ! rttov_const contains useful RTTOV constants USE rttov_const, ONLY : & errorstatus_success, & - errorstatus_fatal, & - platform_name, & - inst_name, & - surftype_sea, & - surftype_land, & - surftype_seaice + errorstatus_fatal + ! rttov_types contains definitions of all RTTOV data types USE rttov_types, ONLY : & rttov_options, & - rttov_coefs, & - rttov_profile, & - rttov_transmission, & - rttov_radiance, & - rttov_chanprof, & - rttov_emissivity, & - rttov_reflectance + rttov_coefs ! jpim, jprb and jplm are the RTTOV integer, real and logical KINDs USE parkind1, ONLY : jpim, jprb, jplm @@ -65,47 +54,20 @@ MODULE MOD_COSP_RTTOV_INTERFACE IMPLICIT NONE -#include "rttov_direct.interface" -#include "rttov_parallel_direct.interface" #include "rttov_read_coefs.interface" -#include "rttov_dealloc_coefs.interface" -#include "rttov_alloc_direct.interface" -#include "rttov_init_emis_refl.interface" #include "rttov_user_options_checkinput.interface" #include "rttov_print_opts.interface" -#include "rttov_print_profile.interface" -#include "rttov_skipcommentline.interface" !-------------------------- - ! - INTEGER(KIND=jpim), PARAMETER :: iup = 20 ! unit for input profile file - INTEGER(KIND=jpim), PARAMETER :: ioout = 21 ! unit for output - + ! RTTOV variables/structures !==================== -! JKS these are already imported from "mod_cosp_rttov" -! TYPE(rttov_options) :: opts ! Options structure -! TYPE(rttov_coefs) :: coefs ! Coefficients structure - - TYPE(rttov_chanprof), POINTER :: chanprof(:) => NULL() ! Input channel/profile list LOGICAL(KIND=jplm), POINTER :: calcemis(:) => NULL() ! Flag to indicate calculation of emissivity within RTTOV - TYPE(rttov_emissivity), POINTER :: emissivity(:) => NULL() ! Input/output surface emissivity LOGICAL(KIND=jplm), POINTER :: calcrefl(:) => NULL() ! Flag to indicate calculation of BRDF within RTTOV - TYPE(rttov_reflectance), POINTER :: reflectance(:) => NULL() ! Input/output surface BRDF - TYPE(rttov_profile), POINTER :: profiles(:) => NULL() ! Input profiles - TYPE(rttov_transmission) :: transmission ! Output transmittances - TYPE(rttov_radiance) :: radiance ! Output radiances - INTEGER(KIND=jpim) :: errorstatus ! Return error status of RTTOV subroutine calls INTEGER(KIND=jpim) :: alloc_status(60) -! integer :: alloc_status_cosp(60) - -! Old -!#include "rttov_read_coefs.interface" -!#include "rttov_read_scattcoeffs.interface" - CONTAINS !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -298,11 +260,7 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI ! We aren't checking an allocation steps so this seems more appropriate. call rttov_error('fatal error reading coefficients' , lalloc = .false.) - ! Old error check -! if (errorstatus /= errorstatus_success) then -! write(*,*) 'fatal error reading coefficients' -! call rttov_exit(errorstatus) -! endif + ! Ensure input number of channels is not higher than number stored in coefficient file if (nchannels > coef_rttov % coef % fmv_chn) then @@ -314,11 +272,6 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI ! We aren't checking an allocation steps so this seems more appropriate. call rttov_error('error in rttov options' , lalloc = .false.) - ! Old error check -! if (errorstatus /= errorstatus_success) then -! write(*,*) 'error in rttov options' -! call rttov_exit(errorstatus) -! endif ! Old code ! coef_file = trim(rttovDir)//"rtcoef_rttov11/rttov7pred54L/"// & From 03b507e9d1427d37be44487dce832260549c2fc9 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 7 Mar 2023 14:41:24 -0700 Subject: [PATCH 027/159] Building without errors with RTTOV. --- build/Makefile | 33 ++++++++++++----- build/Makefile.rttov | 84 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 9 deletions(-) create mode 100644 build/Makefile.rttov diff --git a/build/Makefile b/build/Makefile index 182c7d18cb..9c3a7d24d2 100644 --- a/build/Makefile +++ b/build/Makefile @@ -11,10 +11,18 @@ MODIS_PATH = $(SIM_PATH)/MODIS_simulator PARASOL_PATH = $(SIM_PATH)/parasol # RTTOV variables. You may need to change this. JKS -RTTOV_PATH = /glade/u/home/jonahshaw/w/RTTOV -RTTOV_LIB_PATH = $(RTTOV_PATH)/lib -RTTOV_INC_PATH = $(RTTOV_PATH)/include -RTTOV_MOD_PATH = $(RTTOV_PATH)/mod +# RTTOV_PATH = /glade/u/home/jonahshaw/w/RTTOV +# RTTOV_LIB_PATH = $(RTTOV_PATH)/lib +# RTTOV_INC_PATH = $(RTTOV_PATH)/include +# RTTOV_MOD_PATH = $(RTTOV_PATH)/mod + +# Makefile.rttov needs to define: RTTOVDIR, FFLAGS, LIBDIR, LIBS, LLIBS +include Makefile.rttov +# RTTOV_LIB_PATH = $(RTTOVDIR)/lib # JKS - this became LIBDIR in Makefile.rttov +# RTTOV_INC_PATH = $(RTTOVDIR)/include # JKS - this gets folded into FFLAGS +# RTTOV_MOD_PATH = $(RTTOVDIR)/mod # JKS - this gets folded into FFLAGS + + VPATH = $(SRC_PATH):$(HOOKS):$(SIM_PATH):$(RT_PATH):$(RS_PATH):$(CS_PATH):$(ISCCP_PATH):$(MISR_PATH):$(MODIS_PATH):$(PARASOL_PATH) @@ -34,7 +42,11 @@ LDFLAGS += $(NC_LIB) -lnetcdff LDFLAGS += -L. -lcosp -lsubcol ifdef RTTOV -LDFLAGS += -L${RTTOV_LIB_PATH} -lrttov13 +# LDFLAGS += -L${RTTOV_LIB_PATH} -lrttov13 +#LDFLAGS += -L${RTTOV_LIB_PATH} -lrttov_main +#LDFLAGS += -L${LIBDIR} -lrttov_main +#LDFLAGS += $(LIBS) $(LLIBS) +LDFLAGS += $(LIBS) $(LLIBS) $(LDFLAGS_NETCDF) $(LDFLAGS_HDF5) $(LDFLAGS_ARCH) $(LDFLAGS_LAPACK) endif @@ -46,16 +58,19 @@ endif $(F90) $(F90FLAGS) -c $< %: %.o - $(F90) $(F90FLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) + $(F90) $(F90FLAGS) -o $@ $^ $(LDFLAGS) +# $(F90) $(F90FLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) # Special rule for the RTTOV file. Had an ifdef line but it wasn't necessary. # JKS is this needed because of the load_coefficient calls? Can I remove this by restructuring? cosp_rttov_interface_v13.o : cosp_rttov_interface_v13.F90 - $(F90) $(F90FLAGS) -c -I $(RTTOV_INC_PATH) -I $(RTTOV_MOD_PATH) $< + $(F90) $(F90FLAGS) $(FFLAGS) -c $< +# $(F90) $(F90FLAGS) -c -I $(RTTOV_INC_PATH) -I $(RTTOV_MOD_PATH) $< cosp_rttov_v13.o : cosp_rttov_v13.F90 - $(F90) $(F90FLAGS) -c -I $(RTTOV_INC_PATH) -I $(RTTOV_MOD_PATH) $< + $(F90) $(F90FLAGS) $(FFLAGS) -c $< +# $(F90) $(F90FLAGS) -c -I $(RTTOV_INC_PATH) -I $(RTTOV_MOD_PATH) $< # # The COSP library @@ -66,7 +81,7 @@ COSP_OBJS = cosp.o cosp_config.o cosp_stats.o cosp_constants.o cosp_errorHandlin cosp_calipso_interface.o lidar_simulator.o cosp_cloudsat_interface.o quickbeam.o \ cosp_grLidar532_interface.o cosp_atlid_interface.o -# Add RTTOV files appropriately +# Add RTTOV files appropriately. JKS: cosp should only need to depend on the interface, not the simulator. ifdef RTTOV COSP_OBJS += cosp_rttov_interface_v13.o cosp_rttov_v13.o else diff --git a/build/Makefile.rttov b/build/Makefile.rttov new file mode 100644 index 0000000000..36c1e7b9d6 --- /dev/null +++ b/build/Makefile.rttov @@ -0,0 +1,84 @@ +# Makefile specifics for linking with RTTOV. +# From src/test/Makefile_examples +# ----------------------------------------------------------------------------- + +# You must update the following variables below according to the local RTTOV installation and compiler + +# RTTOV_VERSION RTTOV version number +# RTTOVDIR root directory for RTTOV binaries, libraries, modules, includes + +# FC compiler command name +# FFLAGS compiler specific flags: -I$(RTTOVDIR)/mod -I$(RTTOVDIR)/include are mandatory +# LDFLAGS_ARCH flags for linker + +# BINDIR directory to store the binary file + +# If RTTOV was compiled against the HDF5 or external LAPACK libraries this is +# handled automatically using the contents of Makefile.local. + +# ----------------------------------------------------------------------------- + + +# RTTOVDIR=../../ +RTTOVDIR=/glade/u/home/jonahshaw/w/RTTOV + +FC=gfortran +FFLAGS= -I$(RTTOVDIR)/mod -I$(RTTOVDIR)/include -fPIC -O3 -fopenmp -ffree-line-length-none +LDFLAGS_ARCH=-fopenmp + + +RTTOV_VERSION=13 +EXT_BIN=.exe +EXT_OBJ=.o +EXT_LIB=.a +OBJDIR=$(RTTOVDIR)/obj +BINDIR=$(RTTOVDIR)/bin + + +#### Do not edit beyond this line #### + +# JKS - should this be $(RTTOVDIR)/build/Makefile.local ? +# include ../../build/Makefile.local +include $(RTTOVDIR)/build/Makefile.local + +LIBDIR=$(RTTOVDIR)/lib + +ifdef LDFLAGS_HDF5 + LIBS=\ + $(LIBDIR)/librttov$(RTTOV_VERSION)_brdf_atlas$(EXT_LIB) \ + $(LIBDIR)/librttov$(RTTOV_VERSION)_emis_atlas$(EXT_LIB) \ + $(LIBDIR)/librttov$(RTTOV_VERSION)_mw_scatt$(EXT_LIB) \ + $(LIBDIR)/librttov$(RTTOV_VERSION)_other$(EXT_LIB) \ + $(LIBDIR)/librttov$(RTTOV_VERSION)_coef_io$(EXT_LIB) \ + $(LIBDIR)/librttov$(RTTOV_VERSION)_hdf$(EXT_LIB) \ + $(LIBDIR)/librttov$(RTTOV_VERSION)_parallel$(EXT_LIB) \ + $(LIBDIR)/librttov$(RTTOV_VERSION)_main$(EXT_LIB) + + LLIBS=-L$(LIBDIR) \ + -lrttov$(RTTOV_VERSION)_brdf_atlas \ + -lrttov$(RTTOV_VERSION)_emis_atlas \ + -lrttov$(RTTOV_VERSION)_mw_scatt \ + -lrttov$(RTTOV_VERSION)_other \ + -lrttov$(RTTOV_VERSION)_coef_io \ + -lrttov$(RTTOV_VERSION)_hdf \ + -lrttov$(RTTOV_VERSION)_parallel \ + -lrttov$(RTTOV_VERSION)_main +else + LIBS=\ + $(LIBDIR)/librttov$(RTTOV_VERSION)_brdf_atlas$(EXT_LIB) \ + $(LIBDIR)/librttov$(RTTOV_VERSION)_emis_atlas$(EXT_LIB) \ + $(LIBDIR)/librttov$(RTTOV_VERSION)_mw_scatt$(EXT_LIB) \ + $(LIBDIR)/librttov$(RTTOV_VERSION)_other$(EXT_LIB) \ + $(LIBDIR)/librttov$(RTTOV_VERSION)_coef_io$(EXT_LIB) \ + $(LIBDIR)/librttov$(RTTOV_VERSION)_parallel$(EXT_LIB) \ + $(LIBDIR)/librttov$(RTTOV_VERSION)_main$(EXT_LIB) + + LLIBS=-L$(LIBDIR) \ + -lrttov$(RTTOV_VERSION)_brdf_atlas \ + -lrttov$(RTTOV_VERSION)_emis_atlas \ + -lrttov$(RTTOV_VERSION)_mw_scatt \ + -lrttov$(RTTOV_VERSION)_other \ + -lrttov$(RTTOV_VERSION)_coef_io \ + -lrttov$(RTTOV_VERSION)_parallel \ + -lrttov$(RTTOV_VERSION)_main +endif \ No newline at end of file From 43868e1667671af1b12ed82ec3fa8920492092a2 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 7 Mar 2023 14:51:37 -0700 Subject: [PATCH 028/159] Compiling with RTTOV. Makefile cleaned up. Build time is very moderate. ~2 minutes. --- build/Makefile | 98 +++----------------------------------------------- 1 file changed, 5 insertions(+), 93 deletions(-) diff --git a/build/Makefile b/build/Makefile index 9c3a7d24d2..40bcc8ab7c 100644 --- a/build/Makefile +++ b/build/Makefile @@ -10,19 +10,9 @@ MISR_PATH = $(SIM_PATH)/MISR_simulator MODIS_PATH = $(SIM_PATH)/MODIS_simulator PARASOL_PATH = $(SIM_PATH)/parasol -# RTTOV variables. You may need to change this. JKS -# RTTOV_PATH = /glade/u/home/jonahshaw/w/RTTOV -# RTTOV_LIB_PATH = $(RTTOV_PATH)/lib -# RTTOV_INC_PATH = $(RTTOV_PATH)/include -# RTTOV_MOD_PATH = $(RTTOV_PATH)/mod - -# Makefile.rttov needs to define: RTTOVDIR, FFLAGS, LIBDIR, LIBS, LLIBS +# Makefile.rttov needed to define the following: +# RTTOVDIR, FFLAGS, LIBDIR, LIBS, LLIBS, LDFLAGS_NETCDF, LDFLAGS_HDF5, LDFLAGS_ARCH include Makefile.rttov -# RTTOV_LIB_PATH = $(RTTOVDIR)/lib # JKS - this became LIBDIR in Makefile.rttov -# RTTOV_INC_PATH = $(RTTOVDIR)/include # JKS - this gets folded into FFLAGS -# RTTOV_MOD_PATH = $(RTTOVDIR)/mod # JKS - this gets folded into FFLAGS - - VPATH = $(SRC_PATH):$(HOOKS):$(SIM_PATH):$(RT_PATH):$(RS_PATH):$(CS_PATH):$(ISCCP_PATH):$(MISR_PATH):$(MODIS_PATH):$(PARASOL_PATH) @@ -41,15 +31,11 @@ LDFLAGS += $(NC_LIB) -lnetcdff LDFLAGS += -L. -lcosp -lsubcol +# Need additional load flags from Makefile.rttov when linking to RTTOV ifdef RTTOV -# LDFLAGS += -L${RTTOV_LIB_PATH} -lrttov13 -#LDFLAGS += -L${RTTOV_LIB_PATH} -lrttov_main -#LDFLAGS += -L${LIBDIR} -lrttov_main -#LDFLAGS += $(LIBS) $(LLIBS) LDFLAGS += $(LIBS) $(LLIBS) $(LDFLAGS_NETCDF) $(LDFLAGS_HDF5) $(LDFLAGS_ARCH) $(LDFLAGS_LAPACK) endif - # Rules %.o: %.F90 $(F90) $(F90FLAGS) -c $< @@ -59,18 +45,13 @@ endif %: %.o $(F90) $(F90FLAGS) -o $@ $^ $(LDFLAGS) -# $(F90) $(F90FLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) - -# Special rule for the RTTOV file. Had an ifdef line but it wasn't necessary. -# JKS is this needed because of the load_coefficient calls? Can I remove this by restructuring? +# Special rules for the RTTOV files. cosp_rttov_interface_v13.o : cosp_rttov_interface_v13.F90 $(F90) $(F90FLAGS) $(FFLAGS) -c $< -# $(F90) $(F90FLAGS) -c -I $(RTTOV_INC_PATH) -I $(RTTOV_MOD_PATH) $< cosp_rttov_v13.o : cosp_rttov_v13.F90 $(F90) $(F90FLAGS) $(FFLAGS) -c $< -# $(F90) $(F90FLAGS) -c -I $(RTTOV_INC_PATH) -I $(RTTOV_MOD_PATH) $< # # The COSP library @@ -119,7 +100,7 @@ cosp.o : cosp_kinds.o cosp_modis_interface.o cosp_constants.o quickbeam.o MISR_simulator.o lidar_simulator.o \ parasol.o icarus.o cosp_grLidar532_interface.o cosp_atlid_interface.o -# Conditionally add dependencies on the Stub or actual RTTOV simulator. +# Conditionally add dependencies on the STUB or actual RTTOV simulator. ifdef RTTOV cosp.o: cosp_rttov_interface_v13.o cosp_rttov_v13.o else @@ -174,72 +155,3 @@ mo_rng.o : cosp_kinds.o cosp2_io.o : cosp_kinds.o cosp_config.o cosp.o cosp2_test.o : cosp2_io.o libcosp.a libsubcol.a cosp2_test : cosp2_test.o cosp2_io.o - - -############### -### OLD -############### - -# Offline driver with RTTOV is just adding the COSP-RTTOV file and the RTTOV library. -#cosp2_rttov_test : cosp2_test.o cosp2_io.o cosp_rttov_v13.o - - -# OLD Offline driver with RTTOV -#cosp2_rttov_io.o : cosp_kinds.o cosp_config.o cosp_rttov.o -#cosp2_rttov_test.o : cosp2_rttov_io.o libcosp_rttov.a libsubcol_rttov.a -#cosp2_rttov_test : cosp2_rttov_test.o cosp2_rttov_io.o - - -# Dependencies for COSP-RTTOV libary -#cosp_rttov.o : cosp_kinds.o cosp_modis_interface.o cosp_constants.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_rttov_v13.o \ -# cosp_rttov_interface_v13.o quickbeam.o MISR_simulator.o lidar_simulator.o \ -# parasol.o icarus.o cosp_grLidar532_interface.o cosp_atlid_interface.o - - -### Library for COSP-RTTOV build -#COSP_RTTOV_OBJS = cosp.o cosp_config.o cosp_stats.o cosp_constants.o cosp_errorHandling.o cosp_kinds.o \ -# cosp_isccp_interface.o icarus.o cosp_misr_interface.o MISR_simulator.o \ -# cosp_modis_interface.o modis_simulator.o cosp_parasol_interface.o parasol.o \ -# cosp_calipso_interface.o lidar_simulator.o cosp_cloudsat_interface.o quickbeam.o \ -# cosp_rttov_interface_v13.o cosp_rttov_v13.o cosp_grLidar532_interface.o cosp_atlid_interface.o - -#LIBRARY_RTTOV = libcosp_rttov.a - -#$(LIBRARY_RTTOV): $(COSP_RTTOV_OBJS) -# ar -rvs $(LIBRARY_RTTOV) $(COSP_RTTOV_OBJS) - - -# Is this right? -#libsubcol_rttov.a: $(SUBCOL_OBJS) libcosp_rttov.a -# ar -rvs libsubcol_rttov.a $(SUBCOL_OBJS) - -# Will need to be updated. Conditionally removed rttov_interface dependence on cosp_rttov_v13 -#cosp_rttov_interface_v13.o : cosp_kinds.o cosp_config.o - -#ifdef RTTOV -#cosp_rttov_interface_v13.o : cosp_kinds.o cosp_config.o cosp_rttov_v13.o -#else -#cosp_rttov_interface_v13.o : cosp_kinds.o cosp_config.o cosp_rttovSTUB.o -#endif - -#cosp_rttov_interface_v13.o : cosp_kinds.o cosp_config.o cosp_rttov_v13.o -#cosp_rttov_v13.o : cosp_kinds.o cosp_config.o cosp_constants.o - -#ifdef RTTOV -#COSP_OBJS = cosp.o cosp_config.o cosp_stats.o cosp_constants.o cosp_errorHandling.o cosp_kinds.o \ -# cosp_isccp_interface.o icarus.o cosp_misr_interface.o MISR_simulator.o \ -# cosp_modis_interface.o modis_simulator.o cosp_parasol_interface.o parasol.o \ -# cosp_calipso_interface.o lidar_simulator.o cosp_cloudsat_interface.o quickbeam.o \ -# cosp_grLidar532_interface.o cosp_atlid_interface.o \ -# cosp_rttov_interface_v13.o cosp_rttov_v13.o -#else -#COSP_OBJS = cosp.o cosp_config.o cosp_stats.o cosp_constants.o cosp_errorHandling.o cosp_kinds.o \ -# cosp_isccp_interface.o icarus.o cosp_misr_interface.o MISR_simulator.o \ -# cosp_modis_interface.o modis_simulator.o cosp_parasol_interface.o parasol.o \ -# cosp_calipso_interface.o lidar_simulator.o cosp_cloudsat_interface.o quickbeam.o \ -# cosp_grLidar532_interface.o cosp_atlid_interface.o \ -# cosp_rttov_interfaceSTUB.o cosp_rttovSTUB.o -#endif \ No newline at end of file From 95e3f593fb95b38d14335acd7ee0be2cecdc414c Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Thu, 9 Mar 2023 11:17:26 -0700 Subject: [PATCH 029/159] Add RTTOV input and output namelist options. --- driver/run/cosp2_input_rttov_nl.txt | 5 ++++- driver/run/cosp2_output_rttov_nl.txt | 6 +++++- driver/src/cosp2_test.F90 | 29 +++++++++++++++++++++------- src/cosp_config.F90 | 4 +++- 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/driver/run/cosp2_input_rttov_nl.txt b/driver/run/cosp2_input_rttov_nl.txt index 3b3d6319ac..b3b65d30f0 100644 --- a/driver/run/cosp2_input_rttov_nl.txt +++ b/driver/run/cosp2_input_rttov_nl.txt @@ -92,5 +92,8 @@ CO2=5.241e-04, ! Mixing ratios of trace gases CH4=9.139e-07, N2O=4.665e-07, - CO=2.098e-07 + CO=2.098e-07, + rttov_Nlocaltime=2, + rttov_localtime=10.0,13.0, ! To implement local time + rttov_localtimewindow=1.0,1.0 ! To implement local time width / diff --git a/driver/run/cosp2_output_rttov_nl.txt b/driver/run/cosp2_output_rttov_nl.txt index e9a4f7c8b1..01b3a718b8 100755 --- a/driver/run/cosp2_output_rttov_nl.txt +++ b/driver/run/cosp2_output_rttov_nl.txt @@ -133,7 +133,11 @@ Liwpmodis=.true., Lclmodis=.true., !- RTTOV - Ltbrttov=.true., + Ltbrttov=.false., + Lrttov_cld=.false., + Lrttov_aer=.true., + Lrttov_rad=.false., + Lrttov_localtime=.true., ! -CLOUDSAT precipitation frequency/occurence diagnostics Lptradarflag0=.true., Lptradarflag1=.true., diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 0b77b3b151..42e1ce22bf 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -52,7 +52,8 @@ program cosp2_test tau_binBoundsV1p4,tau_binEdgesV1p4, tau_binCentersV1p4, & grLidar532_histBsct,atlid_histBsct,vgrid_zu,vgrid_zl, & Nlvgrid_local => Nlvgrid, & - vgrid_z,cloudsat_preclvl + vgrid_z,cloudsat_preclvl, & + RTTOV_MAX_LOCALTIMES use cosp_phys_constants, only: amw,amd,amO3,amCO2,amCH4,amN2O,amCO use mod_cosp_io, only: nc_read_input_file,write_cosp2_output USE mod_quickbeam_optics,only: size_distribution,hydro_class_init,quickbeam_optics, & @@ -136,7 +137,8 @@ program cosp2_test rttov_platform, & ! RTTOV: Satellite platform rttov_satellite, & ! RTTOV: Satellite rttov_instrument, & ! RTTOV: Instrument - rttov_Nchannels ! RTTOV: Number of channels to be computed + rttov_Nchannels, & ! RTTOV: Number of channels to be computed + rttov_Nlocaltime ! RTTOV: Number of local times to be computed real(wp) :: & ! cloudsat_radar_freq, & ! CloudSat radar frequency (GHz) cloudsat_k2, & ! |K|^2, -1=use frequency dependent default @@ -150,11 +152,13 @@ program cosp2_test csat_vgrid, & ! CloudSat vertical grid? use_precipitation_fluxes ! True if precipitation fluxes are input to the ! algorithm - integer,dimension(RTTOV_MAX_CHANNELS) :: & rttov_Channels ! RTTOV: Channel numbers real(wp),dimension(RTTOV_MAX_CHANNELS) :: & rttov_Surfem ! RTTOV: Surface emissivity + real(wp),dimension(RTTOV_MAX_LOCALTIMES) :: & ! JKS This is not allowed in a main program + rttov_localtime, & ! RTTOV subsetting by local time in hours [0,24] + rttov_localtimewindow ! Width of local time window (hrs). character(len=64) :: & cloudsat_micro_scheme ! Microphysical scheme used in cloudsat radar simulator character(len=64) :: & @@ -164,13 +168,14 @@ program cosp2_test character(len=512) :: & dinput ! Directory where the input files are located character(len=600) :: & - fileIN ! dinput+finput + fileIN ! dinput+finput namelist/COSP_INPUT/overlap, isccp_topheight, isccp_topheight_direction, npoints, & npoints_it, ncolumns, nlevels, use_vgrid, Nlvgrid, csat_vgrid, dinput, finput, & foutput, cloudsat_radar_freq, surface_radar, cloudsat_use_gas_abs,cloudsat_do_ray,& cloudsat_k2, cloudsat_micro_scheme, lidar_ice_type, use_precipitation_fluxes, & rttov_platform, rttov_satellite, rttov_Instrument, rttov_Nchannels, & - rttov_Channels, rttov_Surfem, rttov_ZenAng, co2, ch4, n2o, co + rttov_Channels, rttov_Surfem, rttov_ZenAng, co2, ch4, n2o, co, & + rttov_Nlocaltime, rttov_localtime, rttov_localtimewindow !JKS ! Output namelist logical :: Lcfaddbze94,Ldbze94,Latb532,LcfadLidarsr532,Lclcalipso,Lclhcalipso, & @@ -194,7 +199,8 @@ program cosp2_test Lclmodis,Ltbrttov,Lptradarflag0,Lptradarflag1,Lptradarflag2,Lptradarflag3, & Lptradarflag4,Lptradarflag5,Lptradarflag6,Lptradarflag7,Lptradarflag8, & Lptradarflag9,Lradarpia, & - Lwr_occfreq, Lcfodd + Lwr_occfreq, Lcfodd, & + Lrttov_cld, Lrttov_aer, Lrttov_rad, Lrttov_localtime namelist/COSP_OUTPUT/Lcfaddbze94,Ldbze94,Latb532,LcfadLidarsr532,Lclcalipso, & Lclhcalipso,Lcllcalipso,Lclmcalipso,Lcltcalipso,LparasolRefl, & Lclcalipsoliq,Lclcalipsoice,Lclcalipsoun,Lclcalipsotmp, & @@ -220,7 +226,8 @@ program cosp2_test Lptradarflag0,Lptradarflag1,Lptradarflag2,Lptradarflag3, & Lptradarflag4,Lptradarflag5,Lptradarflag6,Lptradarflag7, & Lptradarflag8,Lptradarflag9,Lradarpia, & - Lwr_occfreq, Lcfodd + Lwr_occfreq, Lcfodd, & + Lrttov_cld, Lrttov_aer, Lrttov_rad, Lrttov_localtime ! JKS ! Local variables logical :: & @@ -528,6 +535,14 @@ program cosp2_test call cpu_time(driver_time(8)) print*,'Time to write to output: ',driver_time(8)-driver_time(7) + + ! JKS test new namelist options + print*,'rttov_localtime: ',rttov_localtime + print*,'rttov_localtimewindow: ',rttov_localtimewindow + print*,'Lrttov_cld: ',Lrttov_cld + print*,'Lrttov_aer: ',Lrttov_aer + print*,'Lrttov_rad: ',Lrttov_rad + print*,'Lrttov_localtime: ',Lrttov_localtime !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Free up memory diff --git a/src/cosp_config.F90 b/src/cosp_config.F90 index 8e15567d75..b7c27e82ad 100755 --- a/src/cosp_config.F90 +++ b/src/cosp_config.F90 @@ -153,9 +153,11 @@ MODULE MOD_COSP_CONFIG ! Constants used by RTTOV. ! #################################################################################### integer,parameter :: & - RTTOV_MAX_CHANNELS = 20 + RTTOV_MAX_CHANNELS = 20, & + RTTOV_MAX_LOCALTIMES = 8 ! JKS arbitrary character(len=256),parameter :: & rttovDir = '/homedata/rguzman/CALIPSO/RTTOV/rttov_11.3/' +! rttovDir = '/glade/u/home/jonahshaw/w/RTTOV/' ! JKS update or pass in ! #################################################################################### ! Constants used by the PARASOL simulator. ! #################################################################################### From 97319c5c051f37d5cac962cb7dd6482974286732 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Thu, 9 Mar 2023 11:18:09 -0700 Subject: [PATCH 030/159] Remember to deallocate coef memory at end of run. --- src/simulator/cosp_rttov_interface_v13.F90 | 23 ++++++++++------- src/simulator/rttov/cosp_rttov_v13.F90 | 29 ++++++++++++++-------- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index bbd88a7ef5..b92398078f 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -57,8 +57,6 @@ MODULE MOD_COSP_RTTOV_INTERFACE #include "rttov_read_coefs.interface" #include "rttov_user_options_checkinput.interface" #include "rttov_print_opts.interface" - - !-------------------------- ! RTTOV variables/structures !==================== @@ -323,7 +321,7 @@ END SUBROUTINE COSP_RTTOV_INIT !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_simulate - Call subroutines in mod_cosp_rttov to run RTTOV !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN, & ! Inputs + SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup & ! Inputs Tb,error) ! Outputs use mod_cosp_rttov, only: & @@ -335,7 +333,9 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN, & ! Inputs type(rttov_in),intent(in) :: & rttovIN - real(wp),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! + logical,intent(in) :: & + lCleanup ! Flag to determine whether to deallocate RTTOV types + real(wp),intent(inout),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! Tb ! RTTOV brightness temperature. character(len=128) :: & error ! Error messages (only populated if error encountered) @@ -345,11 +345,16 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN, & ! Inputs integer(kind=jpim) :: nthreads ! Parallelization, should become an input ! Run each step for running RTTOV from mod_cosp_rttov - call rttov_allocate(rttovIN) - call rttov_construct_profiles(rttovIN) - call rttov_setup_emissivity_reflectance() - call rttov_call_direct(nthreads) - call rttov_save_and_deallocate(rttovIN,Tb) + call cosp_rttov_allocate(rttovIN) + call cosp_rttov_construct_profiles(rttovIN) + call cosp_rttov_setup_emissivity_reflectance() + call cosp_rttov_call_direct(nthreads) + call cosp_rttov_save_and_deallocate_profiles(rttovIN,Tb) + + ! Deallocate the coefficient files if directed + if (lCleanup) then + call cosp_rttov_deallocate_coefs() + endif END SUBROUTINE COSP_RTTOV_SIMULATE diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 55d6ec49e6..dff31907c0 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -229,7 +229,7 @@ end subroutine rttov_error ! 3. Allocate RTTOV input and output structures ! 4. Build the list of profile/channel indices in chanprof ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine rttov_allocate(rttovIN & + subroutine cosp_rttov_allocate(rttovIN & ) type(rttov_in),intent(in) :: & ! What is the best way to do this? Should rttovIN be a module-wide DDT? Yes. @@ -288,7 +288,7 @@ subroutine rttov_allocate(rttovIN & end do end do - end subroutine rttov_allocate + end subroutine cosp_rttov_allocate ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -296,7 +296,7 @@ end subroutine rttov_allocate ! ------------------------------------------------------ ! Largely from cosp_rttov_v11.F90 file. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine rttov_construct_profiles(rttovIN & + subroutine cosp_rttov_construct_profiles(rttovIN & ) type(rttov_in),intent(in) :: & ! What is the best way to do this? Should rttovIN be a module-wide DDT? Yes. @@ -455,7 +455,7 @@ subroutine rttov_construct_profiles(rttovIN & ! JKS To-do: set up scattering profiles (MW only) (rttov_profile_cloud) - end subroutine rttov_construct_profiles + end subroutine cosp_rttov_construct_profiles ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -463,7 +463,7 @@ end subroutine rttov_construct_profiles ! ------------------------------------------------------ ! From RTTOV example files. Will need to be expanded on to pass in values. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine rttov_setup_emissivity_reflectance() + subroutine cosp_rttov_setup_emissivity_reflectance() ! In this example we have no values for input emissivities or reflectances ! so we initialise all inputs to zero @@ -478,7 +478,7 @@ subroutine rttov_setup_emissivity_reflectance() ! less (all channels in this case) calcrefl(:) = (reflectance(:) % refl_in <= 0._jprb) - end subroutine rttov_setup_emissivity_reflectance + end subroutine cosp_rttov_setup_emissivity_reflectance ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -486,7 +486,7 @@ end subroutine rttov_setup_emissivity_reflectance ! ------------------------------------------------------ ! From RTTOV example files. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine rttov_call_direct(nthreads) + subroutine cosp_rttov_call_direct(nthreads) integer(kind=jpim) :: nthreads @@ -522,14 +522,14 @@ subroutine rttov_call_direct(nthreads) endif call rttov_error('rttov_direct error', lalloc = .true.) - end subroutine rttov_call_direct + end subroutine cosp_rttov_call_direct ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! rttov_save_and_deallocate - 8. Save output data, 9. Deallocate all RTTOV arrays and structures ! ------------------------------------------------------ ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine rttov_save_and_deallocate(rttovIN,Tb) + subroutine cosp_rttov_save_and_deallocate_profiles(rttovIN,Tb) type(rttov_in),intent(in) :: & rttovIN @@ -580,7 +580,16 @@ subroutine rttov_save_and_deallocate(rttovIN,Tb) call rttov_dealloc_coefs(errorstatus, coef_rttov) call rttov_error('coefs deallocation error', lalloc = .true.) - end subroutine rttov_save_and_deallocate + end subroutine cosp_rttov_save_and_deallocate_profiles + + subroutine cosp_rttov_deallocate_coefs() + + call rttov_dealloc_coefs(errorstatus, coef_rttov) + if (errorstatus /= errorstatus_success) then + write(*,*) 'coefs deallocation error' + endif + + end subroutine cosp_rttov_deallocate_coefs function construct_rttov_coeffilename(platform,satellite,instrument) From fc0a5ebfa3160236b60dad833481e87b80f470f3 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Mon, 13 Mar 2023 08:46:32 -0600 Subject: [PATCH 031/159] Allow user to specify some RTTOV options from the namelist --- build/Makefile.rttov | 2 + driver/run/cosp2_output_rttov_nl.txt | 6 ++- driver/src/cosp2_test.F90 | 9 ++-- src/cosp.F90 | 12 +++-- src/simulator/cosp_rttov_interfaceSTUB.F90 | 12 ++++- src/simulator/cosp_rttov_interface_v13.F90 | 52 +++++++++++++++------- src/simulator/rttov/cosp_rttov_v13.F90 | 6 +++ 7 files changed, 73 insertions(+), 26 deletions(-) diff --git a/build/Makefile.rttov b/build/Makefile.rttov index 36c1e7b9d6..1e885c7f6b 100644 --- a/build/Makefile.rttov +++ b/build/Makefile.rttov @@ -43,6 +43,8 @@ include $(RTTOVDIR)/build/Makefile.local LIBDIR=$(RTTOVDIR)/lib +# JKS this if statement depends on the contents of Makefile.local +# but it doesn't seem to do anything. ifdef LDFLAGS_HDF5 LIBS=\ $(LIBDIR)/librttov$(RTTOV_VERSION)_brdf_atlas$(EXT_LIB) \ diff --git a/driver/run/cosp2_output_rttov_nl.txt b/driver/run/cosp2_output_rttov_nl.txt index 01b3a718b8..ae204d2127 100755 --- a/driver/run/cosp2_output_rttov_nl.txt +++ b/driver/run/cosp2_output_rttov_nl.txt @@ -135,9 +135,11 @@ !- RTTOV Ltbrttov=.false., Lrttov_cld=.false., - Lrttov_aer=.true., + Lrttov_cldparam=.false., + Lrttov_aer=.false., + Lrttov_aerparam=.false., Lrttov_rad=.false., - Lrttov_localtime=.true., + Lrttov_localtime=.false., ! -CLOUDSAT precipitation frequency/occurence diagnostics Lptradarflag0=.true., Lptradarflag1=.true., diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 42e1ce22bf..88bc68ec5b 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -200,7 +200,8 @@ program cosp2_test Lptradarflag4,Lptradarflag5,Lptradarflag6,Lptradarflag7,Lptradarflag8, & Lptradarflag9,Lradarpia, & Lwr_occfreq, Lcfodd, & - Lrttov_cld, Lrttov_aer, Lrttov_rad, Lrttov_localtime + Lrttov_cld, Lrttov_cldparam, Lrttov_aer, Lrttov_aerparam, & + Lrttov_rad, Lrttov_localtime namelist/COSP_OUTPUT/Lcfaddbze94,Ldbze94,Latb532,LcfadLidarsr532,Lclcalipso, & Lclhcalipso,Lcllcalipso,Lclmcalipso,Lcltcalipso,LparasolRefl, & Lclcalipsoliq,Lclcalipsoice,Lclcalipsoun,Lclcalipsotmp, & @@ -227,7 +228,8 @@ program cosp2_test Lptradarflag4,Lptradarflag5,Lptradarflag6,Lptradarflag7, & Lptradarflag8,Lptradarflag9,Lradarpia, & Lwr_occfreq, Lcfodd, & - Lrttov_cld, Lrttov_aer, Lrttov_rad, Lrttov_localtime ! JKS + Lrttov_cld, Lrttov_cldparam, Lrttov_aer, Lrttov_aerparam, & + Lrttov_rad, Lrttov_localtime ! JKS ! Local variables logical :: & @@ -402,7 +404,8 @@ program cosp2_test cloudsat_do_ray, isccp_topheight, isccp_topheight_direction, surface_radar, & rcfg_cloudsat, use_vgrid, csat_vgrid, Nlvgrid, Nlevels, cloudsat_micro_scheme, & rttov_platform, rttov_satellite, rttov_Instrument, rttov_Nchannels, & ! JKS added RTTOV inputs here - rttov_Channels) + rttov_Channels,Lrttov_cld, Lrttov_aer, Lrttov_rad, Lrttov_cldparam, & + Lrttov_aerparam) call cpu_time(driver_time(3)) !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/cosp.F90 b/src/cosp.F90 index 52663a0ca0..ec5154b3f3 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -1533,7 +1533,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (lrttov_column) then ! JKS new RTTOV subroutine for v13 called from the RTTOV interface. - call cosp_rttov_simulate(rttovIN,cospOUT%rttov_tbs(ij:ik,:),cosp_simulator(nError+1)) + call cosp_rttov_simulate(rttovIN,lrttov_cleanUp,cospOUT%rttov_tbs(ij:ik,:),cosp_simulator(nError+1)) ! JKS building new call ! call rttov_column(rttovIN%nPoints,rttovIN%nLevels,rttovIN%nSubCols,rttovIN%q, & @@ -1784,10 +1784,14 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La cloudsat_radar_freq, cloudsat_k2, cloudsat_use_gas_abs, cloudsat_do_ray, & isccp_top_height, isccp_top_height_direction, surface_radar, rcfg, lusevgrid, & luseCSATvgrid, Nvgrid, Nlevels, cloudsat_micro_scheme, & - NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN) + NchanIN, platformIN, satelliteIN, instrumentIN, channelsIN, & + Lrttov_cld, Lrttov_aer, Lrttov_rad, Lrttov_cldparam, Lrttov_aerparam) ! INPUTS logical,intent(in) :: Lisccp,Lmodis,Lmisr,Lcloudsat,Lcalipso,LgrLidar532,Latlid,Lparasol,Lrttov + logical,intent(in) :: Lrttov_cld, Lrttov_aer, Lrttov_rad, Lrttov_cldparam, Lrttov_aerparam + ! JKS to-do +! type(rttov_init_in),intent(in) :: rttov_init_IN integer,intent(in) :: & cloudsat_use_gas_abs, & ! cloudsat_do_ray, & ! @@ -1857,7 +1861,9 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La if (Lisccp) call cosp_isccp_init(isccp_top_height,isccp_top_height_direction) if (Lmodis) call cosp_modis_init() if (Lmisr) call cosp_misr_init() - if (Lrttov) call cosp_rttov_init(NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN,Nlevels) ! JKS arguments must be available + if (Lrttov) call cosp_rttov_init(NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN, & + Nlevels,Lrttov_cld,Lrttov_aer,Lrttov_rad,Lrttov_cldparam, & + Lrttov_aerparam) ! JKS arguments must be available ! if (Lrttov) call cosp_rttov_init() ! JKS arguments must be available if (Lcloudsat) call cosp_cloudsat_init(cloudsat_radar_freq,cloudsat_k2, & diff --git a/src/simulator/cosp_rttov_interfaceSTUB.F90 b/src/simulator/cosp_rttov_interfaceSTUB.F90 index 9919b01d16..b64cbbbc4d 100644 --- a/src/simulator/cosp_rttov_interfaceSTUB.F90 +++ b/src/simulator/cosp_rttov_interfaceSTUB.F90 @@ -41,7 +41,9 @@ MODULE MOD_COSP_RTTOV_INTERFACE !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_init !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN,nlevels) + SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN, & + nlevels,Lrttov_cld,Lrttov_aer,Lrttov_rad,Lrttov_cldparam, & + Lrttov_aerparam) integer,intent(in) :: & NchanIN, & ! Number of channels platformIN, & ! Satellite platform @@ -50,13 +52,19 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI nlevels integer,intent(in),dimension(RTTOV_MAX_CHANNELS) :: & channelsIN ! RTTOV channels + logical,intent(in) :: & + Lrttov_cld, & + Lrttov_aer, & + Lrttov_rad, & + Lrttov_cldparam, & + Lrttov_aerparam END SUBROUTINE COSP_RTTOV_INIT !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_simulate !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN, & ! Inputs + SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, & ! Inputs Tb,error) ! Outputs type(rttov_in),intent(in) :: & diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index b92398078f..83a0278302 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -35,7 +35,8 @@ MODULE MOD_COSP_RTTOV_INTERFACE USE MOD_COSP_CONFIG, ONLY: RTTOV_MAX_CHANNELS,rttovDir use mod_cosp_rttov, only: platform,satellite,sensor,nChannels,iChannel,coef_rttov, & opts,construct_rttov_coeffilename,rttov_in, & - construct_rttov_scatfilename + construct_rttov_scatfilename,do_rttov_cld,do_rttov_aer, & + do_rttov_rad,rttov_cld_optparam,rttov_aer_optparam ! rttov_const contains useful RTTOV constants USE rttov_const, ONLY : & @@ -71,15 +72,23 @@ MODULE MOD_COSP_RTTOV_INTERFACE !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_init !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN,nlevels) + SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN, & + nlevels,Lrttov_cld,Lrttov_aer,Lrttov_rad,Lrttov_cldparam, & + Lrttov_aerparam) integer,intent(in) :: & - NchanIN, & ! Number of channels - platformIN, & ! Satellite platform - satelliteIN, & ! Satellite + NchanIN, & ! Number of channels + platformIN, & ! Satellite platform + satelliteIN, & ! Satellite instrumentIN, & ! Instrument nlevels integer,intent(in),dimension(RTTOV_MAX_CHANNELS) :: & channelsIN ! RTTOV channels + logical,intent(in) :: & + Lrttov_cld, & + Lrttov_aer, & + Lrttov_rad, & + Lrttov_cldparam, & + Lrttov_aerparam ! Local variables character(len=256) :: & @@ -100,6 +109,13 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI satellite = satelliteIN sensor = instrumentIN iChannel = channelsIN + + ! Logicals for RTTOV options + do_rttov_cld = Lrttov_cld + do_rttov_aer = Lrttov_aer + do_rttov_rad = Lrttov_rad ! to be used in output + rttov_cld_optparam = Lrttov_cldparam + rttov_aer_optparam = Lrttov_aerparam ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 1. Initialise RTTOV options structure @@ -153,10 +169,13 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI opts%rt_ir%do_nlte_correction = .false. opts%rt_ir%solar_sea_brdf_model = 2 opts%rt_ir%ir_sea_emis_model = 2 - opts%rt_ir%addaerosl = .false. - opts%rt_ir%addclouds = .false. - opts%rt_ir%user_aer_opt_param = .false. ! User specifies the aerosol scattering optical parameters - opts%rt_ir%user_cld_opt_param = .false. ! User specifies the cloud scattering optical parameters + + ! User options - JKS + opts%rt_ir%addaerosl = do_rttov_aer + opts%rt_ir%addclouds = do_rttov_cld + opts%rt_ir%user_aer_opt_param = rttov_aer_optparam ! User specifies the aerosol scattering optical parameters + opts%rt_ir%user_cld_opt_param = rttov_cld_optparam ! User specifies the cloud scattering optical parameters + opts%rt_ir%grid_box_avg_cloud = .true. opts%rt_ir%cldcol_threshold = -1._wp opts%rt_ir%cloud_overlap = 1 ! Maximum-random overlap @@ -321,15 +340,16 @@ END SUBROUTINE COSP_RTTOV_INIT !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_simulate - Call subroutines in mod_cosp_rttov to run RTTOV !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup & ! Inputs + SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, & ! Inputs Tb,error) ! Outputs - use mod_cosp_rttov, only: & - rttov_allocate, & - rttov_construct_profiles, & - rttov_setup_emissivity_reflectance, & - rttov_call_direct, & - rttov_save_and_deallocate + use mod_cosp_rttov, only: & + cosp_rttov_allocate, & + cosp_rttov_construct_profiles, & + cosp_rttov_setup_emissivity_reflectance, & + cosp_rttov_call_direct, & + cosp_rttov_save_and_deallocate_profiles, & + cosp_rttov_deallocate_coefs type(rttov_in),intent(in) :: & rttovIN diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index dff31907c0..ed2dbe0d15 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -124,6 +124,12 @@ module mod_cosp_rttov ! RTTOV setup and options (set during initialization) type(rttov_options) :: & opts ! defaults to everything optional switched off + logical :: & + do_rttov_cld, & ! Include clouds in RTTOV calculations + do_rttov_aer, & ! Include aerosols in RTTOV calculations + do_rttov_rad, & ! Return radiances in RTTOV calculations + rttov_cld_optparam, & ! Use user-supplied optical cloud parameters + rttov_aer_optparam ! Use user-supplied optical aerosol parameters ! JKS should this be module-wide? ! type(rttov_IN) :: & From baaa964acf11c8fd45745f13db826a11e0ea436f Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Mon, 13 Mar 2023 13:37:00 -0600 Subject: [PATCH 032/159] Infrastructure for using a rttov_init_in object in place but not in use. --- src/cosp.F90 | 3 +-- src/simulator/cosp_rttov_interfaceSTUB.F90 | 29 +++++++++++++++++++++- src/simulator/cosp_rttov_interface_v13.F90 | 26 +++++++++++++++++++ 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/src/cosp.F90 b/src/cosp.F90 index ec5154b3f3..fb26e734b8 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -52,7 +52,7 @@ MODULE MOD_COSP cloudsat_preclvl,grLidar532_histBsct,atlid_histBsct,& RTTOV_MAX_CHANNELS ! JKS needed for RTTOV to be in cosp_optical_inputs USE MOD_COSP_MODIS_INTERFACE, ONLY: cosp_modis_init, modis_IN - USE MOD_COSP_RTTOV_INTERFACE, ONLY: cosp_rttov_init, cosp_rttov_simulate + USE MOD_COSP_RTTOV_INTERFACE, ONLY: cosp_rttov_init, rttov_init_IN, cosp_rttov_simulate ! JKS USE MOD_COSP_MISR_INTERFACE, ONLY: cosp_misr_init, misr_IN USE MOD_COSP_ISCCP_INTERFACE, ONLY: cosp_isccp_init, isccp_IN USE MOD_COSP_CALIPSO_INTERFACE, ONLY: cosp_calipso_init, calipso_IN @@ -1864,7 +1864,6 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La if (Lrttov) call cosp_rttov_init(NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN, & Nlevels,Lrttov_cld,Lrttov_aer,Lrttov_rad,Lrttov_cldparam, & Lrttov_aerparam) ! JKS arguments must be available -! if (Lrttov) call cosp_rttov_init() ! JKS arguments must be available if (Lcloudsat) call cosp_cloudsat_init(cloudsat_radar_freq,cloudsat_k2, & cloudsat_use_gas_abs,cloudsat_do_ray,R_UNDEF,N_HYDRO, surface_radar, & diff --git a/src/simulator/cosp_rttov_interfaceSTUB.F90 b/src/simulator/cosp_rttov_interfaceSTUB.F90 index b64cbbbc4d..813d248592 100644 --- a/src/simulator/cosp_rttov_interfaceSTUB.F90 +++ b/src/simulator/cosp_rttov_interfaceSTUB.F90 @@ -36,6 +36,32 @@ MODULE MOD_COSP_RTTOV_INTERFACE USE MOD_COSP_RTTOV, ONLY: rttov_IN IMPLICIT NONE + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! TYPE rttov_init_IN (RTTOV init DDT to be passed to cosp_init) + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +! I may remove this because it will require an additional dependency between +! cosp2_test and the RTTOV interface. + +! Integers: NchanIN, platformIN, satelliteIN, instrumentIN, channelsIN, & +! Logicals: Lrttov_cld, Lrttov_aer, Lrttov_rad, Lrttov_cldparam, Lrttov_aerparam + + type rttov_init_IN + logical,pointer :: & + Lrttov_cld, & + Lrttov_aer, & + Lrttov_rad, & + Lrttov_cldparam, & + Lrttov_aerparam + integer,pointer :: & + NchanIN, & ! Number of spectral channels to simulate + platformIN, & ! Index of the platform + satelliteIN, & ! Index of the satellite + instrumentIN ! Index of the instrument + integer,dimension(RTTOV_MAX_CHANNELS) :: & + channelsIN ! Indices of spectral channels + end type rttov_init_IN + CONTAINS !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -60,7 +86,6 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI Lrttov_aerparam END SUBROUTINE COSP_RTTOV_INIT - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_simulate !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -69,6 +94,8 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, & ! Inputs type(rttov_in),intent(in) :: & rttovIN + logical,intent(in) :: & + lCleanup ! Flag to determine whether to deallocate RTTOV types real(wp),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! Tb ! RTTOV brightness temperature. character(len=128) :: & diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 83a0278302..6966858200 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -67,6 +67,32 @@ MODULE MOD_COSP_RTTOV_INTERFACE INTEGER(KIND=jpim) :: alloc_status(60) + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! TYPE rttov_init_IN (RTTOV init DDT to be passed to cosp_init) + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +! I may remove this because it will require an additional dependency between +! cosp2_test and the RTTOV interface. + +! Integers: NchanIN, platformIN, satelliteIN, instrumentIN, channelsIN, & +! Logicals: Lrttov_cld, Lrttov_aer, Lrttov_rad, Lrttov_cldparam, Lrttov_aerparam + + type rttov_init_IN + logical,pointer :: & + Lrttov_cld, & + Lrttov_aer, & + Lrttov_rad, & + Lrttov_cldparam, & + Lrttov_aerparam + integer,pointer :: & + NchanIN, & ! Number of spectral channels to simulate + platformIN, & ! Index of the platform + satelliteIN, & ! Index of the satellite + instrumentIN ! Index of the instrument + integer,dimension(RTTOV_MAX_CHANNELS) :: & + channelsIN ! Indices of spectral channels + end type rttov_init_IN + CONTAINS !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From c5b73b9c09dfbb57fcbb981f99c44c3e3c061c97 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Mon, 13 Mar 2023 14:01:10 -0600 Subject: [PATCH 033/159] print statements for RTTOV runtime added, not tested --- src/cosp.F90 | 46 +++++++--------------- src/simulator/cosp_rttov_interface_v13.F90 | 20 +++++++++- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/src/cosp.F90 b/src/cosp.F90 index fb26e734b8..534baa57b5 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -373,6 +373,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ok_lidar_cfad_grLidar532 = .false., & ok_lidar_cfad_atlid = .false., & lrttov_cleanUp = .false. + real(wp),dimension(10) :: driver_time integer, dimension(:,:),allocatable :: & modisRetrievedPhase,isccpLEVMATCH @@ -1530,39 +1531,14 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) endif ! RTTOV - if (lrttov_column) then + if (Lrttov_column) then ! JKS new RTTOV subroutine for v13 called from the RTTOV interface. - call cosp_rttov_simulate(rttovIN,lrttov_cleanUp,cospOUT%rttov_tbs(ij:ik,:),cosp_simulator(nError+1)) - -! JKS building new call -! call rttov_column(rttovIN%nPoints,rttovIN%nLevels,rttovIN%nSubCols,rttovIN%q, & -! rttovIN%p,rttovIN%t,rttovIN%o3,rttovIN%ph,rttovIN%h_surf, & -! rttovIN%u_surf,rttovIN%v_surf,rttovIN%p_surf,rttovIN%t_skin, & -! rttovIN%t2m,rttovIN%q2m,rttovIN%lsmask,rttovIN%longitude, & -! rttovIN%latitude,rttovIN%seaice,rttovIN%co2,rttovIN%ch4, & -! rttovIN%n2o,rttovIN%co,rttovIN%zenang,lrttov_cleanUp, & -! cospOUT%rttov_tbs(ij:ik,:),cosp_simulator(nError+1), & -! ! Optional arguments for surface emissivity calculation -! month=rttovIN%month) -! ! Optional arguments to rttov for all-sky calculation -! ! rttovIN%month, rttovIN%tca,rttovIN%cldIce,rttovIN%cldLiq, & -! ! rttovIN%fl_rain,rttovIN%fl_snow) - -! call rttov_simulate(rttovIN%nPoints,rttovIN%nLevels,rttovIN%nSubCols,rttovIN%q, & -! rttovIN%p,rttovIN%t,rttovIN%o3,rttovIN%ph,rttovIN%h_surf, & -! rttovIN%u_surf,rttovIN%v_surf,rttovIN%p_surf,rttovIN%t_skin, & -! rttovIN%t2m,rttovIN%q2m,rttovIN%lsmask,rttovIN%longitude, & -! rttovIN%latitude,rttovIN%seaice,rttovIN%co2,rttovIN%ch4, & -! rttovIN%n2o,rttovIN%co,rttovIN%zenang,lrttov_cleanUp, & -!! Previously optional emissivity arguments -! rttovIN%surfem,rttovIN%month, & -!! Previously optional cloud arguments -! rttovIN%tca,rttovIN%cldIce,rttovIN%cldLiq, & -! rttovIN%fl_rain,rttovIN%fl_snow, & -!! Outputs -! cospOUT%rttov_tbs(ij:ik,:),cosp_simulator(nError+1)) - + call cpu_time(driver_time(3)) + call cosp_rttov_simulate(rttovIN,Lrttov_cleanUp,cospOUT%rttov_tbs(ij:ik,:),cosp_simulator(nError+1)) + call cpu_time(driver_time(4)) + print*,'Time to run RTTOV: ',driver_time(4)-driver_time(3) + endif !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1815,6 +1791,7 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La ! vertical grid character(len=64),intent(in) :: & cloudsat_micro_scheme ! Microphysical scheme used by CLOUDSAT + real(wp),dimension(10) :: driver_time ! OUTPUTS type(radar_cfg) :: rcfg @@ -1861,9 +1838,16 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La if (Lisccp) call cosp_isccp_init(isccp_top_height,isccp_top_height_direction) if (Lmodis) call cosp_modis_init() if (Lmisr) call cosp_misr_init() + + ! Could print diagnostic on timing here. + call cpu_time(driver_time(1)) if (Lrttov) call cosp_rttov_init(NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN, & Nlevels,Lrttov_cld,Lrttov_aer,Lrttov_rad,Lrttov_cldparam, & Lrttov_aerparam) ! JKS arguments must be available + call cpu_time(driver_time(2)) + if (Lrttov) then + print*,'Time to run cosp_rttov_init: ',driver_time(2)-driver_time(1) + endif if (Lcloudsat) call cosp_cloudsat_init(cloudsat_radar_freq,cloudsat_k2, & cloudsat_use_gas_abs,cloudsat_do_ray,R_UNDEF,N_HYDRO, surface_radar, & diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 6966858200..b51aa08650 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -389,19 +389,37 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, & ! Inputs rttov_simulate_cld, & rttov_simulate_aer integer(kind=jpim) :: nthreads ! Parallelization, should become an input + real(wp),dimension(10) :: driver_time - ! Run each step for running RTTOV from mod_cosp_rttov + ! Run each step for running RTTOV from mod_cosp_rttov (and time them) + call cpu_time(driver_time(1)) call cosp_rttov_allocate(rttovIN) + call cpu_time(driver_time(2)) call cosp_rttov_construct_profiles(rttovIN) + call cpu_time(driver_time(3)) call cosp_rttov_setup_emissivity_reflectance() + call cpu_time(driver_time(4)) call cosp_rttov_call_direct(nthreads) + call cpu_time(driver_time(5)) call cosp_rttov_save_and_deallocate_profiles(rttovIN,Tb) + call cpu_time(driver_time(6)) + + print*,'Time to run "cosp_rttov_allocate": ', driver_time(2)-driver_time(1) + print*,'Time to run "cosp_rttov_construct_profiles": ', driver_time(3)-driver_time(2) + print*,'Time to run "cosp_rttov_setup_emissivity_reflectance": ',driver_time(4)-driver_time(3) + print*,'Time to run "cosp_rttov_call_direct": ', driver_time(5)-driver_time(4) + print*,'Time to run "cosp_rttov_save_and_deallocate_profiles": ',driver_time(6)-driver_time(5) ! Deallocate the coefficient files if directed if (lCleanup) then + call cpu_time(driver_time(7)) call cosp_rttov_deallocate_coefs() + call cpu_time(driver_time(8)) + print*,'Time to run "cosp_rttov_deallocate_coefs": ',driver_time(8)-driver_time(7) endif + print*,'Total RTTOV run time: ',driver_time(8)-driver_time(1) + END SUBROUTINE COSP_RTTOV_SIMULATE ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From 69fd86ca1a69e76ec72a33bf87b9adc59766616d Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 14 Mar 2023 15:55:11 -0600 Subject: [PATCH 034/159] Added infrastructure for passing an RTTOV namelist filename into cosp_rttov_init --- driver/run/cosp2_output_rttov_nl.txt | 2 +- driver/run/cosp2_rttov_nl.txt | 60 ++++++++++++++++++ driver/src/cosp2_test.F90 | 20 ++++-- src/cosp.F90 | 26 ++++++-- src/cosp_config.F90 | 4 +- src/simulator/cosp_rttov_interfaceSTUB.F90 | 7 ++- src/simulator/cosp_rttov_interface_v13.F90 | 72 +++++++++++++++++----- 7 files changed, 159 insertions(+), 32 deletions(-) create mode 100644 driver/run/cosp2_rttov_nl.txt diff --git a/driver/run/cosp2_output_rttov_nl.txt b/driver/run/cosp2_output_rttov_nl.txt index ae204d2127..6a25e907e7 100755 --- a/driver/run/cosp2_output_rttov_nl.txt +++ b/driver/run/cosp2_output_rttov_nl.txt @@ -133,7 +133,7 @@ Liwpmodis=.true., Lclmodis=.true., !- RTTOV - Ltbrttov=.false., + Ltbrttov=.true., Lrttov_cld=.false., Lrttov_cldparam=.false., Lrttov_aer=.false., diff --git a/driver/run/cosp2_rttov_nl.txt b/driver/run/cosp2_rttov_nl.txt new file mode 100644 index 0000000000..cbdeca3bbf --- /dev/null +++ b/driver/run/cosp2_rttov_nl.txt @@ -0,0 +1,60 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- RTTOV Outputs + Ltbrttov=.true., + Lrttov_cld=.false., + Lrttov_cldparam=.false., + Lrttov_aer=.false., + Lrttov_aerparam=.false., + Lrttov_rad=.false., + Lrttov_localtime=.false., + !-------------- RTTOV Coefficient Paths + OD_coef_file='test1', + aer_coef_file='test2', + cld_coef_file='test3', + OD_coef_filepath='test4', + aer_coef_filepath='test5', + cld_coef_filepath='test6', + !---------------------------------------------------------------------------------- + !-------------- RTTOV inputs + !---------------------------------------------------------------------------------- + rttov_Platform=1, ! satellite platform + rttov_Satellite=15, ! satellite + rttov_Instrument=5, ! instrument + rttov_Nchannels=3, ! Number of channels to be computed + rttov_Channels=1,2,3, ! Channel numbers (please be sure that you supply Nchannels) + rttov_Surfem=0.0,0.0,0.0, ! Surface emissivity (please be sure that you supply Nchannels) + rttov_ZenAng=50.0, ! Satellite Zenith Angle + CO2=5.241e-04, ! Mixing ratios of trace gases + CH4=9.139e-07, + N2O=4.665e-07, + CO=2.098e-07, + rttov_Nlocaltime=2, + rttov_localtime=10.0,13.0, ! To implement local time + rttov_localtimewindow=1.0,1.0 ! To implement local time width +/ diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 88bc68ec5b..fe53839aa2 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -72,7 +72,7 @@ program cosp2_test implicit none ! Input/Output driver file control - character(len=64) :: cosp_input_namelist + character(len=64) :: cosp_input_namelist,rttov_input_namelist character(len=64) :: cosp_output_namelist = 'cosp2_output_nl.txt' ! Test data @@ -307,7 +307,16 @@ program cosp2_test open(10,file=cosp_output_namelist,status='unknown') read(10,nml=cosp_output) close(10) - + + ! Save the path for the RTTOV input namelist to read later + ! Because cosp2_test is an outer program, rttov_input_name cannot be optional. + ! I use this solution, which isn't great but works. + if (command_argument_count() == 3) then + call get_command_argument(3, rttov_input_namelist) + else + rttov_input_namelist = 'false' + endif + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Read in sample input data. !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -405,7 +414,8 @@ program cosp2_test rcfg_cloudsat, use_vgrid, csat_vgrid, Nlvgrid, Nlevels, cloudsat_micro_scheme, & rttov_platform, rttov_satellite, rttov_Instrument, rttov_Nchannels, & ! JKS added RTTOV inputs here rttov_Channels,Lrttov_cld, Lrttov_aer, Lrttov_rad, Lrttov_cldparam, & - Lrttov_aerparam) + Lrttov_aerparam, & + rttov_input_namelist=rttov_input_namelist) ! options RTTOV argument call cpu_time(driver_time(3)) !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -540,8 +550,8 @@ program cosp2_test print*,'Time to write to output: ',driver_time(8)-driver_time(7) ! JKS test new namelist options - print*,'rttov_localtime: ',rttov_localtime - print*,'rttov_localtimewindow: ',rttov_localtimewindow +! print*,'rttov_localtime: ',rttov_localtime +! print*,'rttov_localtimewindow: ',rttov_localtimewindow print*,'Lrttov_cld: ',Lrttov_cld print*,'Lrttov_aer: ',Lrttov_aer print*,'Lrttov_rad: ',Lrttov_rad diff --git a/src/cosp.F90 b/src/cosp.F90 index 534baa57b5..c323b3973a 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -1761,7 +1761,8 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La isccp_top_height, isccp_top_height_direction, surface_radar, rcfg, lusevgrid, & luseCSATvgrid, Nvgrid, Nlevels, cloudsat_micro_scheme, & NchanIN, platformIN, satelliteIN, instrumentIN, channelsIN, & - Lrttov_cld, Lrttov_aer, Lrttov_rad, Lrttov_cldparam, Lrttov_aerparam) + Lrttov_cld, Lrttov_aer, Lrttov_rad, Lrttov_cldparam, Lrttov_aerparam, & + rttov_input_namelist) ! INPUTS logical,intent(in) :: Lisccp,Lmodis,Lmisr,Lcloudsat,Lcalipso,LgrLidar532,Latlid,Lparasol,Lrttov @@ -1792,7 +1793,10 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La character(len=64),intent(in) :: & cloudsat_micro_scheme ! Microphysical scheme used by CLOUDSAT real(wp),dimension(10) :: driver_time - + + ! JKS testing using a RTTOV input namelist here + character(len=64),intent(in),optional :: rttov_input_namelist ! = 'cosp2_rttov_nl.txt' + ! OUTPUTS type(radar_cfg) :: rcfg @@ -1841,11 +1845,21 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La ! Could print diagnostic on timing here. call cpu_time(driver_time(1)) - if (Lrttov) call cosp_rttov_init(NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN, & - Nlevels,Lrttov_cld,Lrttov_aer,Lrttov_rad,Lrttov_cldparam, & - Lrttov_aerparam) ! JKS arguments must be available - call cpu_time(driver_time(2)) if (Lrttov) then + if (rttov_input_namelist=='false') then + print*,'Lrttov is true but no RTTOV namelist is provided. Will not run RTTOV.' + else + call cosp_rttov_init(NchanIN,platformIN,satelliteIN, & + instrumentIN,channelsIN,Nlevels, & + Lrttov_cld,Lrttov_aer, & + Lrttov_rad,Lrttov_cldparam, & + Lrttov_aerparam, & + rttov_input_namelist=rttov_input_namelist) + endif + endif + + call cpu_time(driver_time(2)) + if ((Lrttov) .and. (rttov_input_namelist/='false')) then print*,'Time to run cosp_rttov_init: ',driver_time(2)-driver_time(1) endif diff --git a/src/cosp_config.F90 b/src/cosp_config.F90 index b7c27e82ad..d2b5aae640 100755 --- a/src/cosp_config.F90 +++ b/src/cosp_config.F90 @@ -156,8 +156,8 @@ MODULE MOD_COSP_CONFIG RTTOV_MAX_CHANNELS = 20, & RTTOV_MAX_LOCALTIMES = 8 ! JKS arbitrary character(len=256),parameter :: & - rttovDir = '/homedata/rguzman/CALIPSO/RTTOV/rttov_11.3/' -! rttovDir = '/glade/u/home/jonahshaw/w/RTTOV/' ! JKS update or pass in +! rttovDir = '/homedata/rguzman/CALIPSO/RTTOV/rttov_11.3/' + rttovDir = '/glade/u/home/jonahshaw/w/RTTOV/' ! JKS update or pass in ! #################################################################################### ! Constants used by the PARASOL simulator. ! #################################################################################### diff --git a/src/simulator/cosp_rttov_interfaceSTUB.F90 b/src/simulator/cosp_rttov_interfaceSTUB.F90 index 813d248592..7e97425ca7 100644 --- a/src/simulator/cosp_rttov_interfaceSTUB.F90 +++ b/src/simulator/cosp_rttov_interfaceSTUB.F90 @@ -69,7 +69,8 @@ MODULE MOD_COSP_RTTOV_INTERFACE !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN, & nlevels,Lrttov_cld,Lrttov_aer,Lrttov_rad,Lrttov_cldparam, & - Lrttov_aerparam) + Lrttov_aerparam, & + rttov_input_namelist) integer,intent(in) :: & NchanIN, & ! Number of channels platformIN, & ! Satellite platform @@ -84,6 +85,10 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI Lrttov_rad, & Lrttov_cldparam, & Lrttov_aerparam + + ! JKS testing using a RTTOV input namelist here + character(len=64),optional :: rttov_input_namelist + END SUBROUTINE COSP_RTTOV_INIT !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index b51aa08650..1ca15439cb 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -100,7 +100,8 @@ MODULE MOD_COSP_RTTOV_INTERFACE !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN, & nlevels,Lrttov_cld,Lrttov_aer,Lrttov_rad,Lrttov_cldparam, & - Lrttov_aerparam) + Lrttov_aerparam, & + rttov_input_namelist) integer,intent(in) :: & NchanIN, & ! Number of channels platformIN, & ! Satellite platform @@ -115,20 +116,43 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI Lrttov_rad, & Lrttov_cldparam, & Lrttov_aerparam - + + ! JKS testing using a RTTOV input namelist here + ! (default cosp_rttov namelist is set in cosp.F90) + character(len=64),optional :: rttov_input_namelist ! = 'cosp2_rttov_nl.txt' + ! Local variables character(len=256) :: & - coef_file, & - scat_file, & - rttov_coefDir, & - rttov_predDir, & - rttov_cldaerDir, & - OD_coef_filepath, & - aer_coef_file, & - cld_coef_file, & + coef_file, & + scat_file, & + rttov_coefDir, & + rttov_predDir, & + rttov_cldaerDir, & + OD_coef_file, & + aer_coef_file, & + cld_coef_file, & + OD_coef_filepath, & aer_coef_filepath, & cld_coef_filepath + ! Declare RTTOV namelist fields + logical :: so2_data,n2o_data,co_data,ch4_data + character(len=256) :: cosp_status + + ! Read RTTOV namelist fields + namelist/RTTOV_INPUT/OD_coef_file,aer_coef_file,cld_coef_file,OD_coef_filepath, & + aer_coef_filepath,cld_coef_filepath +! rttov_Nlocaltime, rttov_localtime, rttov_localtimewindow !JKS + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Read in namelists + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + !if (command_argument_count() == 2) call get_command_argument(2, cosp_output_namelist) + ! Use a different if statement because this subroutine doesn't interface with the command line + open(10,file=rttov_input_namelist,status='unknown') + read(10,nml=RTTOV_INPUT) + close(10) + ! Initialize fields in module memory (cosp_rttovXX.F90) nChannels = NchanIN platform = platformIN @@ -159,13 +183,17 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI ! General Radiative Transfer Options ! Gas profiles opts%rt_all%ozone_data = .true. - opts%rt_all%so2_data = .true. +! opts%rt_all%so2_data = .true. + opts%rt_all%so2_data = .false. ! Well-mixed gases opts%rt_all%co2_data = .true. - opts%rt_all%n2o_data = .true. - opts%rt_all%co_data = .true. - opts%rt_all%ch4_data = .true. +! opts%rt_all%n2o_data = .true. + opts%rt_all%n2o_data = .false. +! opts%rt_all%co_data = .true. + opts%rt_all%co_data = .false. +! opts%rt_all%ch4_data = .true. + opts%rt_all%ch4_data = .false. ! Other general RT options (initializing to defaults for completeness) opts%rt_all%do_lambertian = .false. @@ -278,12 +306,18 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI rttov_cldaerDir = "cldaer_visir/" ! This should be input. Also "cldaer_ir". ! Optical depth file + OD_coef_file = "rtcoef_ticfire_1_mbfiri_o3co2.dat" OD_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(rttov_predDir)// & - trim(construct_rttov_coeffilename(platform,satellite,sensor)) + trim(OD_coef_file) + +! OD_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(rttov_predDir)// & +! trim(construct_rttov_coeffilename(platform,satellite,sensor)) ! Example coefficient files (hardcoded) - aer_coef_file = "scaercoef_eos_2_airs_cams_chou-only.H5" - cld_coef_file = "sccldcoef_eos_2_airs_chou-only.H5" + aer_coef_file = "scaercoef_ticfire_1_mbfiri_cams.dat" + cld_coef_file = "sccldcoef_ticfire_1_mbfiri.dat" +! aer_coef_file = "scaercoef_eos_2_airs_cams_chou-only.H5" +! cld_coef_file = "sccldcoef_eos_2_airs_chou-only.H5" ! Coefficient files from the "construct_rttov_scatfilename" function. Not sure if working. ! aer_coef_file = construct_rttov_scatfilename(platform,satellite,sensor) @@ -295,6 +329,10 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI cld_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(rttov_cldaerDir)// & trim(cld_coef_file) + print*,'OD_coef_filepath: ',OD_coef_filepath + print*,'aer_coef_filepath: ',aer_coef_filepath + print*,'cld_coef_filepath: ',cld_coef_filepath + ! Read optical depth and cloud coefficient files together call rttov_read_coefs(errorstatus, coef_rttov, opts, & file_coef=OD_coef_filepath, & From 979199b6b502bda2e4e8e1864ec946d99ed967e5 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Thu, 16 Mar 2023 18:17:16 -0600 Subject: [PATCH 035/159] Added RTTOV input namelist. Added RTTOV inputs to COSP column input. Also cleaned up old code. Added warning messages if trying to run RTTOV if compiling without RTTOV. Getting a segmentation fault after the cosp_rttov_init when running, likely due to missing an allocation statement. Will investigate next. --- driver/run/cosp2_output_rttov_nl.txt | 4 +- driver/run/cosp2_rttov_nl.txt | 62 +++++++++------- driver/src/cosp2_test.F90 | 86 +++++++++++++--------- src/cosp.F90 | 29 +++----- src/simulator/cosp_rttov_interfaceSTUB.F90 | 7 +- src/simulator/cosp_rttov_interface_v13.F90 | 73 ++++++------------ 6 files changed, 127 insertions(+), 134 deletions(-) diff --git a/driver/run/cosp2_output_rttov_nl.txt b/driver/run/cosp2_output_rttov_nl.txt index 6a25e907e7..d0648e2b41 100755 --- a/driver/run/cosp2_output_rttov_nl.txt +++ b/driver/run/cosp2_output_rttov_nl.txt @@ -134,9 +134,9 @@ Lclmodis=.true., !- RTTOV Ltbrttov=.true., - Lrttov_cld=.false., + Lrttov_cld=.true., Lrttov_cldparam=.false., - Lrttov_aer=.false., + Lrttov_aer=.true., Lrttov_aerparam=.false., Lrttov_rad=.false., Lrttov_localtime=.false., diff --git a/driver/run/cosp2_rttov_nl.txt b/driver/run/cosp2_rttov_nl.txt index cbdeca3bbf..4cd8c1154e 100644 --- a/driver/run/cosp2_rttov_nl.txt +++ b/driver/run/cosp2_rttov_nl.txt @@ -26,35 +26,41 @@ ! Namelist that sets up the main COSP options &RTTOV_INPUT !-------------- RTTOV Outputs - Ltbrttov=.true., - Lrttov_cld=.false., - Lrttov_cldparam=.false., - Lrttov_aer=.false., - Lrttov_aerparam=.false., - Lrttov_rad=.false., - Lrttov_localtime=.false., - !-------------- RTTOV Coefficient Paths - OD_coef_file='test1', - aer_coef_file='test2', - cld_coef_file='test3', - OD_coef_filepath='test4', - aer_coef_filepath='test5', - cld_coef_filepath='test6', + !Ltbrttov=.true., + !Lrttov_cld=.false., + !Lrttov_cldparam=.false., + !Lrttov_aer=.false., + !Lrttov_aerparam=.false., + !Lrttov_rad=.false., + !Lrttov_localtime=.false., + !-------------- RTTOV Coefficient Paths + !- Paths should be relative to the RTTOVdir path specified in cosp_config.F90 + rttov_coefDir='rtcoef_rttov13/' + OD_coef_filepath='rttov13pred54L/rtcoef_ticfire_1_mbfiri_o3co2.dat', + aer_coef_filepath='cldaer_visir/scaercoef_ticfire_1_mbfiri_cams.dat', + cld_coef_filepath='cldaer_visir/sccldcoef_ticfire_1_mbfiri.dat', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + so2_data=.false., + n2o_data=.false., + co_data=.false., + co2_data=.false., + ch4_data=.false., + ozone_data=.false., !---------------------------------------------------------------------------------- !-------------- RTTOV inputs !---------------------------------------------------------------------------------- - rttov_Platform=1, ! satellite platform - rttov_Satellite=15, ! satellite - rttov_Instrument=5, ! instrument - rttov_Nchannels=3, ! Number of channels to be computed - rttov_Channels=1,2,3, ! Channel numbers (please be sure that you supply Nchannels) - rttov_Surfem=0.0,0.0,0.0, ! Surface emissivity (please be sure that you supply Nchannels) - rttov_ZenAng=50.0, ! Satellite Zenith Angle - CO2=5.241e-04, ! Mixing ratios of trace gases - CH4=9.139e-07, - N2O=4.665e-07, - CO=2.098e-07, - rttov_Nlocaltime=2, - rttov_localtime=10.0,13.0, ! To implement local time - rttov_localtimewindow=1.0,1.0 ! To implement local time width + !rttov_Platform=1, ! satellite platform + !rttov_Satellite=15, ! satellite + !rttov_Instrument=5, ! instrument + !rttov_Nchannels=3, ! Number of channels to be computed + !rttov_Channels=1,2,3, ! Channel numbers (please be sure that you supply Nchannels) + !rttov_Surfem=0.0,0.0,0.0, ! Surface emissivity (please be sure that you supply Nchannels) + !rttov_ZenAng=50.0, ! Satellite Zenith Angle + !CO2=5.241e-04, ! Mixing ratios of trace gases + !CH4=9.139e-07, + !N2O=4.665e-07, + !CO=2.098e-07, + !rttov_Nlocaltime=2, + !rttov_localtime=10.0,13.0, ! To implement local time + !rttov_localtimewindow=1.0,1.0 ! To implement local time width / diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index fe53839aa2..c444748ae8 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -72,8 +72,8 @@ program cosp2_test implicit none ! Input/Output driver file control - character(len=64) :: cosp_input_namelist,rttov_input_namelist - character(len=64) :: cosp_output_namelist = 'cosp2_output_nl.txt' + character(len=256) :: cosp_input_namelist,rttov_input_namelist + character(len=64) :: cosp_output_namelist = 'cosp2_output_nl.txt' ! Test data integer :: & @@ -199,9 +199,9 @@ program cosp2_test Lclmodis,Ltbrttov,Lptradarflag0,Lptradarflag1,Lptradarflag2,Lptradarflag3, & Lptradarflag4,Lptradarflag5,Lptradarflag6,Lptradarflag7,Lptradarflag8, & Lptradarflag9,Lradarpia, & - Lwr_occfreq, Lcfodd, & - Lrttov_cld, Lrttov_cldparam, Lrttov_aer, Lrttov_aerparam, & - Lrttov_rad, Lrttov_localtime + Lwr_occfreq,Lcfodd, & + Lrttov_cld,Lrttov_cldparam,Lrttov_aer,Lrttov_aerparam, & + Lrttov_rad,Lrttov_localtime namelist/COSP_OUTPUT/Lcfaddbze94,Ldbze94,Latb532,LcfadLidarsr532,Lclcalipso, & Lclhcalipso,Lcllcalipso,Lclmcalipso,Lcltcalipso,LparasolRefl, & Lclcalipsoliq,Lclcalipsoice,Lclcalipsoun,Lclcalipsotmp, & @@ -224,13 +224,12 @@ program cosp2_test Lclmmodis,Lcllmodis,Ltautmodis,Ltauwmodis,Ltauimodis, & Ltautlogmodis,Ltauwlogmodis,Ltauilogmodis,Lreffclwmodis, & Lreffclimodis,Lpctmodis,Llwpmodis,Liwpmodis,Lclmodis,Ltbrttov, & + Lrttov_cld, Lrttov_cldparam, Lrttov_aer, Lrttov_aerparam, & ! JKS + Lrttov_rad, Lrttov_localtime, & ! JKS Lptradarflag0,Lptradarflag1,Lptradarflag2,Lptradarflag3, & Lptradarflag4,Lptradarflag5,Lptradarflag6,Lptradarflag7, & Lptradarflag8,Lptradarflag9,Lradarpia, & - Lwr_occfreq, Lcfodd, & - Lrttov_cld, Lrttov_cldparam, Lrttov_aer, Lrttov_aerparam, & - Lrttov_rad, Lrttov_localtime ! JKS - + Lwr_occfreq, Lcfodd ! Local variables logical :: & lsingle = .true., & ! True if using MMF_v3_single_moment CLOUDSAT microphysical scheme (default) @@ -303,7 +302,7 @@ program cosp2_test close(10) ! Output namelist (logical flags to turn on/off outputs) - if (command_argument_count() == 2) call get_command_argument(2, cosp_output_namelist) + if (command_argument_count() .ge. 2) call get_command_argument(2, cosp_output_namelist) open(10,file=cosp_output_namelist,status='unknown') read(10,nml=cosp_output) close(10) @@ -311,7 +310,7 @@ program cosp2_test ! Save the path for the RTTOV input namelist to read later ! Because cosp2_test is an outer program, rttov_input_name cannot be optional. ! I use this solution, which isn't great but works. - if (command_argument_count() == 3) then + if (command_argument_count() .ge. 3) then call get_command_argument(3, rttov_input_namelist) else rttov_input_namelist = 'false' @@ -379,7 +378,12 @@ program cosp2_test Lptradarflag6 .or. Lptradarflag7 .or. Lptradarflag8 .or. Lptradarflag9 .or. & Lradarpia) Lcloudsat = .true. if (Lparasolrefl) Lparasol = .true. - if (Ltbrttov) Lrttov = .true. + if ((Ltbrttov) .and. (rttov_input_namelist /= 'false')) Lrttov = .true. + if ((Ltbrttov) .and. (rttov_input_namelist .eq. 'false')) then + print*,'Ltbrttov must be true and a RTTOV namelist must be provided to run RTTOV.' + Lrttov = .false. + Ltbrttov = .false. + endif !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -414,8 +418,7 @@ program cosp2_test rcfg_cloudsat, use_vgrid, csat_vgrid, Nlvgrid, Nlevels, cloudsat_micro_scheme, & rttov_platform, rttov_satellite, rttov_Instrument, rttov_Nchannels, & ! JKS added RTTOV inputs here rttov_Channels,Lrttov_cld, Lrttov_aer, Lrttov_rad, Lrttov_cldparam, & - Lrttov_aerparam, & - rttov_input_namelist=rttov_input_namelist) ! options RTTOV argument + Lrttov_aerparam,rttov_input_namelist) ! options RTTOV argument call cpu_time(driver_time(3)) !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -507,6 +510,40 @@ program cosp2_test ! cospstateIN%hgt_matrix_half(:,Nlevels) contains the bottom of the surface layer. cospstateIN%hgt_matrix_half(:,1:Nlevels) = zlev_half(start_idx:end_idx,Nlevels:1:-1) ! km + ! Assign RTTOV values (JKS) + ! From namelist file + cospstateIN%emis_sfc = rttov_Surfem(1:rttov_Nchannels) + cospstateIN%zenang = rttov_ZenAng + ! Well-mixed gases + cospstateIN%co2 = co2 + cospstateIN%ch4 = ch4 + cospstateIN%n2o = n2o + cospstateIN%co = co + + ! From the data input file + cospstateIN%u_sfc = u_wind + cospstateIN%v_sfc = v_wind + cospstateIN%lat = lat + cospstateIN%lon = lon + + cospstateIN%o3 = mr_ozone(start_idx:end_idx,Nlevels:1:-1) + cospstateIN%tca = tca(start_idx:end_idx,Nlevels:1:-1) + + ! Combine large-scale and convective cloud mixing ratios for RTTOV + cospstateIN%cloudIce = mr_lsice(start_idx:end_idx,Nlevels:1:-1) + mr_ccice(start_idx:end_idx,Nlevels:1:-1) + cospstateIN%cloudLiq = mr_lsliq(start_idx:end_idx,Nlevels:1:-1) + mr_ccliq(start_idx:end_idx,Nlevels:1:-1) + + ! RTTOV doesn't consider precip flux, but I think it was used previously. + ! Graupel goes in the snow category, arbitrarily + cospstateIN%fl_rain = fl_lsrain(start_idx:end_idx,Nlevels:1:-1) + fl_ccrain(start_idx:end_idx,Nlevels:1:-1) + cospstateIN%fl_snow = fl_lssnow(start_idx:end_idx,Nlevels:1:-1) + fl_ccsnow(start_idx:end_idx,Nlevels:1:-1) + & + fl_lsgrpl(start_idx:end_idx,Nlevels:1:-1) + + ! Inputs not supplied in the UKMO test data + cospstateIN%seaice(1:nPoints) = 0._wp + cospstateIN%month = 0 + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Generate subcolumns and compute optical inputs. !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -548,14 +585,6 @@ program cosp2_test call cpu_time(driver_time(8)) print*,'Time to write to output: ',driver_time(8)-driver_time(7) - - ! JKS test new namelist options -! print*,'rttov_localtime: ',rttov_localtime -! print*,'rttov_localtimewindow: ',rttov_localtimewindow - print*,'Lrttov_cld: ',Lrttov_cld - print*,'Lrttov_aer: ',Lrttov_aer - print*,'Lrttov_rad: ',Lrttov_rad - print*,'Lrttov_localtime: ',Lrttov_localtime !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Free up memory @@ -1056,18 +1085,7 @@ subroutine construct_cospstateIN(npoints,nlevels,nchan,y) y%cloudIce(nPoints,nLevels),y%cloudLiq(nPoints,nLevels),y%surfelev(npoints),& y%fl_snow(nPoints,nLevels),y%fl_rain(nPoints,nLevels),y%seaice(npoints), & y%tca(nPoints,nLevels),y%hgt_matrix_half(npoints,nlevels)) - -! allocate(y%sunlit(npoints),y%skt(npoints),y%land(npoints),y%at(npoints,nlevels), & -! y%pfull(npoints,nlevels),y%phalf(npoints,nlevels+1),y%qv(npoints,nlevels), & -! y%hgt_matrix(npoints,nlevels),y%hgt_matrix_half(npoints,nlevels), & -! y%surfelev(npoints)) -!#ifdef RTTOV -! allocate(y%o3(npoints,nlevels),y%u_sfc(npoints),y%v_sfc(npoints), & -! y%lat(npoints),y%lon(nPoints),y%emis_sfc(nchan), & -! y%cloudIce(nPoints,nLevels),y%cloudLiq(nPoints,nLevels), & -! y%fl_snow(nPoints,nLevels),y%fl_rain(nPoints,nLevels),y%seaice(npoints), & -! y%tca(nPoints,nLevels)) -!#endif +! JKS is everything RTTOV needs being allocated? Perhaps not. end subroutine construct_cospstateIN diff --git a/src/cosp.F90 b/src/cosp.F90 index c323b3973a..f0a224b78f 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -69,8 +69,6 @@ MODULE MOD_COSP USE MOD_COSP_RTTOV, ONLY: rttov_IN USE MOD_COSP_STATS, ONLY: COSP_LIDAR_ONLY_CLOUD,COSP_CHANGE_VERTICAL_GRID, & COSP_DIAG_WARMRAIN -! use mod_cosp_rttov, ONLY: rttov_simulate ! JKS new function -! use mod_cosp_rttov, ONLY: rttov_column,rttov_simulate ! JKS new function IMPLICIT NONE @@ -1795,7 +1793,7 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La real(wp),dimension(10) :: driver_time ! JKS testing using a RTTOV input namelist here - character(len=64),intent(in),optional :: rttov_input_namelist ! = 'cosp2_rttov_nl.txt' + character(len=256),intent(in) :: rttov_input_namelist ! OUTPUTS type(radar_cfg) :: rcfg @@ -1844,25 +1842,18 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La if (Lmisr) call cosp_misr_init() ! Could print diagnostic on timing here. - call cpu_time(driver_time(1)) if (Lrttov) then - if (rttov_input_namelist=='false') then - print*,'Lrttov is true but no RTTOV namelist is provided. Will not run RTTOV.' - else - call cosp_rttov_init(NchanIN,platformIN,satelliteIN, & - instrumentIN,channelsIN,Nlevels, & - Lrttov_cld,Lrttov_aer, & - Lrttov_rad,Lrttov_cldparam, & - Lrttov_aerparam, & - rttov_input_namelist=rttov_input_namelist) - endif - endif - - call cpu_time(driver_time(2)) - if ((Lrttov) .and. (rttov_input_namelist/='false')) then + call cpu_time(driver_time(1)) + call cosp_rttov_init(NchanIN,platformIN,satelliteIN, & + instrumentIN,channelsIN,Nlevels, & + Lrttov_cld,Lrttov_aer, & + Lrttov_rad,Lrttov_cldparam, & + Lrttov_aerparam, & + rttov_input_namelist) + call cpu_time(driver_time(2)) print*,'Time to run cosp_rttov_init: ',driver_time(2)-driver_time(1) endif - + if (Lcloudsat) call cosp_cloudsat_init(cloudsat_radar_freq,cloudsat_k2, & cloudsat_use_gas_abs,cloudsat_do_ray,R_UNDEF,N_HYDRO, surface_radar, & rcfg,cloudsat_micro_scheme) diff --git a/src/simulator/cosp_rttov_interfaceSTUB.F90 b/src/simulator/cosp_rttov_interfaceSTUB.F90 index 7e97425ca7..ce13b11ef9 100644 --- a/src/simulator/cosp_rttov_interfaceSTUB.F90 +++ b/src/simulator/cosp_rttov_interfaceSTUB.F90 @@ -87,7 +87,10 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI Lrttov_aerparam ! JKS testing using a RTTOV input namelist here - character(len=64),optional :: rttov_input_namelist + character(len=256),intent(in) :: rttov_input_namelist + + print*,'Running COSP_RTTOV_INIT from STUB files.', & + 'To run RTTOV, compile COSP after setting environmental variable "RTTOV"' END SUBROUTINE COSP_RTTOV_INIT @@ -107,6 +110,8 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, & ! Inputs error ! Error messages (only populated if error encountered) + print*,'Running COSP_RTTOV_SIMULATE from STUB files.', & + 'To run RTTOV, compile COSP after setting environmental variable "RTTOV"' ! How do I want the interface to function? How should it to be consistent with the rest of COSP? END SUBROUTINE COSP_RTTOV_SIMULATE diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 1ca15439cb..3206098b1d 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -119,7 +119,7 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI ! JKS testing using a RTTOV input namelist here ! (default cosp_rttov namelist is set in cosp.F90) - character(len=64),optional :: rttov_input_namelist ! = 'cosp2_rttov_nl.txt' + character(len=256),intent(in) :: rttov_input_namelist ! Local variables character(len=256) :: & @@ -136,22 +136,27 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI cld_coef_filepath ! Declare RTTOV namelist fields - logical :: so2_data,n2o_data,co_data,ch4_data + logical :: so2_data,n2o_data,co_data,ch4_data,co2_data,ozone_data character(len=256) :: cosp_status ! Read RTTOV namelist fields - namelist/RTTOV_INPUT/OD_coef_file,aer_coef_file,cld_coef_file,OD_coef_filepath, & - aer_coef_filepath,cld_coef_filepath + namelist/RTTOV_INPUT/rttov_coefDir, & + OD_coef_filepath, & + aer_coef_filepath,cld_coef_filepath,so2_data,n2o_data, & + co_data,ch4_data,co2_data,ozone_data ! rttov_Nlocaltime, rttov_localtime, rttov_localtimewindow !JKS !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Read in namelists !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - !if (command_argument_count() == 2) call get_command_argument(2, cosp_output_namelist) - ! Use a different if statement because this subroutine doesn't interface with the command line open(10,file=rttov_input_namelist,status='unknown') read(10,nml=RTTOV_INPUT) close(10) + + !print*,'OD_coef_file: ',OD_coef_file + !print*,'aer_coef_file: ',aer_coef_file + !print*,'cld_coef_file: ',cld_coef_file + !print*,'OD_coef_filepath: ',OD_coef_filepath ! Initialize fields in module memory (cosp_rttovXX.F90) nChannels = NchanIN @@ -160,7 +165,7 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI sensor = instrumentIN iChannel = channelsIN - ! Logicals for RTTOV options + ! Set logicals for RTTOV options do_rttov_cld = Lrttov_cld do_rttov_aer = Lrttov_aer do_rttov_rad = Lrttov_rad ! to be used in output @@ -181,19 +186,13 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI opts%config%opdep13_gas_clip = .true. ! General Radiative Transfer Options - ! Gas profiles - opts%rt_all%ozone_data = .true. -! opts%rt_all%so2_data = .true. - opts%rt_all%so2_data = .false. - - ! Well-mixed gases - opts%rt_all%co2_data = .true. -! opts%rt_all%n2o_data = .true. - opts%rt_all%n2o_data = .false. -! opts%rt_all%co_data = .true. - opts%rt_all%co_data = .false. -! opts%rt_all%ch4_data = .true. - opts%rt_all%ch4_data = .false. + ! Gas profile logicals + opts%rt_all%ozone_data = ozone_data + opts%rt_all%so2_data = so2_data + opts%rt_all%co2_data = co2_data + opts%rt_all%n2o_data = n2o_data + opts%rt_all%co_data = co_data + opts%rt_all%ch4_data = ch4_data ! Other general RT options (initializing to defaults for completeness) opts%rt_all%do_lambertian = .false. @@ -298,36 +297,10 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI ! Construct optical depth and cloud coefficient files - ! rttovDir should be "/glade/u/home/jonahshaw/w/RTTOV/" passed from namelist - - ! Hardcoding these other paths for now, they should be input later. - rttov_coefDir = "rtcoef_rttov13/" ! directory for coefficient in RTTOV v13 - rttov_predDir = "rttov13pred54L/" ! example directory for predictors. This should be input - rttov_cldaerDir = "cldaer_visir/" ! This should be input. Also "cldaer_ir". - - ! Optical depth file - OD_coef_file = "rtcoef_ticfire_1_mbfiri_o3co2.dat" - OD_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(rttov_predDir)// & - trim(OD_coef_file) - -! OD_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(rttov_predDir)// & -! trim(construct_rttov_coeffilename(platform,satellite,sensor)) - - ! Example coefficient files (hardcoded) - aer_coef_file = "scaercoef_ticfire_1_mbfiri_cams.dat" - cld_coef_file = "sccldcoef_ticfire_1_mbfiri.dat" -! aer_coef_file = "scaercoef_eos_2_airs_cams_chou-only.H5" -! cld_coef_file = "sccldcoef_eos_2_airs_chou-only.H5" - - ! Coefficient files from the "construct_rttov_scatfilename" function. Not sure if working. -! aer_coef_file = construct_rttov_scatfilename(platform,satellite,sensor) -! cld_coef_file = construct_rttov_scatfilename(platform,satellite,sensor) - - ! Cloud and Aerosol scattering (and absorption?) file(s) - aer_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(rttov_cldaerDir)// & - trim(aer_coef_file) - cld_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(rttov_cldaerDir)// & - trim(cld_coef_file) + ! rttovDir should be "/glade/u/home/jonahshaw/w/RTTOV/" and is defined in cosp_config.F90 + OD_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(OD_coef_filepath) + aer_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(aer_coef_filepath) + cld_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(cld_coef_filepath) print*,'OD_coef_filepath: ',OD_coef_filepath print*,'aer_coef_filepath: ',aer_coef_filepath From dea4ae0f2fafadd51ad7c7c7f7b821521e4ea7b9 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 21 Mar 2023 17:27:27 -0600 Subject: [PATCH 036/159] RTTOV working, no clean up or checks yet. --- driver/src/cosp2_test.F90 | 7 +- src/cosp.F90 | 8 +- src/simulator/cosp_rttov_interface_v13.F90 | 8 ++ src/simulator/rttov/cosp_rttovSTUB.F90 | 3 + src/simulator/rttov/cosp_rttov_v13.F90 | 101 +++++++++++++-------- 5 files changed, 83 insertions(+), 44 deletions(-) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index c444748ae8..260ef6f7ce 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -156,7 +156,7 @@ program cosp2_test rttov_Channels ! RTTOV: Channel numbers real(wp),dimension(RTTOV_MAX_CHANNELS) :: & rttov_Surfem ! RTTOV: Surface emissivity - real(wp),dimension(RTTOV_MAX_LOCALTIMES) :: & ! JKS This is not allowed in a main program + real(wp),dimension(RTTOV_MAX_LOCALTIMES) :: & rttov_localtime, & ! RTTOV subsetting by local time in hours [0,24] rttov_localtimewindow ! Width of local time window (hrs). character(len=64) :: & @@ -541,8 +541,7 @@ program cosp2_test ! Inputs not supplied in the UKMO test data cospstateIN%seaice(1:nPoints) = 0._wp - cospstateIN%month = 0 - + cospstateIN%month = 0 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Generate subcolumns and compute optical inputs. @@ -568,6 +567,7 @@ program cosp2_test do ij=1,size(cosp_status,1) if (cosp_status(ij) .ne. '') print*,trim(cosp_status(ij)) end do + print*,'COSP_SIMULATOR successful' ! jks call cpu_time(driver_time(7)) enddo @@ -1085,7 +1085,6 @@ subroutine construct_cospstateIN(npoints,nlevels,nchan,y) y%cloudIce(nPoints,nLevels),y%cloudLiq(nPoints,nLevels),y%surfelev(npoints),& y%fl_snow(nPoints,nLevels),y%fl_rain(nPoints,nLevels),y%seaice(npoints), & y%tca(nPoints,nLevels),y%hgt_matrix_half(npoints,nlevels)) -! JKS is everything RTTOV needs being allocated? Perhaps not. end subroutine construct_cospstateIN diff --git a/src/cosp.F90 b/src/cosp.F90 index f0a224b78f..f8b9f7e1de 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -405,6 +405,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Initialize error reporting for output cosp_simulator(:)='' + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 1) Determine if using full inputs or subset @@ -742,6 +743,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) rttovIN%nLevels => cospIN%nLevels rttovIN%nSubCols => cospIN%nColumns rttovIN%nChannels => cospIN%nChannels_rttov + rttovIN%channels => cospIN%channelsIN_rttov rttovIN%zenang => cospgridIN%zenang rttovIN%co2 => cospgridIN%co2 rttovIN%ch4 => cospgridIN%ch4 @@ -770,7 +772,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) rttovIN%cldIce => cospgridIN%cloudIce rttovIN%cldLiq => cospgridIN%cloudLiq rttovIN%fl_rain => cospgridIN%fl_rain ! JKS remove? - rttovIN%fl_snow => cospgridIN%fl_snow ! JKS remove? + rttovIN%fl_snow => cospgridIN%fl_snow ! JKS remove? endif !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1528,6 +1530,8 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (allocated(isccpLEVMATCH)) deallocate(isccpLEVMATCH) endif + print*,'Lrttov_column start' ! jks + ! RTTOV if (Lrttov_column) then @@ -1538,6 +1542,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) print*,'Time to run RTTOV: ',driver_time(4)-driver_time(3) endif + print*,'Lrttov_column successful' ! jks !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 6) Compute multi-instrument products @@ -1792,7 +1797,6 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La cloudsat_micro_scheme ! Microphysical scheme used by CLOUDSAT real(wp),dimension(10) :: driver_time - ! JKS testing using a RTTOV input namelist here character(len=256),intent(in) :: rttov_input_namelist ! OUTPUTS diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 3206098b1d..a3c1da9d82 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -403,18 +403,26 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, & ! Inputs real(wp),dimension(10) :: driver_time ! Run each step for running RTTOV from mod_cosp_rttov (and time them) + print*,'cosp_rttov_allocate begin' ! jks call cpu_time(driver_time(1)) call cosp_rttov_allocate(rttovIN) + print*,'cosp_rttov_allocate successful' ! jks call cpu_time(driver_time(2)) call cosp_rttov_construct_profiles(rttovIN) + print*,'cosp_rttov_construct_profiles successful' ! jks call cpu_time(driver_time(3)) call cosp_rttov_setup_emissivity_reflectance() + print*,'cosp_rttov_setup_emissivity_reflectance successful' ! jks call cpu_time(driver_time(4)) call cosp_rttov_call_direct(nthreads) + print*,'cosp_rttov_call_direct successful' ! jks call cpu_time(driver_time(5)) call cosp_rttov_save_and_deallocate_profiles(rttovIN,Tb) + print*,'cosp_rttov_save_and_deallocate_profiles successful' ! jks call cpu_time(driver_time(6)) + print*,'RTTOV Tb output: ',Tb + print*,'Time to run "cosp_rttov_allocate": ', driver_time(2)-driver_time(1) print*,'Time to run "cosp_rttov_construct_profiles": ', driver_time(3)-driver_time(2) print*,'Time to run "cosp_rttov_setup_emissivity_reflectance": ',driver_time(4)-driver_time(3) diff --git a/src/simulator/rttov/cosp_rttovSTUB.F90 b/src/simulator/rttov/cosp_rttovSTUB.F90 index 088f1be1ed..4bcd94469b 100644 --- a/src/simulator/rttov/cosp_rttovSTUB.F90 +++ b/src/simulator/rttov/cosp_rttovSTUB.F90 @@ -69,6 +69,9 @@ MODULE MOD_COSP_RTTOV co ! Carbon monoxide real(wp),dimension(:),pointer :: & surfem ! Surface emissivities for the channels +! refl, & ! Surface reflectances for the channels + integer,dimension(:),pointer :: & + channels ! Surface reflectances for the channels real(wp),dimension(:),pointer :: & h_surf, & ! Surface height u_surf, & ! U component of surface wind diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index ed2dbe0d15..05cd2ea151 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -144,7 +144,7 @@ module mod_cosp_rttov integer(kind=jpim) :: nthreads integer(kind=jpim) :: dosolar integer(kind=jpim) :: nchanprof ! JKS - jpim is RTTOV integer type - integer(kind=jpim), allocatable :: channel_list(:) ! JKS this needs to be specified +! integer(kind=jpim), allocatable :: channel_list(:) ! JKS this needs to be specified TYPE(rttov_chanprof), POINTER :: chanprof(:) => NULL() ! Input channel/profile list LOGICAL(KIND=jplm), POINTER :: calcemis(:) => NULL() ! Flag to indicate calculation of emissivity within RTTOV @@ -165,7 +165,7 @@ module mod_cosp_rttov ! JKS - add additional COSP inputs here. type rttov_IN - integer,pointer :: & + integer(kind=jpim),pointer :: & ! JKS trying this nPoints, & ! Number of profiles to simulate nLevels, & ! Number of levels nSubCols, & ! Number of subcolumns @@ -178,7 +178,10 @@ module mod_cosp_rttov n2o, & ! n2o co ! Carbon monoxide real(wp),dimension(:),pointer :: & - surfem ! Surface emissivities for the channels + surfem ! Surface emissivities for the channels +! refl, & ! Surface reflectances for the channels + integer(kind=jpim),dimension(:),pointer :: & + channels ! Surface reflectances for the channels real(wp),dimension(:),pointer :: & h_surf, & ! Surface height u_surf, & ! U component of surface wind @@ -243,8 +246,7 @@ subroutine cosp_rttov_allocate(rttovIN & ! Loop variables integer(kind=jpim) :: j, jch, nch -! integer(kind=jpim) :: nch - + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 3. Allocate RTTOV input and output structures ! ------------------------------------------------------ @@ -254,6 +256,14 @@ subroutine cosp_rttov_allocate(rttovIN & ! Determine the total number of radiances to simulate (nchanprof). ! We aren't doing subcolumn sampling (RTTOV already does this and it would be slow) ! nchanprof = nchannels * nprof + + ! Allocate and fill in channel_list +! allocate(channel_list(rttovIN%nChannels)) +! channel_list(1:nChannels) = rttovIN%channels(1:nChannels) + +! print*,'rttovIN%channels: ',rttovIN%channels +! print*,'channel_list: ',channel_list + nchanprof = rttovIN%nChannels * rttovIN%nPoints ! Allocate structures for rttov_direct @@ -290,10 +300,10 @@ subroutine cosp_rttov_allocate(rttovIN & do jch = 1, rttovIN%nChannels nch = nch + 1_jpim chanprof(nch)%prof = j - chanprof(nch)%chan = channel_list(jch) ! channel_list should be specified + chanprof(nch)%chan = rttovIN%channels(jch) ! Example code used channel_list end do end do - + end subroutine cosp_rttov_allocate @@ -323,35 +333,39 @@ subroutine cosp_rttov_construct_profiles(rttovIN & ! If you are not able to provide ozone, CO2, etc profiles the flags ! ozone_data, co2_data and so on in the options structure should be ! set to false." - - ! Initialize trace gas column concentrations (well-mixed so constant in input) - do j = 1, rttovIN%nlevels - profiles(:)%co2(j) = rttovIN%co2 - profiles(:)%n2o(j) = rttovIN%n2o - profiles(:)%co(j) = rttovIN%n2o - profiles(:)%ch4(j) = rttovIN%ch4 - end do - profiles%gas_units = 1 ! kg/kg over moist air (default) + profiles(:)%gas_units = 1 ! kg/kg over moist air (default) do i = 1, rttovIN%nPoints - profiles(i)%p(:) = rttovIN%p(i, :) + + ! Initialize trace gas concentrations + profiles(i)%co2(:) = rttovIN%co2 + profiles(i)%n2o(:) = rttovIN%n2o + profiles(i)%co(:) = rttovIN%n2o + profiles(i)%ch4(:) = rttovIN%ch4 + + ! Initialize column pressure, temperature, and humidity + profiles(i)%p(:) = rttovIN%p(i, :) * 1e-2 ! convert Pa to hPa profiles(i)%t(:) = rttovIN%t(i, :) profiles(i)%q(:) = rttovIN%q(i, :) - ! JKS not sure if I should keep this limiting of water vapor - where(profiles(i)%q(:) < 1e-4) - profiles(i)%q(:) = 1e-4 + ! q coefficient limit is 09=.1e-10 + where(profiles(i)%q(:) < 0.1e-10) + profiles(i)%q(:) = 0.11e-10 end where + +! if (any(profiles%q < 0.1e-10)) then +! write(*,*) 'q profile less than RTTOV minimum. Rewritten to 1e-11' +! errorstatus = 1 +! call rttov_exit(errorstatus) +! endif ! Gas profiles profiles(i)%o3 = rttovIN%o3(i, :) ! profiles(i)%so2 = ! Sulfate not in COSP input files -! profiles(i)%aerosols(naertyp,nlayers) = ! Aerosols in different modes (see User Guide pg 80) - ! 2m parameters - profiles(i)%s2m%p = rttovIN%p_surf(i) + profiles(i)%s2m%p = rttovIN%p_surf(i) * 1e-2 ! convert Pa to hPa profiles(i)%s2m%t = rttovIN%t2m(i) ! JKS or rttovIN%t_skin profiles(i)%s2m%q = rttovIN%q2m(i) ! Should be the same as gas units (kg/kg) profiles(i)%s2m%u = rttovIN%u_surf(i) @@ -374,7 +388,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN & profiles(i)%latitude = rttovIN%latitude(i) profiles(i)%longitude = rttovIN%longitude(i) - profiles(i)%elevation = rttovIN%h_surf(i) + profiles(i)%elevation = rttovIN%h_surf(i) * 1e-3 ! Convert m to km ! Solar angles. JKS - get this from COSP? Doesn't seem to be passed in. profiles(i)%sunzenangle = 0. ! hard-coded in rttov9 int @@ -397,23 +411,29 @@ subroutine cosp_rttov_construct_profiles(rttovIN & !profiles(i) %idg = 0. ! Depreciated? !profiles(i) %ish = 0. ! Depreciated? end do - + ! JKS - nothing to check here, this will never trigger. call rttov_error('error in profile initialization' , lalloc = .false.) +! print*,'profiles(90)%p(:): ',profiles(90)%p(:) +! print*,'profiles(90)%q(:): ',profiles(90)%q(:) +! print*,'profiles(90)%t(:): ',profiles(90)%t(:) + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Only add the cloud fields if simulating cloud. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - rttov_simulate_cld = .false. - if (rttov_simulate_cld) then +! rttov_simulate_cld = .false. +! if (rttov_simulate_cld) then + + if (do_rttov_cld) then ! Set cloud mass mixing ratio units - profiles%mmr_cldaer = .true. ! kg/kg for cloud and aerosol (default) + profiles(:)%mmr_cldaer = .true. ! kg/kg for cloud and aerosol (default) - profiles%clw_scheme = 2. ! Deff scheme avoids cloud types + profiles(:)%clw_scheme = 2 ! Deff scheme avoids cloud types ! profiles%clwde_scheme = 1. ! Not implemented? - profiles%ice_scheme = 1. !1:Baum 2:Baran(2014) 3:Baran(2018) - profiles%icede_param = 2. ! 2:Wyser(recommended). Only used if ice effective diameter not input + profiles(:)%ice_scheme = 1 !1:Baum 2:Baran(2014) 3:Baran(2018) + profiles(:)%icede_param = 2 ! 2:Wyser(recommended). Only used if ice effective diameter not input do i = 1, rttovIN%nPoints ! Cloud scheme stuff @@ -434,7 +454,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN & ! Other options not implemented ! profiles(i)%clw = ! Cloud liquid water (kg/kg) – MW only, - end do + end do endif ! JKS - nothing to check here, this will never trigger. @@ -444,14 +464,17 @@ subroutine cosp_rttov_construct_profiles(rttovIN & ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Only add the aerosol fields if simulating aerosol. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - rttov_simulate_aer = .false. - if (rttov_simulate_aer) then +! rttov_simulate_aer = .false. +! if (rttov_simulate_aer) then + + if (do_rttov_aer) then ! Set aerosol mass mixing ratio units profiles%mmr_cldaer = .true. ! kg/kg for cloud and aerosol (default) ! Read in aerosol profiles ! do i = 1, rttovIN%nPoints +! profiles(i)%aerosols(naertyp,nlayers) = ! Aerosols in different modes (see User Guide pg 80) ! ! end do endif @@ -497,6 +520,7 @@ subroutine cosp_rttov_call_direct(nthreads) integer(kind=jpim) :: nthreads nthreads = 1 ! Default not parallel for now. Can be optimized later. - JKS + print*,'Calling rttov_direct' if (nthreads <= 1) then call rttov_direct( & @@ -557,10 +581,11 @@ subroutine cosp_rttov_save_and_deallocate_profiles(rttovIN,Tb) ! From RTTOV example files. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - deallocate (channel_list, stat=alloc_status(1)) - if (alloc_status(1) /= 0) then - write(*,*) 'mem dellocation error' - endif + ! JKS no longer using channel_list + !deallocate (channel_list, stat=alloc_status(1)) + !if (alloc_status(1) /= 0) then + ! write(*,*) 'mem dellocation error' + !endif ! Deallocate structures for rttov_direct call rttov_alloc_direct( & From 24d6e7e10227a19bf4ec75bedf4ff445b69aadbb Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 21 Mar 2023 18:35:17 -0600 Subject: [PATCH 037/159] Add RTTOV brightness temperatures as an output. --- driver/run/cosp2_input_rttov_nl.txt | 6 ++--- driver/src/cosp2_io.f90 | 34 ++++++++++++++++++++++++----- driver/src/cosp2_test.F90 | 2 +- src/cosp.F90 | 16 ++++++++++++-- 4 files changed, 47 insertions(+), 11 deletions(-) diff --git a/driver/run/cosp2_input_rttov_nl.txt b/driver/run/cosp2_input_rttov_nl.txt index b3b65d30f0..73829530e8 100644 --- a/driver/run/cosp2_input_rttov_nl.txt +++ b/driver/run/cosp2_input_rttov_nl.txt @@ -85,9 +85,9 @@ rttov_Platform=1, ! satellite platform rttov_Satellite=15, ! satellite rttov_Instrument=5, ! instrument - rttov_Nchannels=3, ! Number of channels to be computed - rttov_Channels=1,2,3, ! Channel numbers (please be sure that you supply Nchannels) - rttov_Surfem=0.0,0.0,0.0, ! Surface emissivity (please be sure that you supply Nchannels) + rttov_Nchannels=15, ! Number of channels to be computed + rttov_Channels=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, ! Channel numbers (please be sure that you supply Nchannels) + rttov_Surfem=0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, ! Surface emissivity (please be sure that you supply Nchannels) rttov_ZenAng=50.0, ! Satellite Zenith Angle CO2=5.241e-04, ! Mixing ratios of trace gases CH4=9.139e-07, diff --git a/driver/src/cosp2_io.f90 b/driver/src/cosp2_io.f90 index 4931d7c395..b829da22ad 100644 --- a/driver/src/cosp2_io.f90 +++ b/driver/src/cosp2_io.f90 @@ -17,8 +17,8 @@ module mod_cosp_io !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE write_cosp2_output !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, lev, lon, lat, cospOUT, outFileName) - integer,intent(in) :: Npoints, Ncolumns, Nlevels + subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, lev, lon, lat, cospOUT, outFileName) + integer,intent(in) :: Npoints, Ncolumns, Nlevels, Nchannels real(wp),dimension(Npoints),intent(in) :: lon,lat real(wp),dimension(Nlevels),intent(in) :: lev type(cosp_outputs),intent(in) :: cospOUT @@ -79,9 +79,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,"CFODD_NICOD",CFODD_NICOD,dimID(18)) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - + status = nf90_def_dim(fileID,"RTTOV_CHAN",Nchannels,dimID(19)) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) ! --------------------------------------------------------------------------------------- - ! Define varaibles + ! Define variables ! --------------------------------------------------------------------------------------- ! Longitude status = nf90_def_var(fileID,"longitude", nf90_float, (/dimID(1)/),varID(1)) @@ -192,6 +193,7 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, lev, lon, lat, cospOUT if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) status = nf90_put_att(fileID,varID(83),"units", "1") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + ! CALIPSO simulator output if (associated(cospOUT%calipso_betaperp_tot)) then @@ -1417,6 +1419,23 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, lev, lon, lat, cospOUT if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) endif + + ! --------------------------------------------------------------------------------------- + ! RTTOV - JKS + ! --------------------------------------------------------------------------------------- + + ! Brightness Temperature + if (associated(cospOUT%rttov_tbs)) then + status = nf90_def_var(fileID,"rttov_tb",nf90_float, (/dimID(1),dimID(19)/),varID(148)) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(148),"long_name","RTTOV Brightness Temperature") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(148),"units", "Degrees Kelvin") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(148),"standard_name", "bleh") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + ! --------------------------------------------------------------------------------------- ! Exit define mode ! --------------------------------------------------------------------------------------- @@ -1894,7 +1913,12 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, lev, lon, lat, cospOUT if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) endif - + ! RTTOV outputs + if (associated(cospOUT%rttov_tbs)) then + status = nf90_put_var(fileID,varID(148),cospOUT%rttov_tbs) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + ! Close file status = nf90_close(fileID) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 260ef6f7ce..6e556e503c 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -581,7 +581,7 @@ program cosp2_test !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Output !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - call write_cosp2_output(Npoints, Ncolumns, Nlevels, zlev(1,Nlevels:1:-1), lon, lat, cospOUT, foutput) + call write_cosp2_output(Npoints, Ncolumns, Nlevels, rttov_Nchannels, zlev(1,Nlevels:1:-1), lon, lat, cospOUT, foutput) call cpu_time(driver_time(8)) print*,'Time to write to output: ',driver_time(8)-driver_time(7) diff --git a/src/cosp.F90 b/src/cosp.F90 index f8b9f7e1de..c3a243113f 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -386,7 +386,8 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) modisRetrievedCloudTopPressure,modisRetrievedTau,modisRetrievedSize, & misr_boxtau,misr_boxztop,misr_dist_model_layertops,isccp_boxtau, & isccp_boxttop,isccp_boxptop,calipso_beta_mol,lidar_only_freq_cloud, & - grLidar532_beta_mol,atlid_beta_mol + grLidar532_beta_mol,atlid_beta_mol, & + rttovTb ! JKS RTTOV REAL(WP), dimension(:,:,:),allocatable :: & modisJointHistogram,modisJointHistogramIce,modisJointHistogramLiq, & calipso_beta_tot,calipso_betaperp_tot, cloudsatDBZe,parasolPix_refl, & @@ -1535,11 +1536,22 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! RTTOV if (Lrttov_column) then + ! Allocate memory for the outputs + allocate(rttovTb(rttovIN%Npoints,rttovIN%Nchannels)) + ! JKS new RTTOV subroutine for v13 called from the RTTOV interface. call cpu_time(driver_time(3)) - call cosp_rttov_simulate(rttovIN,Lrttov_cleanUp,cospOUT%rttov_tbs(ij:ik,:),cosp_simulator(nError+1)) + ! Run simulator + call cosp_rttov_simulate(rttovIN,Lrttov_cleanUp,rttovTb,cosp_simulator(nError+1)) call cpu_time(driver_time(4)) print*,'Time to run RTTOV: ',driver_time(4)-driver_time(3) + + ! Write to cospOUT + if (associated(cospOUT%rttov_tbs)) & + cospOUT%rttov_tbs(ij:ik,:) = rttovTb + + ! Free up memory from output (if necessary) + if (allocated(rttovTb)) deallocate(rttovTb) endif print*,'Lrttov_column successful' ! jks From 1b22d54c8ce2dc3dd4f8992f36ba30950c5b2d3e Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Thu, 23 Mar 2023 15:15:17 -0600 Subject: [PATCH 038/159] Add options and code for BT, radiance, and reflectivity outputs New namelist variables select outputs to product. Potential issues: - cosp_rttov_init is slower now regard of the logical inputs, could potentially speed this up. - Reflectivities have extreme values for TICFIRE channels, probably not relevant, but should check with SW instrument. --- driver/run/cosp2_output_rttov_nl.txt | 6 +- driver/src/cosp2_io.f90 | 98 +++++++++- driver/src/cosp2_test.F90 | 98 +++++++--- src/cosp.F90 | 217 +++++++++++++++++---- src/simulator/cosp_rttov_interfaceSTUB.F90 | 27 ++- src/simulator/cosp_rttov_interface_v13.F90 | 95 +++++---- src/simulator/rttov/cosp_rttov_v13.F90 | 54 ++++- 7 files changed, 463 insertions(+), 132 deletions(-) diff --git a/driver/run/cosp2_output_rttov_nl.txt b/driver/run/cosp2_output_rttov_nl.txt index d0648e2b41..b886a4e7ae 100755 --- a/driver/run/cosp2_output_rttov_nl.txt +++ b/driver/run/cosp2_output_rttov_nl.txt @@ -133,12 +133,14 @@ Liwpmodis=.true., Lclmodis=.true., !- RTTOV - Ltbrttov=.true., +! Ltbrttov=.true., + Lrttov_bt=.true., + Lrttov_rad=.true., + Lrttov_refl=.true., Lrttov_cld=.true., Lrttov_cldparam=.false., Lrttov_aer=.true., Lrttov_aerparam=.false., - Lrttov_rad=.false., Lrttov_localtime=.false., ! -CLOUDSAT precipitation frequency/occurence diagnostics Lptradarflag0=.true., diff --git a/driver/src/cosp2_io.f90 b/driver/src/cosp2_io.f90 index b829da22ad..f294daaaa2 100644 --- a/driver/src/cosp2_io.f90 +++ b/driver/src/cosp2_io.f90 @@ -1425,16 +1425,77 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, lev, lon, l ! --------------------------------------------------------------------------------------- ! Brightness Temperature - if (associated(cospOUT%rttov_tbs)) then - status = nf90_def_var(fileID,"rttov_tb",nf90_float, (/dimID(1),dimID(19)/),varID(148)) + if (associated(cospOUT%rttov_bt_total)) then + status = nf90_def_var(fileID,"rttov_bt_total",nf90_float, (/dimID(1),dimID(19)/),varID(148)) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(148),"long_name","RTTOV Brightness Temperature") + status = nf90_put_att(fileID,varID(148),"long_name","RTTOV All-sky Brightness Temperature") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) status = nf90_put_att(fileID,varID(148),"units", "Degrees Kelvin") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) status = nf90_put_att(fileID,varID(148),"standard_name", "bleh") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) endif + if (associated(cospOUT%rttov_bt_clear)) then + status = nf90_def_var(fileID,"rttov_bt_clear",nf90_float, (/dimID(1),dimID(19)/),varID(149)) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(149),"long_name","RTTOV Clear-sky Brightness Temperature") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(149),"units", "Degrees Kelvin") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(149),"standard_name", "bleh") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_rad_total)) then + status = nf90_def_var(fileID,"rttov_rad_total",nf90_float, (/dimID(1),dimID(19)/),varID(150)) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(150),"long_name","RTTOV All-sky Radiance") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(150),"units", "mW/cm-1/sr/m2") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(150),"standard_name", "bleh") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_rad_clear)) then + status = nf90_def_var(fileID,"rttov_rad_clear",nf90_float, (/dimID(1),dimID(19)/),varID(151)) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(151),"long_name","RTTOV Clear-sky Radiance") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(151),"units", "mW/cm-1/sr/m2") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(151),"standard_name", "bleh") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_rad_cloudy)) then + status = nf90_def_var(fileID,"rttov_rad_cloudy",nf90_float, (/dimID(1),dimID(19)/),varID(152)) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(152),"long_name","RTTOV Cloudy-sky Radiance") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(152),"units", "mW/cm-1/sr/m2") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(152),"standard_name", "bleh") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_refl_total)) then + status = nf90_def_var(fileID,"rttov_refl_total",nf90_float, (/dimID(1),dimID(19)/),varID(153)) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(153),"long_name","RTTOV All-sky Reflectance") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(153),"units", "unitless") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(153),"standard_name", "bleh") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_refl_clear)) then + status = nf90_def_var(fileID,"rttov_refl_clear",nf90_float, (/dimID(1),dimID(19)/),varID(154)) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(154),"long_name","RTTOV Clear-sky Reflectance") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(154),"units", "unitless") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(154),"standard_name", "bleh") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + ! --------------------------------------------------------------------------------------- ! Exit define mode @@ -1914,11 +1975,36 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, lev, lon, l endif ! RTTOV outputs - if (associated(cospOUT%rttov_tbs)) then - status = nf90_put_var(fileID,varID(148),cospOUT%rttov_tbs) + if (associated(cospOUT%rttov_bt_total)) then + status = nf90_put_var(fileID,varID(148),cospOUT%rttov_bt_total) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_bt_clear)) then + status = nf90_put_var(fileID,varID(149),cospOUT%rttov_bt_clear) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_rad_total)) then + status = nf90_put_var(fileID,varID(150),cospOUT%rttov_rad_total) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_rad_clear)) then + status = nf90_put_var(fileID,varID(151),cospOUT%rttov_rad_clear) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_rad_cloudy)) then + status = nf90_put_var(fileID,varID(152),cospOUT%rttov_rad_cloudy) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) endif - + if (associated(cospOUT%rttov_refl_total)) then + status = nf90_put_var(fileID,varID(153),cospOUT%rttov_refl_total) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_refl_clear)) then + status = nf90_put_var(fileID,varID(154),cospOUT%rttov_refl_clear) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + + ! Close file status = nf90_close(fileID) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 6e556e503c..b74233a6fd 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -196,12 +196,18 @@ program cosp2_test LlidarBetaMol532,Lcltmodis,Lclwmodis,Lclimodis,Lclhmodis,Lclmmodis, & Lcllmodis,Ltautmodis,Ltauwmodis,Ltauimodis,Ltautlogmodis,Ltauwlogmodis, & Ltauilogmodis,Lreffclwmodis,Lreffclimodis,Lpctmodis,Llwpmodis,Liwpmodis, & - Lclmodis,Ltbrttov,Lptradarflag0,Lptradarflag1,Lptradarflag2,Lptradarflag3, & + Lclmodis,Lptradarflag0,Lptradarflag1,Lptradarflag2,Lptradarflag3, & Lptradarflag4,Lptradarflag5,Lptradarflag6,Lptradarflag7,Lptradarflag8, & Lptradarflag9,Lradarpia, & - Lwr_occfreq,Lcfodd, & - Lrttov_cld,Lrttov_cldparam,Lrttov_aer,Lrttov_aerparam, & - Lrttov_rad,Lrttov_localtime + Lwr_occfreq,Lcfodd + logical :: Lrttov_bt = .false. + logical :: Lrttov_rad = .false. + logical :: Lrttov_refl = .false. + logical :: Lrttov_cld = .false. + logical :: Lrttov_cldparam = .false. + logical :: Lrttov_aer = .false. + logical :: Lrttov_aerparam = .false. + logical :: Lrttov_localtime = .false. namelist/COSP_OUTPUT/Lcfaddbze94,Ldbze94,Latb532,LcfadLidarsr532,Lclcalipso, & Lclhcalipso,Lcllcalipso,Lclmcalipso,Lcltcalipso,LparasolRefl, & Lclcalipsoliq,Lclcalipsoice,Lclcalipsoun,Lclcalipsotmp, & @@ -223,9 +229,10 @@ program cosp2_test LlidarBetaMol532,Lcltmodis,Lclwmodis,Lclimodis,Lclhmodis, & Lclmmodis,Lcllmodis,Ltautmodis,Ltauwmodis,Ltauimodis, & Ltautlogmodis,Ltauwlogmodis,Ltauilogmodis,Lreffclwmodis, & - Lreffclimodis,Lpctmodis,Llwpmodis,Liwpmodis,Lclmodis,Ltbrttov, & - Lrttov_cld, Lrttov_cldparam, Lrttov_aer, Lrttov_aerparam, & ! JKS - Lrttov_rad, Lrttov_localtime, & ! JKS + Lreffclimodis,Lpctmodis,Llwpmodis,Liwpmodis,Lclmodis, & + Lrttov_bt, Lrttov_rad, Lrttov_refl, & ! RTTOV output fields + Lrttov_cld, Lrttov_cldparam,Lrttov_aer, Lrttov_aerparam, & ! RTTOV cld/aero + Lrttov_localtime, & ! RTTOV other Lptradarflag0,Lptradarflag1,Lptradarflag2,Lptradarflag3, & Lptradarflag4,Lptradarflag5,Lptradarflag6,Lptradarflag7, & Lptradarflag8,Lptradarflag9,Lradarpia, & @@ -378,11 +385,13 @@ program cosp2_test Lptradarflag6 .or. Lptradarflag7 .or. Lptradarflag8 .or. Lptradarflag9 .or. & Lradarpia) Lcloudsat = .true. if (Lparasolrefl) Lparasol = .true. - if ((Ltbrttov) .and. (rttov_input_namelist /= 'false')) Lrttov = .true. - if ((Ltbrttov) .and. (rttov_input_namelist .eq. 'false')) then - print*,'Ltbrttov must be true and a RTTOV namelist must be provided to run RTTOV.' - Lrttov = .false. - Ltbrttov = .false. + if ((Lrttov_bt .or. Lrttov_rad .or. Lrttov_refl) .and. (rttov_input_namelist /= 'false')) Lrttov = .true. + if ((Lrttov_bt .or. Lrttov_rad .or. Lrttov_refl) .and. (rttov_input_namelist .eq. 'false')) then + print*,'An RTTOV output must be true and a RTTOV namelist must be provided to run RTTOV.' + Lrttov = .false. + Lrttov_bt = .false. + Lrttov_rad = .false. + Lrttov_refl = .false. endif !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -417,8 +426,8 @@ program cosp2_test cloudsat_do_ray, isccp_topheight, isccp_topheight_direction, surface_radar, & rcfg_cloudsat, use_vgrid, csat_vgrid, Nlvgrid, Nlevels, cloudsat_micro_scheme, & rttov_platform, rttov_satellite, rttov_Instrument, rttov_Nchannels, & ! JKS added RTTOV inputs here - rttov_Channels,Lrttov_cld, Lrttov_aer, Lrttov_rad, Lrttov_cldparam, & - Lrttov_aerparam,rttov_input_namelist) ! options RTTOV argument + rttov_Channels, Lrttov_bt, Lrttov_rad, Lrttov_refl, Lrttov_cld, Lrttov_aer, & + Lrttov_cldparam, Lrttov_aerparam,rttov_input_namelist) ! options RTTOV argument call cpu_time(driver_time(3)) !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -445,9 +454,10 @@ program cosp2_test Lclcalipsoopacity, Lclopaquetemp, Lclthintemp, Lclzopaquetemp, Lclopaquemeanz, & Lclthinmeanz, Lclthinemis, Lclopaquemeanzse, Lclthinmeanzse, Lclzopaquecalipsose, & LcfadDbze94, Ldbze94, Lparasolrefl, & - Ltbrttov, Lptradarflag0,Lptradarflag1,Lptradarflag2,Lptradarflag3,Lptradarflag4, & + Lptradarflag0,Lptradarflag1,Lptradarflag2,Lptradarflag3,Lptradarflag4, & Lptradarflag5,Lptradarflag6,Lptradarflag7,Lptradarflag8,Lptradarflag9,Lradarpia, & Lwr_occfreq, Lcfodd, & + Lrttov_bt, Lrttov_rad, Lrttov_refl, & Npoints, Ncolumns, Nlevels, Nlvgrid_local, rttov_Nchannels, cospOUT) !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1121,10 +1131,11 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& Lclzopaquetemp,Lclopaquemeanz,Lclthinmeanz, & Lclthinemis,Lclopaquemeanzse,Lclthinmeanzse, & Lclzopaquecalipsose,LcfadDbze94,Ldbze94,Lparasolrefl,& - Ltbrttov, Lptradarflag0,Lptradarflag1,Lptradarflag2, & + Lptradarflag0,Lptradarflag1,Lptradarflag2, & Lptradarflag3,Lptradarflag4,Lptradarflag5, & Lptradarflag6,Lptradarflag7,Lptradarflag8, & Lptradarflag9,Lradarpia,Lwr_occfreq,Lcfodd, & + Lrttov_bt,Lrttov_rad,Lrttov_refl, & Npoints,Ncolumns,Nlevels,Nlvgrid,Nchan,x) ! Inputs logical,intent(in) :: & @@ -1222,7 +1233,9 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& LcfadDbze94, & ! CLOUDSAT radar reflectivity CFAD Ldbze94, & ! CLOUDSAT radar reflectivity LparasolRefl, & ! PARASOL reflectance - Ltbrttov, & ! RTTOV mean clear-sky brightness temperature + Lrttov_bt, & ! RTTOV mean clear-sky brightness temperature + Lrttov_rad, & ! RTTOV mean clear-sky radiances + Lrttov_refl, & ! RTTOV mean clear-sky radiances Lptradarflag0, & ! CLOUDSAT Lptradarflag1, & ! CLOUDSAT Lptradarflag2, & ! CLOUDSAT @@ -1396,8 +1409,20 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& if (Lcloudsat_tcc) allocate(x%cloudsat_tcc(Npoints)) if (Lcloudsat_tcc2) allocate(x%cloudsat_tcc2(Npoints)) - ! RTTOV - if (Ltbrttov) allocate(x%rttov_tbs(Npoints,Nchan)) + ! RTTOV - Only add non-total fields if clouds or aerosols are simulated + if (Lrttov_bt) then ! Brightness temp + allocate(x%rttov_bt_total(Npoints,Nchan)) + if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_bt_clear(Npoints,Nchan)) + endif + if (Lrttov_rad) then ! Radiance + allocate(x%rttov_rad_total(Npoints,Nchan)) + if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_rad_clear(Npoints,Nchan)) + if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_rad_cloudy(Npoints,Nchan)) + endif + if (Lrttov_refl) then ! Reflectance + allocate(x%rttov_refl_total(Npoints,Nchan)) + if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_refl_clear(Npoints,Nchan)) + endif ! Joint MODIS/CloudSat Statistics if (Lwr_occfreq) allocate(x%wr_occfreq_ntotal(Npoints,WR_NREGIME)) @@ -1697,10 +1722,6 @@ subroutine destroy_cosp_outputs(y) deallocate(y%misr_cldarea) nullify(y%misr_cldarea) endif - if (associated(y%rttov_tbs)) then - deallocate(y%rttov_tbs) - nullify(y%rttov_tbs) - endif if (associated(y%modis_Cloud_Fraction_Total_Mean)) then deallocate(y%modis_Cloud_Fraction_Total_Mean) nullify(y%modis_Cloud_Fraction_Total_Mean) @@ -1789,7 +1810,36 @@ subroutine destroy_cosp_outputs(y) deallocate(y%wr_occfreq_ntotal) nullify(y%wr_occfreq_ntotal) endif - + + ! RTTOV + if (associated(y%rttov_bt_total)) then + deallocate(y%rttov_bt_total) + nullify(y%rttov_bt_total) + endif + if (associated(y%rttov_bt_clear)) then + deallocate(y%rttov_bt_clear) + nullify(y%rttov_bt_clear) + endif + if (associated(y%rttov_rad_total)) then + deallocate(y%rttov_rad_total) + nullify(y%rttov_rad_total) + endif + if (associated(y%rttov_rad_clear)) then + deallocate(y%rttov_rad_clear) + nullify(y%rttov_rad_clear) + endif + if (associated(y%rttov_rad_cloudy)) then + deallocate(y%rttov_rad_cloudy) + nullify(y%rttov_rad_cloudy) + endif + if (associated(y%rttov_refl_total)) then + deallocate(y%rttov_refl_total) + nullify(y%rttov_refl_total) + endif + if (associated(y%rttov_refl_clear)) then + deallocate(y%rttov_refl_clear) + nullify(y%rttov_refl_clear) + endif end subroutine destroy_cosp_outputs end program cosp2_test diff --git a/src/cosp.F90 b/src/cosp.F90 index c3a243113f..5c03f2d077 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -301,7 +301,13 @@ MODULE MOD_COSP ! RTTOV outputs - JKS consider clear-sky and cloudy-sky values here real(wp),pointer :: & - rttov_tbs(:,:) => null() ! Brightness Temperature + rttov_bt_total(:,:) => null(), & ! Brightness Temperature + rttov_bt_clear(:,:) => null(), & ! Brightness Temperature + rttov_rad_total(:,:) => null(), & ! Brightness Temperature + rttov_rad_clear(:,:) => null(), & ! Brightness Temperature + rttov_rad_cloudy(:,:) => null(), & ! Brightness Temperature + rttov_refl_total(:,:) => null(), & ! Brightness Temperature + rttov_refl_clear(:,:) => null() ! Brightness Temperature ! Joint CloudSat+MODIS simulators outputs real(wp),dimension(:,:,:,:),pointer :: & @@ -387,7 +393,9 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) misr_boxtau,misr_boxztop,misr_dist_model_layertops,isccp_boxtau, & isccp_boxttop,isccp_boxptop,calipso_beta_mol,lidar_only_freq_cloud, & grLidar532_beta_mol,atlid_beta_mol, & - rttovTb ! JKS RTTOV + rttov_bt_total,rttov_bt_clear, & ! RTTOV brightness temps + rttov_rad_total,rttov_rad_clear,rttov_rad_cloudy, & ! RTTOV radiances + rttov_refl_total,rttov_refl_clear ! RTTOV reflectances REAL(WP), dimension(:,:,:),allocatable :: & modisJointHistogram,modisJointHistogramIce,modisJointHistogramLiq, & calipso_beta_tot,calipso_betaperp_tot, cloudsatDBZe,parasolPix_refl, & @@ -507,7 +515,13 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) Lparasol_subcolumn = .true. ! RTTOV column - if (associated(cospOUT%rttov_tbs)) & + if (associated(cospOUT%rttov_bt_total) .or. & + associated(cospOUT%rttov_bt_clear) .or. & + associated(cospOUT%rttov_rad_total) .or. & + associated(cospOUT%rttov_rad_clear) .or. & + associated(cospOUT%rttov_rad_cloudy) .or. & + associated(cospOUT%rttov_refl_total) .or. & + associated(cospOUT%rttov_refl_clear)) & Lrttov_column = .true. ! Set flag to deallocate rttov types (only done on final call to simulator) @@ -1536,22 +1550,50 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! RTTOV if (Lrttov_column) then - ! Allocate memory for the outputs - allocate(rttovTb(rttovIN%Npoints,rttovIN%Nchannels)) + ! Allocate memory for the outputs - I won't need all of these in every situation + allocate(rttov_bt_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky brightness temp + allocate(rttov_bt_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky brightness temp + allocate(rttov_rad_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky brightness temp + allocate(rttov_rad_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky brightness temp + allocate(rttov_rad_cloudy(rttovIN%Npoints,rttovIN%Nchannels)) ! cloudy-sky brightness temp + allocate(rttov_refl_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky Bi-directional reflectance factor + allocate(rttov_refl_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky Bi-directional reflectance factor ! JKS new RTTOV subroutine for v13 called from the RTTOV interface. call cpu_time(driver_time(3)) ! Run simulator - call cosp_rttov_simulate(rttovIN,Lrttov_cleanUp,rttovTb,cosp_simulator(nError+1)) + call cosp_rttov_simulate(rttovIN,Lrttov_cleanUp, & ! Inputs + rttov_bt_total,rttov_bt_clear, & ! Brightness Temp Outputs + rttov_rad_total,rttov_rad_clear,rttov_rad_cloudy, & ! Radiance Outputs + rttov_refl_total,rttov_refl_clear, & ! Reflectance Outputs + cosp_simulator(nError+1)) call cpu_time(driver_time(4)) print*,'Time to run RTTOV: ',driver_time(4)-driver_time(3) ! Write to cospOUT - if (associated(cospOUT%rttov_tbs)) & - cospOUT%rttov_tbs(ij:ik,:) = rttovTb - + if (associated(cospOUT%rttov_bt_total)) & + cospOUT%rttov_bt_total(ij:ik,:) = rttov_bt_total + if (associated(cospOUT%rttov_bt_clear)) & + cospOUT%rttov_bt_clear(ij:ik,:) = rttov_bt_clear + if (associated(cospOUT%rttov_rad_total)) & + cospOUT%rttov_rad_total(ij:ik,:) = rttov_rad_total + if (associated(cospOUT%rttov_rad_clear)) & + cospOUT%rttov_rad_clear(ij:ik,:) = rttov_rad_clear + if (associated(cospOUT%rttov_rad_cloudy)) & + cospOUT%rttov_rad_cloudy(ij:ik,:) = rttov_rad_cloudy + if (associated(cospOUT%rttov_refl_total)) & + cospOUT%rttov_refl_total(ij:ik,:) = rttov_refl_total + if (associated(cospOUT%rttov_refl_clear)) & + cospOUT%rttov_refl_clear(ij:ik,:) = rttov_refl_clear + ! Free up memory from output (if necessary) - if (allocated(rttovTb)) deallocate(rttovTb) + if (allocated(rttov_bt_total)) deallocate(rttov_bt_total) + if (allocated(rttov_bt_clear)) deallocate(rttov_bt_clear) + if (allocated(rttov_rad_total)) deallocate(rttov_rad_total) + if (allocated(rttov_rad_clear)) deallocate(rttov_rad_clear) + if (allocated(rttov_rad_cloudy)) deallocate(rttov_rad_cloudy) + if (allocated(rttov_refl_total)) deallocate(rttov_refl_total) + if (allocated(rttov_refl_clear)) deallocate(rttov_refl_clear) endif print*,'Lrttov_column successful' ! jks @@ -1776,12 +1818,15 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La isccp_top_height, isccp_top_height_direction, surface_radar, rcfg, lusevgrid, & luseCSATvgrid, Nvgrid, Nlevels, cloudsat_micro_scheme, & NchanIN, platformIN, satelliteIN, instrumentIN, channelsIN, & - Lrttov_cld, Lrttov_aer, Lrttov_rad, Lrttov_cldparam, Lrttov_aerparam, & + Lrttov_bt, Lrttov_rad, Lrttov_refl, & + Lrttov_cld, Lrttov_aer, Lrttov_cldparam, Lrttov_aerparam, & rttov_input_namelist) ! INPUTS logical,intent(in) :: Lisccp,Lmodis,Lmisr,Lcloudsat,Lcalipso,LgrLidar532,Latlid,Lparasol,Lrttov - logical,intent(in) :: Lrttov_cld, Lrttov_aer, Lrttov_rad, Lrttov_cldparam, Lrttov_aerparam + logical,intent(in) :: & + Lrttov_bt, Lrttov_rad, Lrttov_refl, & + Lrttov_cld, Lrttov_aer, Lrttov_cldparam, Lrttov_aerparam ! JKS to-do ! type(rttov_init_in),intent(in) :: rttov_init_IN integer,intent(in) :: & @@ -1860,11 +1905,11 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La ! Could print diagnostic on timing here. if (Lrttov) then call cpu_time(driver_time(1)) - call cosp_rttov_init(NchanIN,platformIN,satelliteIN, & - instrumentIN,channelsIN,Nlevels, & - Lrttov_cld,Lrttov_aer, & - Lrttov_rad,Lrttov_cldparam, & - Lrttov_aerparam, & + call cosp_rttov_init(NchanIN,platformIN,satelliteIN, & + instrumentIN,channelsIN,Nlevels, & + Lrttov_bt,Lrttov_rad,Lrttov_refl, & + Lrttov_cld,Lrttov_aer, & + Lrttov_cldparam,Lrttov_aerparam, & rttov_input_namelist) call cpu_time(driver_time(2)) print*,'Time to run cosp_rttov_init: ',driver_time(2)-driver_time(1) @@ -2612,7 +2657,13 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, endif if (.not. alloc_status) then Lrttov_column = .false. - if (associated(cospOUT%rttov_tbs)) cospOUT%rttov_tbs(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF endif endif @@ -2710,7 +2761,13 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lcloudsat_tcc = .false. Lcloudsat_tcc2 = .false. Lcloudsat_modis_wr = .false. - if (associated(cospOUT%rttov_tbs)) cospOUT%rttov_tbs(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF if (associated(cospOUT%isccp_totalcldarea)) cospOUT%isccp_totalcldarea(:) = R_UNDEF if (associated(cospOUT%isccp_meantb)) cospOUT%isccp_meantb(:) = R_UNDEF if (associated(cospOUT%isccp_meantbclr)) cospOUT%isccp_meantbclr(:) = R_UNDEF @@ -2752,7 +2809,13 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lisccp_subcolumn = .false. Lisccp_column = .false. Lrttov_column = .false. - if (associated(cospOUT%rttov_tbs)) cospOUT%rttov_tbs(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF if (associated(cospOUT%isccp_totalcldarea)) cospOUT%isccp_totalcldarea(:) = R_UNDEF if (associated(cospOUT%isccp_meantb)) cospOUT%isccp_meantb(:) = R_UNDEF if (associated(cospOUT%isccp_meantbclr)) cospOUT%isccp_meantbclr(:) = R_UNDEF @@ -2777,7 +2840,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lrttov_column = .false. Latlid_column = .false. LgrLidar532_column = .false. - if (associated(cospOUT%rttov_tbs)) cospOUT%rttov_tbs(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF if (associated(cospOUT%isccp_totalcldarea)) cospOUT%isccp_totalcldarea(:) = R_UNDEF if (associated(cospOUT%isccp_meantb)) cospOUT%isccp_meantb(:) = R_UNDEF if (associated(cospOUT%isccp_meantbclr)) cospOUT%isccp_meantbclr(:) = R_UNDEF @@ -2854,7 +2917,13 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lisccp_subcolumn = .false. Lisccp_column = .false. Lrttov_column = .false. - if (associated(cospOUT%rttov_tbs)) cospOUT%rttov_tbs(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF if (associated(cospOUT%isccp_totalcldarea)) cospOUT%isccp_totalcldarea(:) = R_UNDEF if (associated(cospOUT%isccp_meantb)) cospOUT%isccp_meantb(:) = R_UNDEF if (associated(cospOUT%isccp_meantbclr)) cospOUT%isccp_meantbclr(:) = R_UNDEF @@ -2931,7 +3000,13 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Latlid_column = .false. LgrLidar532_column = .false. Lcloudsat_modis_wr = .false. - if (associated(cospOUT%rttov_tbs)) cospOUT%rttov_tbs(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF if (associated(cospOUT%calipso_cfad_sr)) cospOUT%calipso_cfad_sr(:,:,:) = R_UNDEF if (associated(cospOUT%calipso_lidarcld)) cospOUT%calipso_lidarcld(:,:) = R_UNDEF if (associated(cospOUT%calipso_lidarcldphase)) cospOUT%calipso_lidarcldphase(:,:,:) = R_UNDEF @@ -2966,7 +3041,13 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lrttov_column = .false. Lcalipso_column = .false. Lparasol_column = .false. - if (associated(cospOUT%rttov_tbs)) cospOUT%rttov_tbs(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF if (associated(cospOUT%calipso_cfad_sr)) cospOUT%calipso_cfad_sr(:,:,:) = R_UNDEF if (associated(cospOUT%calipso_lidarcld)) cospOUT%calipso_lidarcld(:,:) = R_UNDEF if (associated(cospOUT%calipso_lidarcldphase)) cospOUT%calipso_lidarcldphase(:,:,:) = R_UNDEF @@ -2989,7 +3070,13 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lisccp_subcolumn = .false. Lisccp_column = .false. Lrttov_column = .false. - if (associated(cospOUT%rttov_tbs)) cospOUT%rttov_tbs(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF if (associated(cospOUT%isccp_totalcldarea)) cospOUT%isccp_totalcldarea(:) = R_UNDEF if (associated(cospOUT%isccp_meantb)) cospOUT%isccp_meantb(:) = R_UNDEF if (associated(cospOUT%isccp_meantbclr)) cospOUT%isccp_meantbclr(:) = R_UNDEF @@ -3008,61 +3095,121 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%zenang contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_tbs)) cospOUT%rttov_tbs(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF endif if (cospgridIN%co2 .lt. 0) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%co2 contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_tbs)) cospOUT%rttov_tbs(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF endif if (cospgridIN%ch4 .lt. 0) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%ch4 contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_tbs)) cospOUT%rttov_tbs(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF endif if (cospgridIN%n2o .lt. 0) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%n2o contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_tbs)) cospOUT%rttov_tbs(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF endif if (cospgridIN%co.lt. 0) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%co contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_tbs)) cospOUT%rttov_tbs(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF endif if (any(cospgridIN%o3 .lt. 0)) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%o3 contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_tbs)) cospOUT%rttov_tbs(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF endif if (any(cospgridIN%emis_sfc .lt. 0. .OR. cospgridIN%emis_sfc .gt. 1)) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%emis_sfc contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_tbs)) cospOUT%rttov_tbs(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF endif if (any(cospgridIN%u_sfc .lt. -100. .OR. cospgridIN%u_sfc .gt. 100.)) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospIN%u_sfc contains values out of range' - if (associated(cospOUT%rttov_tbs)) cospOUT%rttov_tbs(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF Lrttov_column = .false. endif if (any(cospgridIN%v_sfc .lt. -100. .OR. cospgridIN%v_sfc .gt. 100.)) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospIN%v_sfc contains values out of range' + if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF Lrttov_column = .false. - if (associated(cospOUT%rttov_tbs)) cospOUT%rttov_tbs(:,:) = R_UNDEF endif if (any(cospgridIN%lat .lt. -90 .OR. cospgridIN%lat .gt. 90)) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospIN%lat contains values out of range' + if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF Lrttov_column = .false. - if (associated(cospOUT%rttov_tbs)) cospOUT%rttov_tbs(:,:) = R_UNDEF endif endif diff --git a/src/simulator/cosp_rttov_interfaceSTUB.F90 b/src/simulator/cosp_rttov_interfaceSTUB.F90 index ce13b11ef9..a8e0db0f72 100644 --- a/src/simulator/cosp_rttov_interfaceSTUB.F90 +++ b/src/simulator/cosp_rttov_interfaceSTUB.F90 @@ -68,8 +68,8 @@ MODULE MOD_COSP_RTTOV_INTERFACE ! SUBROUTINE cosp_rttov_init !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN, & - nlevels,Lrttov_cld,Lrttov_aer,Lrttov_rad,Lrttov_cldparam, & - Lrttov_aerparam, & + nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, & + Lrttov_cld,Lrttov_aer,Lrttov_cldparam,Lrttov_aerparam, & rttov_input_namelist) integer,intent(in) :: & NchanIN, & ! Number of channels @@ -80,11 +80,13 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI integer,intent(in),dimension(RTTOV_MAX_CHANNELS) :: & channelsIN ! RTTOV channels logical,intent(in) :: & + Lrttov_bt, & + Lrttov_rad, & + Lrttov_refl, & Lrttov_cld, & Lrttov_aer, & - Lrttov_rad, & Lrttov_cldparam, & - Lrttov_aerparam + Lrttov_aerparam ! JKS testing using a RTTOV input namelist here character(len=256),intent(in) :: rttov_input_namelist @@ -97,17 +99,26 @@ END SUBROUTINE COSP_RTTOV_INIT !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_simulate !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, & ! Inputs - Tb,error) ! Outputs + SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, & ! Inputs + bt_total,bt_clear, & ! Brightness Temp Outputs + rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs + refl_total,refl_clear, & ! Reflectance Outputs + error) type(rttov_in),intent(in) :: & rttovIN logical,intent(in) :: & lCleanup ! Flag to determine whether to deallocate RTTOV types real(wp),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! - Tb ! RTTOV brightness temperature. + bt_total, & ! All-sky + bt_clear, & ! Clear-sky + rad_total, & ! All-sky + rad_clear, & ! Clear-sky + rad_cloudy, & ! Cloudy-sky + refl_total, & ! All-sky + refl_clear ! Clear-sky character(len=128) :: & - error ! Error messages (only populated if error encountered) + error ! Error messages (only populated if error encountered) print*,'Running COSP_RTTOV_SIMULATE from STUB files.', & diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index a3c1da9d82..483bcbeed9 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -35,8 +35,10 @@ MODULE MOD_COSP_RTTOV_INTERFACE USE MOD_COSP_CONFIG, ONLY: RTTOV_MAX_CHANNELS,rttovDir use mod_cosp_rttov, only: platform,satellite,sensor,nChannels,iChannel,coef_rttov, & opts,construct_rttov_coeffilename,rttov_in, & - construct_rttov_scatfilename,do_rttov_cld,do_rttov_aer, & - do_rttov_rad,rttov_cld_optparam,rttov_aer_optparam + construct_rttov_scatfilename, & + do_rttov_bt,do_rttov_rad,do_rttov_refl, & + do_rttov_cld,do_rttov_aer,rttov_cld_optparam,rttov_aer_optparam + ! rttov_const contains useful RTTOV constants USE rttov_const, ONLY : & @@ -79,9 +81,11 @@ MODULE MOD_COSP_RTTOV_INTERFACE type rttov_init_IN logical,pointer :: & + Lrttov_bt, & + Lrttov_rad, & + Lrttov_refl, & Lrttov_cld, & Lrttov_aer, & - Lrttov_rad, & Lrttov_cldparam, & Lrttov_aerparam integer,pointer :: & @@ -99,8 +103,8 @@ MODULE MOD_COSP_RTTOV_INTERFACE ! SUBROUTINE cosp_rttov_init !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN, & - nlevels,Lrttov_cld,Lrttov_aer,Lrttov_rad,Lrttov_cldparam, & - Lrttov_aerparam, & + nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, & + Lrttov_cld,Lrttov_aer,Lrttov_cldparam,Lrttov_aerparam, & rttov_input_namelist) integer,intent(in) :: & NchanIN, & ! Number of channels @@ -111,9 +115,11 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI integer,intent(in),dimension(RTTOV_MAX_CHANNELS) :: & channelsIN ! RTTOV channels logical,intent(in) :: & + Lrttov_bt, & + Lrttov_rad, & + Lrttov_refl, & Lrttov_cld, & Lrttov_aer, & - Lrttov_rad, & Lrttov_cldparam, & Lrttov_aerparam @@ -166,9 +172,11 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI iChannel = channelsIN ! Set logicals for RTTOV options + do_rttov_bt = Lrttov_bt + do_rttov_rad = Lrttov_rad + do_rttov_refl = Lrttov_refl do_rttov_cld = Lrttov_cld do_rttov_aer = Lrttov_aer - do_rttov_rad = Lrttov_rad ! to be used in output rttov_cld_optparam = Lrttov_cldparam rttov_aer_optparam = Lrttov_aerparam @@ -302,9 +310,9 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI aer_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(aer_coef_filepath) cld_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(cld_coef_filepath) - print*,'OD_coef_filepath: ',OD_coef_filepath - print*,'aer_coef_filepath: ',aer_coef_filepath - print*,'cld_coef_filepath: ',cld_coef_filepath +! print*,'OD_coef_filepath: ',OD_coef_filepath +! print*,'aer_coef_filepath: ',aer_coef_filepath +! print*,'cld_coef_filepath: ',cld_coef_filepath ! Read optical depth and cloud coefficient files together call rttov_read_coefs(errorstatus, coef_rttov, opts, & @@ -326,31 +334,7 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI ! We aren't checking an allocation steps so this seems more appropriate. call rttov_error('error in rttov options' , lalloc = .false.) - - ! Old code - ! coef_file = trim(rttovDir)//"rtcoef_rttov11/rttov7pred54L/"// & - ! trim(construct_rttov_coeffilename(platform,satellite,sensor)) - - ! Read in scattering (clouds+aerosol) coefficient file. *ONLY NEEDED IF DOING RTTOV ALL-SKY.* - !scat_file = trim(rttovDir)//"rtcoef_rttov11/cldaer/"//& - ! trim(construct_rttov_scatfilename(platform,satellite,sensor)) - ! Can't pass filename to rttov_read_scattcoeffs!!!!! - !call rttov_read_scattcoeffs (errorstatus, coef_rttov%coef, coef_scatt,) - -!!!! Old version - - ! Read in scattering coefficient file. -! coef_file = trim(rttovDir)//"rtcoef_rttov11/rttov7pred54L/"// & -! trim(construct_rttov_coeffilename(platform,satellite,sensor)) -! call rttov_read_coefs(errorstatus,coef_rttov, opts, file_coef=trim(coef_file)) - - ! Read in scattering (clouds+aerosol) coefficient file. *ONLY NEEDED IF DOING RTTOV ALL-SKY.* - !scat_file = trim(rttovDir)//"rtcoef_rttov11/cldaer/"//& - ! trim(construct_rttov_scatfilename(platform,satellite,sensor)) - ! Can't pass filename to rttov_read_scattcoeffs!!!!! - !call rttov_read_scattcoeffs (errorstatus, coef_rttov%coef, coef_scatt,) - - + ! subsub routines contains ! Wrapper function for exiting RTTOV and reporting the error @@ -377,8 +361,11 @@ END SUBROUTINE COSP_RTTOV_INIT !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_simulate - Call subroutines in mod_cosp_rttov to run RTTOV !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, & ! Inputs - Tb,error) ! Outputs + SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, & ! Inputs + bt_total,bt_clear, & ! Brightness Temp Outputs + rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs + refl_total,refl_clear, & ! Reflectance Outputs + error) use mod_cosp_rttov, only: & cosp_rttov_allocate, & @@ -393,35 +380,43 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, & ! Inputs logical,intent(in) :: & lCleanup ! Flag to determine whether to deallocate RTTOV types real(wp),intent(inout),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! - Tb ! RTTOV brightness temperature. + bt_total, & ! All-sky + bt_clear, & ! Clear-sky + rad_total, & ! All-sky + rad_clear, & ! Clear-sky + rad_cloudy, & ! Cloudy-sky + refl_total, & ! All-sky + refl_clear ! Clear-sky character(len=128) :: & error ! Error messages (only populated if error encountered) - logical :: & - rttov_simulate_cld, & - rttov_simulate_aer + integer(kind=jpim) :: nthreads ! Parallelization, should become an input real(wp),dimension(10) :: driver_time ! Run each step for running RTTOV from mod_cosp_rttov (and time them) - print*,'cosp_rttov_allocate begin' ! jks +! print*,'cosp_rttov_allocate begin' ! jks call cpu_time(driver_time(1)) call cosp_rttov_allocate(rttovIN) - print*,'cosp_rttov_allocate successful' ! jks +! print*,'cosp_rttov_allocate successful' ! jks call cpu_time(driver_time(2)) call cosp_rttov_construct_profiles(rttovIN) - print*,'cosp_rttov_construct_profiles successful' ! jks +! print*,'cosp_rttov_construct_profiles successful' ! jks call cpu_time(driver_time(3)) call cosp_rttov_setup_emissivity_reflectance() - print*,'cosp_rttov_setup_emissivity_reflectance successful' ! jks +! print*,'cosp_rttov_setup_emissivity_reflectance successful' ! jks call cpu_time(driver_time(4)) call cosp_rttov_call_direct(nthreads) - print*,'cosp_rttov_call_direct successful' ! jks +! print*,'cosp_rttov_call_direct successful' ! jks call cpu_time(driver_time(5)) - call cosp_rttov_save_and_deallocate_profiles(rttovIN,Tb) - print*,'cosp_rttov_save_and_deallocate_profiles successful' ! jks + + call cosp_rttov_save_and_deallocate_profiles(rttovIN, & + bt_total,bt_clear, & + rad_total,rad_clear,rad_cloudy, & + refl_total,refl_clear) +! print*,'cosp_rttov_save_and_deallocate_profiles successful' ! jks call cpu_time(driver_time(6)) - print*,'RTTOV Tb output: ',Tb +! print*,'RTTOV Tb output: ',bt_total print*,'Time to run "cosp_rttov_allocate": ', driver_time(2)-driver_time(1) print*,'Time to run "cosp_rttov_construct_profiles": ', driver_time(3)-driver_time(2) @@ -437,7 +432,7 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, & ! Inputs print*,'Time to run "cosp_rttov_deallocate_coefs": ',driver_time(8)-driver_time(7) endif - print*,'Total RTTOV run time: ',driver_time(8)-driver_time(1) +! print*,'Total RTTOV run time: ',driver_time(8)-driver_time(1) END SUBROUTINE COSP_RTTOV_SIMULATE diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 05cd2ea151..68d969b4cf 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -127,7 +127,9 @@ module mod_cosp_rttov logical :: & do_rttov_cld, & ! Include clouds in RTTOV calculations do_rttov_aer, & ! Include aerosols in RTTOV calculations + do_rttov_bt, & ! Return brightness temps in RTTOV calculations do_rttov_rad, & ! Return radiances in RTTOV calculations + do_rttov_refl, & ! Return reflectances in RTTOV calculations rttov_cld_optparam, & ! Use user-supplied optical cloud parameters rttov_aer_optparam ! Use user-supplied optical aerosol parameters @@ -559,29 +561,67 @@ end subroutine cosp_rttov_call_direct ! rttov_save_and_deallocate - 8. Save output data, 9. Deallocate all RTTOV arrays and structures ! ------------------------------------------------------ ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_rttov_save_and_deallocate_profiles(rttovIN,Tb) - + subroutine cosp_rttov_save_and_deallocate_profiles(rttovIN, & + bt_total,bt_clear, & + rad_total,rad_clear,rad_cloudy, & + refl_total,refl_clear) type(rttov_in),intent(in) :: & rttovIN real(wp),dimension(rttovIN%nPoints,rttovIN%nChannels),intent(inout) :: & ! Can I do this? I guess so! - Tb ! RTTOV brightness temperature. - + bt_total, & ! RTTOV brightness temperature. + bt_clear, & + rad_total, & + rad_clear, & + rad_cloudy, & + refl_total, & + refl_clear ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 8. Save output data ! ------------------------------------------------------ ! JKS - Need to allow options for Tb and radiance for clear- and cloudy-skies ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - Tb(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & - transpose(reshape(radiance%bt(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) +! print *,"present check: ",present(four),present(five) + + ! Documentation for RTTOV radiance structure in RTTOV User Guide pg 166 + + ! Only save output if appropriate + if (do_rttov_bt) then + bt_total(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & + transpose(reshape(radiance%bt(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) + endif + if (do_rttov_bt .and. (do_rttov_cld .or. do_rttov_aer)) then + bt_clear(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & + transpose(reshape(radiance%bt_clear(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) + endif + if (do_rttov_rad) then + rad_total(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & + transpose(reshape(radiance%total(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) + endif + if (do_rttov_rad .and. (do_rttov_cld .or. do_rttov_aer)) then + rad_clear(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & + transpose(reshape(radiance%clear(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) + rad_cloudy(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & + transpose(reshape(radiance%cloudy(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) + endif + + if (do_rttov_refl) then + refl_total(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & + transpose(reshape(radiance%refl(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) + endif + if (do_rttov_refl .and. (do_rttov_cld .or. do_rttov_aer)) then + bt_clear(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & + transpose(reshape(radiance%refl_clear(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) + endif + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 9. Deallocate all RTTOV arrays and structures ! ------------------------------------------------------ ! From RTTOV example files. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! JKS no longer using channel_list + ! JKS no longer using channel_list, rttovIN%channels instead !deallocate (channel_list, stat=alloc_status(1)) !if (alloc_status(1) /= 0) then ! write(*,*) 'mem dellocation error' From f4c0d5d3ce28800cbb23f7d412a7bef108641a59 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Thu, 23 Mar 2023 15:23:53 -0600 Subject: [PATCH 039/159] Update .gitignore to ignore anything in a .ipynb_checkpoints/ directory --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 64b2537769..5e2719567d 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ driver/run/cosp2_test # Ignore changes to the testing files for data *.nc + +# Ignore anything in a .ipynb_checkpoint directory +**/.ipynb_checkpoints/* From 0488632c53e0874e2b26089e48d964b3087eb627 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Thu, 23 Mar 2023 15:53:37 -0600 Subject: [PATCH 040/159] Added degree of parallelization via the namelist Slower with parallelization when on a login node. Will need to test more later. --- driver/run/cosp2_input_rttov_nl.txt | 4 ++-- driver/run/cosp2_rttov_nl.txt | 1 + src/simulator/cosp_rttov_interface_v13.F90 | 17 +++++++++++------ src/simulator/rttov/cosp_rttov_v13.F90 | 16 +++++++--------- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/driver/run/cosp2_input_rttov_nl.txt b/driver/run/cosp2_input_rttov_nl.txt index 73829530e8..6510f5c6f8 100644 --- a/driver/run/cosp2_input_rttov_nl.txt +++ b/driver/run/cosp2_input_rttov_nl.txt @@ -87,7 +87,7 @@ rttov_Instrument=5, ! instrument rttov_Nchannels=15, ! Number of channels to be computed rttov_Channels=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, ! Channel numbers (please be sure that you supply Nchannels) - rttov_Surfem=0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, ! Surface emissivity (please be sure that you supply Nchannels) + rttov_Surfem=0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, ! Surface emissivity (please be sure that you supply Nchannels channels) rttov_ZenAng=50.0, ! Satellite Zenith Angle CO2=5.241e-04, ! Mixing ratios of trace gases CH4=9.139e-07, @@ -95,5 +95,5 @@ CO=2.098e-07, rttov_Nlocaltime=2, rttov_localtime=10.0,13.0, ! To implement local time - rttov_localtimewindow=1.0,1.0 ! To implement local time width + rttov_localtimewindow=1.0,1.0 ! To implement local time width / diff --git a/driver/run/cosp2_rttov_nl.txt b/driver/run/cosp2_rttov_nl.txt index 4cd8c1154e..2ee47a9462 100644 --- a/driver/run/cosp2_rttov_nl.txt +++ b/driver/run/cosp2_rttov_nl.txt @@ -46,6 +46,7 @@ co2_data=.false., ch4_data=.false., ozone_data=.false., + rttov_nthreads=1, ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel !---------------------------------------------------------------------------------- !-------------- RTTOV inputs !---------------------------------------------------------------------------------- diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 483bcbeed9..a875cb88e3 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -37,7 +37,8 @@ MODULE MOD_COSP_RTTOV_INTERFACE opts,construct_rttov_coeffilename,rttov_in, & construct_rttov_scatfilename, & do_rttov_bt,do_rttov_rad,do_rttov_refl, & - do_rttov_cld,do_rttov_aer,rttov_cld_optparam,rttov_aer_optparam + do_rttov_cld,do_rttov_aer,rttov_cld_optparam, & + rttov_aer_optparam,rttov_direct_nthreads ! rttov_const contains useful RTTOV constants @@ -144,12 +145,13 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI ! Declare RTTOV namelist fields logical :: so2_data,n2o_data,co_data,ch4_data,co2_data,ozone_data character(len=256) :: cosp_status - + integer :: rttov_nthreads + ! Read RTTOV namelist fields namelist/RTTOV_INPUT/rttov_coefDir, & OD_coef_filepath, & aer_coef_filepath,cld_coef_filepath,so2_data,n2o_data, & - co_data,ch4_data,co2_data,ozone_data + co_data,ch4_data,co2_data,ozone_data,rttov_nthreads ! rttov_Nlocaltime, rttov_localtime, rttov_localtimewindow !JKS !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -179,6 +181,9 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI do_rttov_aer = Lrttov_aer rttov_cld_optparam = Lrttov_cldparam rttov_aer_optparam = Lrttov_aerparam + + ! Set degree of parallelization + rttov_direct_nthreads = rttov_nthreads ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 1. Initialise RTTOV options structure @@ -373,7 +378,8 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, cosp_rttov_setup_emissivity_reflectance, & cosp_rttov_call_direct, & cosp_rttov_save_and_deallocate_profiles, & - cosp_rttov_deallocate_coefs + cosp_rttov_deallocate_coefs, & + rttov_direct_nthreads type(rttov_in),intent(in) :: & rttovIN @@ -390,7 +396,6 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, character(len=128) :: & error ! Error messages (only populated if error encountered) - integer(kind=jpim) :: nthreads ! Parallelization, should become an input real(wp),dimension(10) :: driver_time ! Run each step for running RTTOV from mod_cosp_rttov (and time them) @@ -405,7 +410,7 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, call cosp_rttov_setup_emissivity_reflectance() ! print*,'cosp_rttov_setup_emissivity_reflectance successful' ! jks call cpu_time(driver_time(4)) - call cosp_rttov_call_direct(nthreads) + call cosp_rttov_call_direct() ! print*,'cosp_rttov_call_direct successful' ! jks call cpu_time(driver_time(5)) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 68d969b4cf..6e7cd0c942 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -112,6 +112,8 @@ module mod_cosp_rttov sensor, & ! RTTOV instrument satellite, & ! RTTOV satellite nChannels ! Number of channels + integer(kind=jpim) :: & ! Parallelization is default off + rttov_direct_nthreads = 1_jpim integer,dimension(RTTOV_MAX_CHANNELS) :: & iChannel ! RTTOV channel numbers @@ -143,7 +145,6 @@ module mod_cosp_rttov ! module-wides variables for input !==================== - integer(kind=jpim) :: nthreads integer(kind=jpim) :: dosolar integer(kind=jpim) :: nchanprof ! JKS - jpim is RTTOV integer type ! integer(kind=jpim), allocatable :: channel_list(:) ! JKS this needs to be specified @@ -517,14 +518,10 @@ end subroutine cosp_rttov_setup_emissivity_reflectance ! ------------------------------------------------------ ! From RTTOV example files. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_rttov_call_direct(nthreads) + subroutine cosp_rttov_call_direct() - integer(kind=jpim) :: nthreads - - nthreads = 1 ! Default not parallel for now. Can be optimized later. - JKS - print*,'Calling rttov_direct' - - if (nthreads <= 1) then + if (rttov_direct_nthreads <= 1) then + print*,'Calling rttov_direct' call rttov_direct( & errorstatus, &! out error flag chanprof, &! in channel and profile index structure @@ -538,6 +535,7 @@ subroutine cosp_rttov_call_direct(nthreads) calcrefl = calcrefl, &! in flag for internal BRDF calcs reflectance = reflectance) ! inout input/output BRDFs per channel else + print*,'Calling rttov_parallel_direct' call rttov_parallel_direct( & errorstatus, &! out error flag chanprof, &! in channel and profile index structure @@ -550,7 +548,7 @@ subroutine cosp_rttov_call_direct(nthreads) emissivity = emissivity, &! inout input/output emissivities per channel calcrefl = calcrefl, &! in flag for internal BRDF calcs reflectance = reflectance,&! inout input/output BRDFs per channel - nthreads = nthreads) ! in number of threads to use + nthreads = rttov_direct_nthreads) ! in number of threads to use endif call rttov_error('rttov_direct error', lalloc = .true.) From e82feb84a61d5d520d8026e59b695003fe4c6d95 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Mon, 27 Mar 2023 14:38:51 -0600 Subject: [PATCH 041/159] Reorganization of namelist and GCM input handling Completely separated RTTOV user inputs (passed from RTTOV namelist file in cosp_rttov_init) from RTTOV input data (from GCM data e.g. UKMO example files). - Simplifies the COSP input namelist if not running RTTOV. - Removes previous dependencies of RTTOV on cosp_config values for array sizing. - Removes depreciated satellite, instrument, and platform inputs from code. - Removes depreciated subroutines for constructing coefficient file names. - Prepares for reading in of long channel index, channel emissivity, and channel reflectivity inputs for hyperspectral sounders. --- driver/run/cosp2_input_rttov_nl.txt | 12 +- driver/run/cosp2_output_rttov_nl.txt | 17 +- driver/run/cosp2_rttov_nl.txt | 52 +++--- driver/src/cosp2_test.F90 | 65 +++----- src/cosp.F90 | 72 ++++----- src/cosp_config.F90 | 7 +- src/simulator/cosp_rttov_interfaceSTUB.F90 | 51 ++---- src/simulator/cosp_rttov_interface_v13.F90 | 104 +++++------- src/simulator/rttov/cosp_rttovSTUB.F90 | 177 +-------------------- src/simulator/rttov/cosp_rttov_v13.F90 | 177 +++++---------------- 10 files changed, 189 insertions(+), 545 deletions(-) diff --git a/driver/run/cosp2_input_rttov_nl.txt b/driver/run/cosp2_input_rttov_nl.txt index 6510f5c6f8..cf40ab7ca1 100644 --- a/driver/run/cosp2_input_rttov_nl.txt +++ b/driver/run/cosp2_input_rttov_nl.txt @@ -82,18 +82,8 @@ !---------------------------------------------------------------------------------- !-------------- RTTOV inputs !---------------------------------------------------------------------------------- - rttov_Platform=1, ! satellite platform - rttov_Satellite=15, ! satellite - rttov_Instrument=5, ! instrument rttov_Nchannels=15, ! Number of channels to be computed - rttov_Channels=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, ! Channel numbers (please be sure that you supply Nchannels) - rttov_Surfem=0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, ! Surface emissivity (please be sure that you supply Nchannels channels) - rttov_ZenAng=50.0, ! Satellite Zenith Angle - CO2=5.241e-04, ! Mixing ratios of trace gases - CH4=9.139e-07, - N2O=4.665e-07, - CO=2.098e-07, rttov_Nlocaltime=2, rttov_localtime=10.0,13.0, ! To implement local time - rttov_localtimewindow=1.0,1.0 ! To implement local time width + rttov_localtimewindow=1.0,1.0, ! To implement local time width / diff --git a/driver/run/cosp2_output_rttov_nl.txt b/driver/run/cosp2_output_rttov_nl.txt index b886a4e7ae..fc50562f28 100755 --- a/driver/run/cosp2_output_rttov_nl.txt +++ b/driver/run/cosp2_output_rttov_nl.txt @@ -133,15 +133,14 @@ Liwpmodis=.true., Lclmodis=.true., !- RTTOV -! Ltbrttov=.true., - Lrttov_bt=.true., - Lrttov_rad=.true., - Lrttov_refl=.true., - Lrttov_cld=.true., - Lrttov_cldparam=.false., - Lrttov_aer=.true., - Lrttov_aerparam=.false., - Lrttov_localtime=.false., + Lrttov_bt=.true., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aer=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_localtime=.false., ! May not be necessary at this level ! -CLOUDSAT precipitation frequency/occurence diagnostics Lptradarflag0=.true., Lptradarflag1=.true., diff --git a/driver/run/cosp2_rttov_nl.txt b/driver/run/cosp2_rttov_nl.txt index 2ee47a9462..eb1fec37ca 100644 --- a/driver/run/cosp2_rttov_nl.txt +++ b/driver/run/cosp2_rttov_nl.txt @@ -25,43 +25,33 @@ ! Namelist that sets up the main COSP options &RTTOV_INPUT - !-------------- RTTOV Outputs - !Ltbrttov=.true., - !Lrttov_cld=.false., - !Lrttov_cldparam=.false., - !Lrttov_aer=.false., - !Lrttov_aerparam=.false., - !Lrttov_rad=.false., - !Lrttov_localtime=.false., !-------------- RTTOV Coefficient Paths !- Paths should be relative to the RTTOVdir path specified in cosp_config.F90 + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', rttov_coefDir='rtcoef_rttov13/' OD_coef_filepath='rttov13pred54L/rtcoef_ticfire_1_mbfiri_o3co2.dat', aer_coef_filepath='cldaer_visir/scaercoef_ticfire_1_mbfiri_cams.dat', cld_coef_filepath='cldaer_visir/sccldcoef_ticfire_1_mbfiri.dat', !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - so2_data=.false., - n2o_data=.false., - co_data=.false., - co2_data=.false., - ch4_data=.false., + SO2_data=.false., + N2O_data=.false., + CO_data=.false., + CO2_data=.false., + CH4_data=.false., ozone_data=.false., - rttov_nthreads=1, ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - !---------------------------------------------------------------------------------- - !-------------- RTTOV inputs - !---------------------------------------------------------------------------------- - !rttov_Platform=1, ! satellite platform - !rttov_Satellite=15, ! satellite - !rttov_Instrument=5, ! instrument - !rttov_Nchannels=3, ! Number of channels to be computed - !rttov_Channels=1,2,3, ! Channel numbers (please be sure that you supply Nchannels) - !rttov_Surfem=0.0,0.0,0.0, ! Surface emissivity (please be sure that you supply Nchannels) - !rttov_ZenAng=50.0, ! Satellite Zenith Angle - !CO2=5.241e-04, ! Mixing ratios of trace gases - !CH4=9.139e-07, - !N2O=4.665e-07, - !CO=2.098e-07, - !rttov_Nlocaltime=2, - !rttov_localtime=10.0,13.0, ! To implement local time - !rttov_localtimewindow=1.0,1.0 ! To implement local time width + !--------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + N2O_mr=4.665e-07, + CO_mr=2.098e-07, + SO2_mr=0.0, + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + ! Channel indices (Nchannels must be supplied in COSP input namelist) + rttov_Channels=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, + ! Surface emissivity (Nchannels must be supplied in COSP input namelist) +! rttov_Surfem=0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, + rttov_ZenAng=50.0, ! Satellite Zenith Angle / diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index b74233a6fd..45786a4562 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -35,7 +35,7 @@ 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, & + N_HYDRO,numMISRHgtBins, & cloudsat_DBZE_BINS,LIDAR_NTEMP,calipso_histBsct, & CFODD_NDBZE, CFODD_NICOD, & CFODD_BNDRE, CFODD_NCLASS, & @@ -52,8 +52,8 @@ program cosp2_test tau_binBoundsV1p4,tau_binEdgesV1p4, tau_binCentersV1p4, & grLidar532_histBsct,atlid_histBsct,vgrid_zu,vgrid_zl, & Nlvgrid_local => Nlvgrid, & - vgrid_z,cloudsat_preclvl, & - RTTOV_MAX_LOCALTIMES + vgrid_z,cloudsat_preclvl +! RTTOV_MAX_LOCALTIMES,RTTOV_MAX_CHANNELS use cosp_phys_constants, only: amw,amd,amO3,amCO2,amCH4,amN2O,amCO use mod_cosp_io, only: nc_read_input_file,write_cosp2_output USE mod_quickbeam_optics,only: size_distribution,hydro_class_init,quickbeam_optics, & @@ -134,29 +134,17 @@ program cosp2_test overlap, & ! Overlap type: 1=max, 2=rand, 3=max/rand isccp_topheight, & ! ISCCP cloud top height isccp_topheight_direction, & ! ISCCP cloud top height direction - rttov_platform, & ! RTTOV: Satellite platform - rttov_satellite, & ! RTTOV: Satellite - rttov_instrument, & ! RTTOV: Instrument rttov_Nchannels, & ! RTTOV: Number of channels to be computed rttov_Nlocaltime ! RTTOV: Number of local times to be computed real(wp) :: & ! cloudsat_radar_freq, & ! CloudSat radar frequency (GHz) - cloudsat_k2, & ! |K|^2, -1=use frequency dependent default - rttov_ZenAng, & ! RTTOV: Satellite Zenith Angle - co2, & ! CO2 mixing ratio - ch4, & ! CH4 mixing ratio - n2o, & ! n2o mixing ratio - co ! co mixing ratio + cloudsat_k2 ! |K|^2, -1=use frequency dependent default logical :: & ! use_vgrid, & ! Use fixed vertical grid for outputs? csat_vgrid, & ! CloudSat vertical grid? use_precipitation_fluxes ! True if precipitation fluxes are input to the ! algorithm - integer,dimension(RTTOV_MAX_CHANNELS) :: & - rttov_Channels ! RTTOV: Channel numbers - real(wp),dimension(RTTOV_MAX_CHANNELS) :: & - rttov_Surfem ! RTTOV: Surface emissivity - real(wp),dimension(RTTOV_MAX_LOCALTIMES) :: & + real(wp),dimension(10) :: & ! JKS - reasonable limit at 10 rttov_localtime, & ! RTTOV subsetting by local time in hours [0,24] rttov_localtimewindow ! Width of local time window (hrs). character(len=64) :: & @@ -173,9 +161,7 @@ program cosp2_test npoints_it, ncolumns, nlevels, use_vgrid, Nlvgrid, csat_vgrid, dinput, finput, & foutput, cloudsat_radar_freq, surface_radar, cloudsat_use_gas_abs,cloudsat_do_ray,& cloudsat_k2, cloudsat_micro_scheme, lidar_ice_type, use_precipitation_fluxes, & - rttov_platform, rttov_satellite, rttov_Instrument, rttov_Nchannels, & - rttov_Channels, rttov_Surfem, rttov_ZenAng, co2, ch4, n2o, co, & - rttov_Nlocaltime, rttov_localtime, rttov_localtimewindow !JKS + rttov_Nchannels, rttov_Nlocaltime, rttov_localtime, rttov_localtimewindow ! Output namelist logical :: Lcfaddbze94,Ldbze94,Latb532,LcfadLidarsr532,Lclcalipso,Lclhcalipso, & @@ -425,9 +411,8 @@ program cosp2_test 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, & - rttov_platform, rttov_satellite, rttov_Instrument, rttov_Nchannels, & ! JKS added RTTOV inputs here - rttov_Channels, Lrttov_bt, Lrttov_rad, Lrttov_refl, Lrttov_cld, Lrttov_aer, & - Lrttov_cldparam, Lrttov_aerparam,rttov_input_namelist) ! options RTTOV argument + rttov_Nchannels, Lrttov_bt, Lrttov_rad, Lrttov_refl, Lrttov_cld, Lrttov_aer, & + Lrttov_cldparam, Lrttov_aerparam,rttov_input_namelist) call cpu_time(driver_time(3)) !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -520,15 +505,18 @@ program cosp2_test ! cospstateIN%hgt_matrix_half(:,Nlevels) contains the bottom of the surface layer. cospstateIN%hgt_matrix_half(:,1:Nlevels) = zlev_half(start_idx:end_idx,Nlevels:1:-1) ! km - ! Assign RTTOV values (JKS) - ! From namelist file - cospstateIN%emis_sfc = rttov_Surfem(1:rttov_Nchannels) - cospstateIN%zenang = rttov_ZenAng - ! Well-mixed gases - cospstateIN%co2 = co2 - cospstateIN%ch4 = ch4 - cospstateIN%n2o = n2o - cospstateIN%co = co + ! Assign RTTOV values + ! Keeping these structures since refl and emis could come from model input + cospstateIN%emis_sfc = 0._wp + cospstateIN%refl_sfc = 0._wp + + ! Well-mixed gases are not in COSP offline input + ! Moved user input of well-mixed gases to cosp2_rttov_nl + ! Keeping these structures since gases could come from model input + cospstateIN%co2 = 0._wp + cospstateIN%ch4 = 0._wp + cospstateIN%n2o = 0._wp + cospstateIN%co = 0._wp ! From the data input file cospstateIN%u_sfc = u_wind @@ -1064,15 +1052,6 @@ subroutine construct_cospIN(npoints,ncolumns,nlevels,y) y%asym(npoints, ncolumns,nlevels),& y%ss_alb(npoints, ncolumns,nlevels)) endif - ! JKS add RTTOV arguments when constructing the cospIN object - if (Lrttov) then - y%nChannels_rttov = rttov_Nchannels - y%platformIN_rttov = rttov_platform - y%satelliteIN_rttov = rttov_satellite - y%instrumentIN_rttov = rttov_Instrument - y%channelsIN_rttov = rttov_Channels - ! ^I could allocate this if I added "RTTOV_MAX_CHANNELS" at the beginning, but I don't think I need to. - endif end subroutine construct_cospIN @@ -1091,7 +1070,8 @@ subroutine construct_cospstateIN(npoints,nlevels,nchan,y) allocate(y%sunlit(npoints),y%skt(npoints),y%land(npoints),y%at(npoints,nlevels), & y%pfull(npoints,nlevels),y%phalf(npoints,nlevels+1),y%qv(npoints,nlevels), & y%o3(npoints,nlevels),y%hgt_matrix(npoints,nlevels),y%u_sfc(npoints), & - y%v_sfc(npoints),y%lat(npoints),y%lon(nPoints),y%emis_sfc(nchan), & + y%v_sfc(npoints),y%lat(npoints),y%lon(nPoints), & + y%emis_sfc(npoints,nchan),y%refl_sfc(npoints,nchan), & y%cloudIce(nPoints,nLevels),y%cloudLiq(nPoints,nLevels),y%surfelev(npoints),& y%fl_snow(nPoints,nLevels),y%fl_rain(nPoints,nLevels),y%seaice(npoints), & y%tca(nPoints,nLevels),y%hgt_matrix_half(npoints,nlevels)) @@ -1486,6 +1466,7 @@ subroutine destroy_cospstateIN(y) if (allocated(y%lat)) deallocate(y%lat) if (allocated(y%lon)) deallocate(y%lon) if (allocated(y%emis_sfc)) deallocate(y%emis_sfc) + if (allocated(y%refl_sfc)) deallocate(y%refl_sfc) if (allocated(y%cloudIce)) deallocate(y%cloudIce) if (allocated(y%cloudLiq)) deallocate(y%cloudLiq) if (allocated(y%seaice)) deallocate(y%seaice) diff --git a/src/cosp.F90 b/src/cosp.F90 index 5c03f2d077..0f04584e32 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -38,7 +38,7 @@ MODULE MOD_COSP 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, & + N_HYDRO,numMISRHgtBins, & cloudsat_DBZE_BINS,LIDAR_NTEMP,calipso_histBsct,& use_vgrid,Nlvgrid,vgrid_zu,vgrid_zl,vgrid_z,dz, & WR_NREGIME, CFODD_NCLASS, & @@ -49,10 +49,9 @@ MODULE MOD_COSP ntau,modis_histTau,tau_binBounds, & modis_histTauEdges,tau_binEdges,nCloudsatPrecipClass,& modis_histTauCenters,tau_binCenters, & - cloudsat_preclvl,grLidar532_histBsct,atlid_histBsct,& - RTTOV_MAX_CHANNELS ! JKS needed for RTTOV to be in cosp_optical_inputs + cloudsat_preclvl,grLidar532_histBsct,atlid_histBsct USE MOD_COSP_MODIS_INTERFACE, ONLY: cosp_modis_init, modis_IN - USE MOD_COSP_RTTOV_INTERFACE, ONLY: cosp_rttov_init, rttov_init_IN, cosp_rttov_simulate ! JKS + USE MOD_COSP_RTTOV_INTERFACE, ONLY: cosp_rttov_init, cosp_rttov_simulate ! JKS USE MOD_COSP_MISR_INTERFACE, ONLY: cosp_misr_init, misr_IN USE MOD_COSP_ISCCP_INTERFACE, ONLY: cosp_isccp_init, isccp_IN USE MOD_COSP_CALIPSO_INTERFACE, ONLY: cosp_calipso_init, calipso_IN @@ -104,19 +103,19 @@ MODULE MOD_COSP integer :: & month ! Month for surface emissivty atlas (1-12) real(wp) :: & - zenang, & ! Satellite zenith angle for RTTOV (deg) co2, & ! CO2 (kg/kg) ch4, & ! Methane (kg/kg) n2o, & ! N2O (kg/kg) co ! CO (kg/kg) real(wp),allocatable,dimension(:) :: & - emis_sfc, & ! Surface emissivity (1) u_sfc, & ! Surface u-wind (m/s) v_sfc, & ! Surface v-wind (m/s) seaice, & ! Sea-ice fraction (0-1) lat, & ! Latitude (deg) lon ! Longitude (deg) real(wp),allocatable,dimension(:,:) :: & + emis_sfc, & ! Surface emissivity (1) + refl_sfc, & ! Surface reflectance (1) o3, & ! Ozone (kg/kg) tca, & ! Total layer cloud fraction (0-1) cloudIce, & ! Cloud ice water mixing ratio (kg/kg) @@ -135,14 +134,7 @@ MODULE MOD_COSP Nlevels, & ! Number of levels. Npart, & ! Number of cloud meteors for LIDAR simulators. Nrefl, & ! Number of reflectances for PARASOL simulator -! RTTOV inputs JKS - nChannels_rttov, & ! Number of RTTOV channels - platformIN_rttov, & ! RTTOV platform integer - satelliteIN_rttov, & ! RTTOV satellite integer - instrumentIN_rttov ! RTTOV instrument integer -! integer,allocatable,dimension(RTTOV_MAX_CHANNELS) :: & - integer,dimension(RTTOV_MAX_CHANNELS) :: & ! JKS - channelsIN_rttov ! RTTOV channels for the specified instrument + nChannels_rttov ! Number of RTTOV channels real(wp) :: & emsfc_lw ! Surface emissivity @ 11micron real(wp),allocatable,dimension(:,:,:) :: & @@ -758,13 +750,12 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) rttovIN%nLevels => cospIN%nLevels rttovIN%nSubCols => cospIN%nColumns rttovIN%nChannels => cospIN%nChannels_rttov - rttovIN%channels => cospIN%channelsIN_rttov - rttovIN%zenang => cospgridIN%zenang rttovIN%co2 => cospgridIN%co2 rttovIN%ch4 => cospgridIN%ch4 rttovIN%n2o => cospgridIN%n2o rttovIN%co => cospgridIN%co - rttovIN%surfem => cospgridIN%emis_sfc +! rttovIN%surfem => cospgridIN%emis_sfc +! rttovIN%refl_sfc => cospgridIN%refl_sfc rttovIN%h_surf => cospgridIN%hgt_matrix_half(:,cospIN%Nlevels) rttovIN%u_surf => cospgridIN%u_sfc rttovIN%v_surf => cospgridIN%v_sfc @@ -1817,8 +1808,7 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La cloudsat_radar_freq, cloudsat_k2, cloudsat_use_gas_abs, cloudsat_do_ray, & isccp_top_height, isccp_top_height_direction, surface_radar, rcfg, lusevgrid, & luseCSATvgrid, Nvgrid, Nlevels, cloudsat_micro_scheme, & - NchanIN, platformIN, satelliteIN, instrumentIN, channelsIN, & - Lrttov_bt, Lrttov_rad, Lrttov_refl, & + NchanIN, Lrttov_bt, Lrttov_rad, Lrttov_refl, & Lrttov_cld, Lrttov_aer, Lrttov_cldparam, Lrttov_aerparam, & rttov_input_namelist) @@ -1828,7 +1818,6 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La Lrttov_bt, Lrttov_rad, Lrttov_refl, & Lrttov_cld, Lrttov_aer, Lrttov_cldparam, Lrttov_aerparam ! JKS to-do -! type(rttov_init_in),intent(in) :: rttov_init_IN integer,intent(in) :: & cloudsat_use_gas_abs, & ! cloudsat_do_ray, & ! @@ -1837,12 +1826,7 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La Nlevels, & ! Nvgrid, & ! Number of levels for new L3 grid surface_radar, & ! - NchanIN, & ! RTTOV arguments here and below JKS - platformIN, & - satelliteIN, & - instrumentIN - integer,dimension(RTTOV_MAX_CHANNELS) :: & - channelsIN ! RTTOV: Channel numbers + NchanIN ! RTTOV arguments here and below JKS real(wp),intent(in) :: & cloudsat_radar_freq, & ! cloudsat_k2 ! @@ -1905,12 +1889,11 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La ! Could print diagnostic on timing here. if (Lrttov) then call cpu_time(driver_time(1)) - call cosp_rttov_init(NchanIN,platformIN,satelliteIN, & - instrumentIN,channelsIN,Nlevels, & + call cosp_rttov_init(NchanIN, Nlevels, & Lrttov_bt,Lrttov_rad,Lrttov_refl, & Lrttov_cld,Lrttov_aer, & Lrttov_cldparam,Lrttov_aerparam, & - rttov_input_namelist) + rttov_input_namelist) call cpu_time(driver_time(2)) print*,'Time to run cosp_rttov_init: ',driver_time(2)-driver_time(1) endif @@ -2550,9 +2533,14 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%emis_sfc has not been allocated' alloc_status = .false. endif + if (.not. allocated(cospgridIN%refl_sfc)) then + nError=nError+1 + errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%refl_sfc has not been allocated' + alloc_status = .false. + endif if (.not. allocated(cospgridIN%hgt_matrix_half)) then nError=nError+1 - errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%emis_sfc has not been allocated' + errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%hgt_matrix_half has not been allocated' alloc_status = .false. endif if (.not. allocated(cospgridIN%u_sfc)) then @@ -3091,18 +3079,6 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, ! RTTOV Inputs if (Lrttov_column) then - if (cospgridIN%zenang .lt. -90. .OR. cospgridIN%zenang .gt. 90) then - nError=nError+1 - errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%zenang contains values out of range' - Lrttov_column = .false. - if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF - endif if (cospgridIN%co2 .lt. 0) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%co2 contains values out of range' @@ -3175,6 +3151,18 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF endif + if (any(cospgridIN%refl_sfc .lt. 0. .OR. cospgridIN%refl_sfc .gt. 1)) then + nError=nError+1 + errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%refl_sfc contains values out of range' + Lrttov_column = .false. + if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF + endif if (any(cospgridIN%u_sfc .lt. -100. .OR. cospgridIN%u_sfc .gt. 100.)) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospIN%u_sfc contains values out of range' diff --git a/src/cosp_config.F90 b/src/cosp_config.F90 index d2b5aae640..739de969a0 100755 --- a/src/cosp_config.F90 +++ b/src/cosp_config.F90 @@ -152,12 +152,7 @@ MODULE MOD_COSP_CONFIG ! #################################################################################### ! Constants used by RTTOV. ! #################################################################################### - integer,parameter :: & - RTTOV_MAX_CHANNELS = 20, & - RTTOV_MAX_LOCALTIMES = 8 ! JKS arbitrary - character(len=256),parameter :: & -! rttovDir = '/homedata/rguzman/CALIPSO/RTTOV/rttov_11.3/' - rttovDir = '/glade/u/home/jonahshaw/w/RTTOV/' ! JKS update or pass in + ! None ! #################################################################################### ! Constants used by the PARASOL simulator. ! #################################################################################### diff --git a/src/simulator/cosp_rttov_interfaceSTUB.F90 b/src/simulator/cosp_rttov_interfaceSTUB.F90 index a8e0db0f72..52ad33eb27 100644 --- a/src/simulator/cosp_rttov_interfaceSTUB.F90 +++ b/src/simulator/cosp_rttov_interfaceSTUB.F90 @@ -32,53 +32,23 @@ ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MODULE MOD_COSP_RTTOV_INTERFACE USE COSP_KINDS, ONLY: wp - USE MOD_COSP_CONFIG, ONLY: RTTOV_MAX_CHANNELS,rttovDir +! USE MOD_COSP_CONFIG, ONLY: RTTOV_MAX_CHANNELS,rttovDir USE MOD_COSP_RTTOV, ONLY: rttov_IN IMPLICIT NONE - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! TYPE rttov_init_IN (RTTOV init DDT to be passed to cosp_init) - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -! I may remove this because it will require an additional dependency between -! cosp2_test and the RTTOV interface. - -! Integers: NchanIN, platformIN, satelliteIN, instrumentIN, channelsIN, & -! Logicals: Lrttov_cld, Lrttov_aer, Lrttov_rad, Lrttov_cldparam, Lrttov_aerparam - - type rttov_init_IN - logical,pointer :: & - Lrttov_cld, & - Lrttov_aer, & - Lrttov_rad, & - Lrttov_cldparam, & - Lrttov_aerparam - integer,pointer :: & - NchanIN, & ! Number of spectral channels to simulate - platformIN, & ! Index of the platform - satelliteIN, & ! Index of the satellite - instrumentIN ! Index of the instrument - integer,dimension(RTTOV_MAX_CHANNELS) :: & - channelsIN ! Indices of spectral channels - end type rttov_init_IN - CONTAINS !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_init !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN, & - nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, & + SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, & Lrttov_cld,Lrttov_aer,Lrttov_cldparam,Lrttov_aerparam, & rttov_input_namelist) - integer,intent(in) :: & - NchanIN, & ! Number of channels - platformIN, & ! Satellite platform - satelliteIN, & ! Satellite - instrumentIN, & ! Instrument + integer,intent(in) :: & + NchanIN, & nlevels - integer,intent(in),dimension(RTTOV_MAX_CHANNELS) :: & - channelsIN ! RTTOV channels +! integer,intent(in),dimension(RTTOV_MAX_CHANNELS) :: & +! channelsIN ! RTTOV channels logical,intent(in) :: & Lrttov_bt, & Lrttov_rad, & @@ -86,10 +56,11 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI Lrttov_cld, & Lrttov_aer, & Lrttov_cldparam, & - Lrttov_aerparam - - ! JKS testing using a RTTOV input namelist here - character(len=256),intent(in) :: rttov_input_namelist + Lrttov_aerparam + + ! JKS testing using a RTTOV input namelist here + ! (default cosp_rttov namelist is set in cosp.F90) + character(len=256),intent(in) :: rttov_input_namelist print*,'Running COSP_RTTOV_INIT from STUB files.', & 'To run RTTOV, compile COSP after setting environmental variable "RTTOV"' diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index a875cb88e3..4d33bcb505 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -32,13 +32,11 @@ ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MODULE MOD_COSP_RTTOV_INTERFACE USE COSP_KINDS, ONLY: wp - USE MOD_COSP_CONFIG, ONLY: RTTOV_MAX_CHANNELS,rttovDir - use mod_cosp_rttov, only: platform,satellite,sensor,nChannels,iChannel,coef_rttov, & - opts,construct_rttov_coeffilename,rttov_in, & - construct_rttov_scatfilename, & + use mod_cosp_rttov, only: nChannels,iChannel,coef_rttov,opts,rttov_in, & do_rttov_bt,do_rttov_rad,do_rttov_refl, & do_rttov_cld,do_rttov_aer,rttov_cld_optparam, & - rttov_aer_optparam,rttov_direct_nthreads + rttov_aer_optparam,rttov_direct_nthreads, & + rttovDir,so2,ch4,co,co2,n2o,zenang ! rttov_const contains useful RTTOV constants @@ -69,52 +67,19 @@ MODULE MOD_COSP_RTTOV_INTERFACE INTEGER(KIND=jpim) :: errorstatus ! Return error status of RTTOV subroutine calls INTEGER(KIND=jpim) :: alloc_status(60) - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! TYPE rttov_init_IN (RTTOV init DDT to be passed to cosp_init) - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -! I may remove this because it will require an additional dependency between -! cosp2_test and the RTTOV interface. -! Integers: NchanIN, platformIN, satelliteIN, instrumentIN, channelsIN, & -! Logicals: Lrttov_cld, Lrttov_aer, Lrttov_rad, Lrttov_cldparam, Lrttov_aerparam - - type rttov_init_IN - logical,pointer :: & - Lrttov_bt, & - Lrttov_rad, & - Lrttov_refl, & - Lrttov_cld, & - Lrttov_aer, & - Lrttov_cldparam, & - Lrttov_aerparam - integer,pointer :: & - NchanIN, & ! Number of spectral channels to simulate - platformIN, & ! Index of the platform - satelliteIN, & ! Index of the satellite - instrumentIN ! Index of the instrument - integer,dimension(RTTOV_MAX_CHANNELS) :: & - channelsIN ! Indices of spectral channels - end type rttov_init_IN CONTAINS !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_init !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsIN, & - nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, & + SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, & Lrttov_cld,Lrttov_aer,Lrttov_cldparam,Lrttov_aerparam, & rttov_input_namelist) - integer,intent(in) :: & - NchanIN, & ! Number of channels - platformIN, & ! Satellite platform - satelliteIN, & ! Satellite - instrumentIN, & ! Instrument + integer,intent(in) :: & + NchanIN, & nlevels - integer,intent(in),dimension(RTTOV_MAX_CHANNELS) :: & - channelsIN ! RTTOV channels logical,intent(in) :: & Lrttov_bt, & Lrttov_rad, & @@ -132,27 +97,44 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI character(len=256) :: & coef_file, & scat_file, & + rttov_srcDir, & rttov_coefDir, & - rttov_predDir, & - rttov_cldaerDir, & OD_coef_file, & aer_coef_file, & cld_coef_file, & OD_coef_filepath, & aer_coef_filepath, & cld_coef_filepath + + real(wp) :: & + SO2_mr, & + N2O_mr, & + CO_mr, & + CH4_mr, & + CO2_mr, & + rttov_ZenAng ! Declare RTTOV namelist fields - logical :: so2_data,n2o_data,co_data,ch4_data,co2_data,ozone_data + logical :: SO2_data = .false. + logical :: N2O_data = .false. + logical :: CO_data = .false. + logical :: CO2_data = .false. + logical :: CH4_data = .false. + logical :: ozone_data = .false. + character(len=256) :: cosp_status - integer :: rttov_nthreads + integer :: & + rttov_nthreads + + integer,dimension(NchanIN) :: & + rttov_Channels ! RTTOV channels ! Read RTTOV namelist fields - namelist/RTTOV_INPUT/rttov_coefDir, & - OD_coef_filepath, & - aer_coef_filepath,cld_coef_filepath,so2_data,n2o_data, & - co_data,ch4_data,co2_data,ozone_data,rttov_nthreads -! rttov_Nlocaltime, rttov_localtime, rttov_localtimewindow !JKS + namelist/RTTOV_INPUT/rttov_srcDir,rttov_coefDir, & + OD_coef_filepath,aer_coef_filepath,cld_coef_filepath, & + SO2_mr,N2O_mr,CO_mr,CH4_mr,CO2_mr,rttov_ZenAng, & ! Mixing ratios + SO2_data,N2O_data,CO_data,CH4_data,CO2_data,ozone_data, & + rttov_nthreads,rttov_Channels !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Read in namelists @@ -160,18 +142,12 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI open(10,file=rttov_input_namelist,status='unknown') read(10,nml=RTTOV_INPUT) close(10) - - !print*,'OD_coef_file: ',OD_coef_file - !print*,'aer_coef_file: ',aer_coef_file - !print*,'cld_coef_file: ',cld_coef_file - !print*,'OD_coef_filepath: ',OD_coef_filepath ! Initialize fields in module memory (cosp_rttovXX.F90) + rttovDir = rttov_srcDir nChannels = NchanIN - platform = platformIN - satellite = satelliteIN - sensor = instrumentIN - iChannel = channelsIN + allocate(iChannel(NchanIN)) + iChannel = rttov_Channels ! Set logicals for RTTOV options do_rttov_bt = Lrttov_bt @@ -182,6 +158,13 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,platformIN,satelliteIN,instrumentIN,channelsI rttov_cld_optparam = Lrttov_cldparam rttov_aer_optparam = Lrttov_aerparam + so2 = SO2_mr + n2o = N2O_mr + co = CO_mr + co2 = CO2_mr + ch4 = CH4_mr + zenang = rttov_ZenAng + ! Set degree of parallelization rttov_direct_nthreads = rttov_nthreads @@ -378,8 +361,7 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, cosp_rttov_setup_emissivity_reflectance, & cosp_rttov_call_direct, & cosp_rttov_save_and_deallocate_profiles, & - cosp_rttov_deallocate_coefs, & - rttov_direct_nthreads + cosp_rttov_deallocate_coefs type(rttov_in),intent(in) :: & rttovIN diff --git a/src/simulator/rttov/cosp_rttovSTUB.F90 b/src/simulator/rttov/cosp_rttovSTUB.F90 index 4bcd94469b..a1b0945c24 100644 --- a/src/simulator/rttov/cosp_rttovSTUB.F90 +++ b/src/simulator/rttov/cosp_rttovSTUB.F90 @@ -32,7 +32,7 @@ MODULE MOD_COSP_RTTOV use cosp_kinds, only : wp - use mod_cosp_config, only : RTTOV_MAX_CHANNELS,N_HYDRO,rttovDir + use mod_cosp_config, only : N_HYDRO use cosp_phys_constants, only : mdry=>amd,mO3=>amO3,mco2=>amCO2,mCH4=>amCH4, & mn2o=>amN2O,mco=>amCO @@ -44,13 +44,11 @@ MODULE MOD_COSP_RTTOV ! Initialization parameters integer :: & - platform, & ! RTTOV platform - sensor, & ! RTTOV instrument - satellite, & ! RTTOV satellite nChannels ! Number of channels - integer,dimension(RTTOV_MAX_CHANNELS) :: & - iChannel ! RTTOV channel numbers + integer,allocatable,dimension(:) :: & + iChannel + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! TYPE rttov_IN - Data type specific to inputs required by RTTOV ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -67,11 +65,11 @@ MODULE MOD_COSP_RTTOV ch4, & ! Methane n2o, & ! n2o co ! Carbon monoxide - real(wp),dimension(:),pointer :: & - surfem ! Surface emissivities for the channels +! real(wp),dimension(:),pointer :: & +! surfem ! Surface emissivities for the channels ! refl, & ! Surface reflectances for the channels - integer,dimension(:),pointer :: & - channels ! Surface reflectances for the channels +! integer,dimension(:),pointer :: & +! channels ! Surface reflectances for the channels real(wp),dimension(:),pointer :: & h_surf, & ! Surface height u_surf, & ! U component of surface wind @@ -100,163 +98,4 @@ MODULE MOD_COSP_RTTOV fl_snow ! Precipitation flux (stratiform+convective snow) end type rttov_IN -CONTAINS - subroutine rttov_column(nPoints,nLevels,nSubCols,q,p,t,o3,ph,h_surf,u_surf,v_surf, & - p_surf,t_skin,t2m,q2m,lsmask,lon,lat,seaice,co2,ch4,n2o,co, & - zenang,lCleanup, & - ! Outputs - Tb,error, & - ! Optional arguments for surface emissivity calculation. - surfem,month, & - ! Optional arguments for all-sky calculation. - tca,ciw,clw,rain,snow) - ! Inputs - integer,intent(in) :: & - nPoints, & ! Number of gridpoints - nLevels, & ! Number of vertical levels - nSubCols ! Number of subcolumns - real(wp),intent(in) :: & - co2, & ! CO2 mixing ratio (kg/kg) - ch4, & ! CH4 mixing ratio (kg/kg) - n2o, & ! N2O mixing ratio (kg/kg) - co, & ! CO mixing ratio (kg/kg) - zenang ! Satellite zenith angle - real(wp),dimension(nPoints),intent(in) :: & - h_surf, & ! Surface height (m) - u_surf, & ! Surface u-wind (m/s) - v_surf, & ! Surface v-wind (m/s) - p_surf, & ! Surface pressure (Pa) - t_skin, & ! Skin temperature (K) - t2m, & ! 2-meter temperature (K) - q2m, & ! 2-meter specific humidity (kg/kg) - lsmask, & ! Land/sea mask - lon, & ! Longitude (deg) - lat, & ! Latitude (deg) - seaice ! Seaice fraction (0-1) - real(wp),dimension(nPoints,nLevels),intent(in) :: & - q, & ! Specific humidity (kg/kg) - p, & ! Pressure(Pa) - t, & ! Temperature (K) - o3 ! Ozone - real(wp),dimension(nPoints,nLevels+1),intent(in) :: & - ph ! Pressure @ half-levels (Pa) - logical,intent(in) :: & - lCleanup ! Flag to determine whether to deallocate RTTOV types - - ! Optional inputs (Needed for surface emissivity calculation) - integer,optional :: & - month ! Month (needed to determine table to load) - real(wp),dimension(nChannels),optional :: & - surfem ! Surface emissivity for each RTTOV channel - - ! Optional inputs (Needed for all-sky calculation) - real(wp),dimension(nPoints,nLevels),optional :: & - tca ! Total column cloud amount (0-1) - real(wp),dimension(nPoints,nSubCols,nLevels),optional :: & - ciw, & ! Cloud ice - clw, & ! Cloud liquid - rain, & ! Precipitation flux (kg/m2/s) - snow ! Precipitation flux (kg/m2/s) - - ! Outputs - real(wp),dimension(nPoints,nChannels) :: & - Tb ! RTTOV brightness temperature. - character(len=128) :: & - error ! Error messages (only populated if error encountered) - - end subroutine rttov_column - function construct_rttov_coeffilename(platform,satellite,instrument) - ! Inputs - integer,intent(in) :: platform,satellite,instrument - ! Outputs - character(len=256) :: construct_rttov_coeffilename - ! Local variables - character(len=256) :: coef_file - integer :: error - - ! Initialize - error = 0 - - ! Platform - if (platform .eq. 1) coef_file = 'rtcoef_noaa_' - if (platform .eq. 10) coef_file = 'rtcoef_metop_' - if (platform .eq. 11) coef_file = 'rtcoef_envisat_' - if (platform .ne. 1 .and. platform .ne. 10 .and. platform .ne. 11) then - error=error+1 - write ( *,* ) 'Unsupported platform ID ',platform - return - endif - - ! Satellite - if (satellite .lt. 10) then - coef_file = trim(coef_file) // char(satellite+48) - else if (satellite .lt. 100) then - coef_file = trim(coef_file) // char(int(satellite/10)+48) - coef_file = trim(coef_file) // char(satellite-int(satellite/10)*10+48) - else - error=error+1 - write ( *,* ) 'Unsupported satellite number ',satellite - return - endif - - ! Sensor - if (sensor .eq. 3) coef_file = trim(coef_file) // '_amsua.dat' - if (sensor .eq. 5) coef_file = trim(coef_file) // '_avhrr.dat' - if (sensor .eq. 49) coef_file = trim(coef_file) // '_mwr.dat' - if (sensor .ne. 3 .and. sensor .ne. 5 .and. sensor .ne. 49) then - error=error+1 - write ( *,* ) 'Unsupported sensor number ', sensor - return - endif - - if (error .eq. 0) construct_rttov_coeffilename=coef_file - - end function construct_rttov_coeffilename - function construct_rttov_scatfilename(platform,satellite,instrument) - ! Inputs - integer,intent(in) :: platform,satellite,instrument - ! Outputs - character(len=256) :: construct_rttov_scatfilename - ! Local variables - character(len=256) :: coef_file - integer :: error - - ! Initialize - error = 0 - - ! Platform - if (platform .eq. 1) coef_file = 'sccldcoef_noaa_' - if (platform .eq. 10) coef_file = 'sccldcoef_metop_' - if (platform .eq. 11) coef_file = 'sccldcoef_envisat_' - if (platform .ne. 1 .and. platform .ne. 10 .and. platform .ne. 11) then - error=error+1 - write ( *,* ) 'Unsupported platform ID ',platform - return - endif - - ! Satellite - if (satellite .lt. 10) then - coef_file = trim(coef_file) // char(satellite+48) - else if (satellite .lt. 100) then - coef_file = trim(coef_file) // char(int(satellite/10)+48) - coef_file = trim(coef_file) // char(satellite-int(satellite/10)*10+48) - else - error=error+1 - write ( *,* ) 'Unsupported satellite number ',satellite - return - endif - - ! Sensor - if (sensor .eq. 3) coef_file = trim(coef_file) // '_amsua.dat' - if (sensor .eq. 5) coef_file = trim(coef_file) // '_avhrr.dat' - if (sensor .eq. 49) coef_file = trim(coef_file) // '_mwr.dat' - if (sensor .ne. 3 .and. sensor .ne. 5 .and. sensor .ne. 49) then - error=error+1 - write ( *,* ) 'Unsupported sensor number ', sensor - return - endif - - if (error .eq. 0) construct_rttov_scatfilename=coef_file - - end function construct_rttov_scatfilename END MODULE MOD_COSP_RTTOV diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 6e7cd0c942..40ac637928 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -40,17 +40,13 @@ module mod_cosp_rttov use rttov_types, only : rttov_options,rttov_coefs,rttov_profile, & rttov_transmission,rttov_radiance,rttov_chanprof, & rttov_emissivity,rttov_reflectance,rttov_opt_param -! use rttov_types, only : rttov_options,rttov_coefs,profile_type, & -! transmission_type,radiance_type,rttov_chanprof, & -! rttov_emissivity,profile_cloud_type,rttov_scatt_coef, & -! rttov_options_scatt use rttov_const, only : surftype_sea, surftype_land, surftype_seaice, & errorstatus_success,errorstatus_fatal, & platform_name,inst_name, & sensor_id_mw,sensor_id_po use rttov_unix_env, only : rttov_exit use cosp_kinds, only : wp - use mod_cosp_config, only : RTTOV_MAX_CHANNELS,N_HYDRO,rttovDir + use mod_cosp_config, only : N_HYDRO use cosp_phys_constants, only : mdry=>amd,mO3=>amO3,mco2=>amCO2,mCH4=>amCH4, & mn2o=>amN2O,mco=>amCO @@ -107,15 +103,13 @@ module mod_cosp_rttov real(wp),parameter :: eps = 0.622 ! Initialization parameters - integer :: & - platform, & ! RTTOV platform - sensor, & ! RTTOV instrument - satellite, & ! RTTOV satellite + integer(kind=jpim) :: & nChannels ! Number of channels integer(kind=jpim) :: & ! Parallelization is default off rttov_direct_nthreads = 1_jpim - integer,dimension(RTTOV_MAX_CHANNELS) :: & - iChannel ! RTTOV channel numbers +! integer,dimension(nChannels) :: & + integer(kind=jpim),allocatable :: & + iChannel(:) ! RTTOV channel numbers ! Scattering coefficients (read in once during initialization) type(rttov_coefs) :: & @@ -134,10 +128,17 @@ module mod_cosp_rttov do_rttov_refl, & ! Return reflectances in RTTOV calculations rttov_cld_optparam, & ! Use user-supplied optical cloud parameters rttov_aer_optparam ! Use user-supplied optical aerosol parameters + + ! --- Well-mixed trace gas mixing ratios from user via RTTOV namelist + real(wp) :: so2 = 0._wp + real(wp) :: ch4 = 0._wp + real(wp) :: co = 0._wp + real(wp) :: co2 = 0._wp + real(wp) :: n2o = 0._wp + real(wp) :: zenang = 0._wp ! NADIR default - ! JKS should this be module-wide? -! type(rttov_IN) :: & -! rttovIN + character(len=256) :: & + rttovDir ! Directory for the RTTOV source code ! JKS - KISS ! type(rttov_options_scatt) :: & @@ -174,17 +175,16 @@ module mod_cosp_rttov nSubCols, & ! Number of subcolumns nChannels, & ! Number of channels to simulate month ! Month (needed for surface emissivity calculation) - real(wp),pointer :: & - zenang, & ! Satellite zenith angle + real(wp),pointer :: & ! Could change the dimensionality of these in the future co2, & ! Carbon dioxide ch4, & ! Methane n2o, & ! n2o co ! Carbon monoxide - real(wp),dimension(:),pointer :: & - surfem ! Surface emissivities for the channels +! real(wp),dimension(:),pointer :: & +! surfem ! Surface emissivities for the channels ! refl, & ! Surface reflectances for the channels - integer(kind=jpim),dimension(:),pointer :: & - channels ! Surface reflectances for the channels +! integer(kind=jpim),dimension(:),pointer :: & +! channels ! real(wp),dimension(:),pointer :: & h_surf, & ! Surface height u_surf, & ! U component of surface wind @@ -203,7 +203,6 @@ module mod_cosp_rttov t, & ! Temperature q, & ! Specific humidity o3 ! Ozone - ! These fields below are needed ONLY for the RTTOV all-sky brightness temperature real(wp),dimension(:,:),pointer :: & tca, & ! Cloud fraction @@ -303,7 +302,8 @@ subroutine cosp_rttov_allocate(rttovIN & do jch = 1, rttovIN%nChannels nch = nch + 1_jpim chanprof(nch)%prof = j - chanprof(nch)%chan = rttovIN%channels(jch) ! Example code used channel_list + chanprof(nch)%chan = iChannel(jch) ! Example code used channel_list +! chanprof(nch)%chan = rttovIN%channels(jch) ! Example code used channel_list end do end do @@ -323,10 +323,6 @@ subroutine cosp_rttov_construct_profiles(rttovIN & ! Loop variables integer(kind=jpim) :: i, j ! Use i to iterate over profile, j for levels. - - logical :: & - rttov_simulate_cld, & - rttov_simulate_aer ! Store profile data from rttovIN in profile type. ! See RTTOV user guide pg 163 for description of "profiles" type @@ -337,15 +333,29 @@ subroutine cosp_rttov_construct_profiles(rttovIN & ! ozone_data, co2_data and so on in the options structure should be ! set to false." + print*,'co2: ',co2 + print*,'n2o: ',n2o + print*,'co: ',co + print*,'ch4: ',ch4 + print*,'so2: ',so2 + print*,'zenang: ',zenang + profiles(:)%gas_units = 1 ! kg/kg over moist air (default) do i = 1, rttovIN%nPoints - ! Initialize trace gas concentrations - profiles(i)%co2(:) = rttovIN%co2 - profiles(i)%n2o(:) = rttovIN%n2o - profiles(i)%co(:) = rttovIN%n2o - profiles(i)%ch4(:) = rttovIN%ch4 + ! Initialize trace gas concentrations from user input + ! These gases are not in COSP input files but might be in the futre + profiles(i)%co2(:) = co2 + profiles(i)%n2o(:) = n2o + profiles(i)%co(:) = co + profiles(i)%ch4(:) = ch4 + profiles(i)%so2 = so2 + +! profiles(i)%co2(:) = rttovIN%co2 +! profiles(i)%n2o(:) = rttovIN%n2o +! profiles(i)%co(:) = rttovIN%co +! profiles(i)%ch4(:) = rttovIN%ch4 ! Initialize column pressure, temperature, and humidity profiles(i)%p(:) = rttovIN%p(i, :) * 1e-2 ! convert Pa to hPa @@ -365,7 +375,6 @@ subroutine cosp_rttov_construct_profiles(rttovIN & ! Gas profiles profiles(i)%o3 = rttovIN%o3(i, :) -! profiles(i)%so2 = ! Sulfate not in COSP input files ! 2m parameters profiles(i)%s2m%p = rttovIN%p_surf(i) * 1e-2 ! convert Pa to hPa @@ -386,14 +395,14 @@ subroutine cosp_rttov_construct_profiles(rttovIN & profiles(i)%skin%fastem(5) = 0.3 ! Viewing angles - profiles(i)%zenangle = rttovIN%zenang ! pass in from cosp + profiles(i)%zenangle = zenang ! pass in from cosp profiles(i)%azangle = 0. ! hard-coded in rttov9 int JKS-? profiles(i)%latitude = rttovIN%latitude(i) profiles(i)%longitude = rttovIN%longitude(i) profiles(i)%elevation = rttovIN%h_surf(i) * 1e-3 ! Convert m to km - ! Solar angles. JKS - get this from COSP? Doesn't seem to be passed in. + ! Solar angles. JKS - get this from COSP/CESM? Doesn't seem to be passed in. profiles(i)%sunzenangle = 0. ! hard-coded in rttov9 int profiles(i)%sunazangle = 0. ! hard-coded in rttov9 int @@ -425,8 +434,6 @@ subroutine cosp_rttov_construct_profiles(rttovIN & ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Only add the cloud fields if simulating cloud. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -! rttov_simulate_cld = .false. -! if (rttov_simulate_cld) then if (do_rttov_cld) then @@ -467,8 +474,6 @@ subroutine cosp_rttov_construct_profiles(rttovIN & ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Only add the aerosol fields if simulating aerosol. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -! rttov_simulate_aer = .false. -! if (rttov_simulate_aer) then if (do_rttov_aer) then @@ -659,101 +664,5 @@ subroutine cosp_rttov_deallocate_coefs() endif end subroutine cosp_rttov_deallocate_coefs - - - function construct_rttov_coeffilename(platform,satellite,instrument) - ! Inputs - integer,intent(in) :: platform,satellite,instrument - ! Outputs - character(len=256) :: construct_rttov_coeffilename - ! Local variables - character(len=256) :: coef_file - integer :: error - - ! Initialize - error = 0 - - ! Platform - if (platform .eq. 1) coef_file = 'rtcoef_noaa_' - if (platform .eq. 10) coef_file = 'rtcoef_metop_' - if (platform .eq. 11) coef_file = 'rtcoef_envisat_' - if (platform .ne. 1 .and. platform .ne. 10 .and. platform .ne. 11) then - error=error+1 - write ( *,* ) 'Unsupported platform ID ',platform - return - endif - - ! Satellite - if (satellite .lt. 10) then - coef_file = trim(coef_file) // char(satellite+48) - else if (satellite .lt. 100) then - coef_file = trim(coef_file) // char(int(satellite/10)+48) - coef_file = trim(coef_file) // char(satellite-int(satellite/10)*10+48) - else - error=error+1 - write ( *,* ) 'Unsupported satellite number ',satellite - return - endif - - ! Sensor - if (sensor .eq. 3) coef_file = trim(coef_file) // '_amsua.dat' - if (sensor .eq. 5) coef_file = trim(coef_file) // '_avhrr.dat' - if (sensor .eq. 49) coef_file = trim(coef_file) // '_mwr.dat' - if (sensor .ne. 3 .and. sensor .ne. 5 .and. sensor .ne. 49) then - error=error+1 - write ( *,* ) 'Unsupported sensor number ', sensor - return - endif - - if (error .eq. 0) construct_rttov_coeffilename=coef_file - - end function construct_rttov_coeffilename - function construct_rttov_scatfilename(platform,satellite,instrument) - ! Inputs - integer,intent(in) :: platform,satellite,instrument - ! Outputs - character(len=256) :: construct_rttov_scatfilename - ! Local variables - character(len=256) :: coef_file - integer :: error - - ! Initialize - error = 0 - - ! Platform - if (platform .eq. 1) coef_file = 'sccldcoef_noaa_' - if (platform .eq. 10) coef_file = 'sccldcoef_metop_' - if (platform .eq. 11) coef_file = 'sccldcoef_envisat_' - if (platform .ne. 1 .and. platform .ne. 10 .and. platform .ne. 11) then - error=error+1 - write ( *,* ) 'Unsupported platform ID ',platform - return - endif - - ! Satellite - if (satellite .lt. 10) then - coef_file = trim(coef_file) // char(satellite+48) - else if (satellite .lt. 100) then - coef_file = trim(coef_file) // char(int(satellite/10)+48) - coef_file = trim(coef_file) // char(satellite-int(satellite/10)*10+48) - else - error=error+1 - write ( *,* ) 'Unsupported satellite number ',satellite - return - endif - - ! Sensor - if (sensor .eq. 3) coef_file = trim(coef_file) // '_amsua.dat' - if (sensor .eq. 5) coef_file = trim(coef_file) // '_avhrr.dat' - if (sensor .eq. 49) coef_file = trim(coef_file) // '_mwr.dat' - if (sensor .ne. 3 .and. sensor .ne. 5 .and. sensor .ne. 49) then - error=error+1 - write ( *,* ) 'Unsupported sensor number ', sensor - return - endif - - if (error .eq. 0) construct_rttov_scatfilename=coef_file - - end function construct_rttov_scatfilename end module mod_cosp_rttov From 0630aef87c6ad0dd4589241330e3f91b796d6d50 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 28 Mar 2023 10:45:59 -0600 Subject: [PATCH 042/159] COSP-RTTOV reorg part 2 1. Added reading channel indices, emissivities, and reflectivities from a .csv file. Cleaned up namelist files. 2. Fixed a bug with rttovIN%Nchannels not being assigned. To-do: - Still passing nchannels both directly and through rttovIN. Probably makes the most sense to only pass it directly since it is a user-specified value and not part of the model input. - Now that emissivities/reflectivities are read in, create an option to pass them into RTTOV. Probably requires additional logical inputs in the RTTOV namelist. - Errors when simulating AIRS. Water vapor coef limits reached. Need to check more thoroughly. --- driver/run/cosp2_input_rttov_nl.txt | 2 +- driver/run/cosp2_rttov_nl.txt | 17 +- driver/run/rttov_channel_input2.csv | 100 + driver/run/rttov_channel_input_AIRS.csv | 2500 +++++++++++++++++ driver/src/cosp2_test.F90 | 6 +- src/simulator/cosp_rttov_interface_v13.F90 | 41 +- .../investigate_Reff_UKMOinput.ipynb | 564 ++++ src/simulator/rttov/cosp_rttovSTUB.F90 | 5 - src/simulator/rttov/cosp_rttov_v13.F90 | 39 +- src/simulator/rttov/cosp_rttov_v13_old.F90 | 1319 +++++++++ 10 files changed, 4537 insertions(+), 56 deletions(-) create mode 100644 driver/run/rttov_channel_input2.csv create mode 100644 driver/run/rttov_channel_input_AIRS.csv create mode 100644 src/simulator/investigate_Reff_UKMOinput.ipynb create mode 100644 src/simulator/rttov/cosp_rttov_v13_old.F90 diff --git a/driver/run/cosp2_input_rttov_nl.txt b/driver/run/cosp2_input_rttov_nl.txt index cf40ab7ca1..6fdec1c40f 100644 --- a/driver/run/cosp2_input_rttov_nl.txt +++ b/driver/run/cosp2_input_rttov_nl.txt @@ -82,7 +82,7 @@ !---------------------------------------------------------------------------------- !-------------- RTTOV inputs !---------------------------------------------------------------------------------- - rttov_Nchannels=15, ! Number of channels to be computed + rttov_Nchannels=200, ! Number of channels to be computed rttov_Nlocaltime=2, rttov_localtime=10.0,13.0, ! To implement local time rttov_localtimewindow=1.0,1.0, ! To implement local time width diff --git a/driver/run/cosp2_rttov_nl.txt b/driver/run/cosp2_rttov_nl.txt index eb1fec37ca..7e1813967b 100644 --- a/driver/run/cosp2_rttov_nl.txt +++ b/driver/run/cosp2_rttov_nl.txt @@ -25,13 +25,16 @@ ! Namelist that sets up the main COSP options &RTTOV_INPUT - !-------------- RTTOV Coefficient Paths - !- Paths should be relative to the RTTOVdir path specified in cosp_config.F90 + !-------------- RTTOV Filepaths + channel_filepath='rttov_channel_input_AIRS.csv' rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', rttov_coefDir='rtcoef_rttov13/' - OD_coef_filepath='rttov13pred54L/rtcoef_ticfire_1_mbfiri_o3co2.dat', - aer_coef_filepath='cldaer_visir/scaercoef_ticfire_1_mbfiri_cams.dat', - cld_coef_filepath='cldaer_visir/sccldcoef_ticfire_1_mbfiri.dat', + OD_coef_filepath='rttov13pred101L/rtcoef_eos_2_airs_7gas.H5', + aer_coef_filepath='cldaer_visir/scaercoef_eos_2_airs_cams.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_airs.H5', +! OD_coef_filepath='rttov13pred54L/rtcoef_ticfire_1_mbfiri_o3co2.dat', +! aer_coef_filepath='cldaer_visir/scaercoef_ticfire_1_mbfiri_cams.dat', +! cld_coef_filepath='cldaer_visir/sccldcoef_ticfire_1_mbfiri.dat', !-------------- RTTOV Trace Gas Logicals (must match coefficient files) SO2_data=.false., N2O_data=.false., @@ -49,9 +52,5 @@ !-------------- RTTOV Other --------------- ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel rttov_nthreads=1, - ! Channel indices (Nchannels must be supplied in COSP input namelist) - rttov_Channels=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, - ! Surface emissivity (Nchannels must be supplied in COSP input namelist) -! rttov_Surfem=0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, rttov_ZenAng=50.0, ! Satellite Zenith Angle / diff --git a/driver/run/rttov_channel_input2.csv b/driver/run/rttov_channel_input2.csv new file mode 100644 index 0000000000..01d2f42dc2 --- /dev/null +++ b/driver/run/rttov_channel_input2.csv @@ -0,0 +1,100 @@ +1,1,0 +2,1,0 +3,1,0 +4,1,0 +5,1,0 +6,1,0 +7,1,0 +8,1,0 +9,1,0 +10,1,0 +11,1,0 +12,1,0 +13,1,0 +14,1,0 +15,1,0 +16,1,0 +17,1,0 +18,1,0 +19,1,0 +20,1,0 +21,1,0 +22,1,0 +23,1,0 +24,1,0 +25,1,0 +26,1,0 +27,1,0 +28,1,0 +29,1,0 +30,1,0 +31,1,0 +32,1,0 +33,1,0 +34,1,0 +35,1,0 +36,1,0 +37,1,0 +38,1,0 +39,1,0 +40,1,0 +41,1,0 +42,1,0 +43,1,0 +44,1,0 +45,1,0 +46,1,0 +47,1,0 +48,1,0 +49,1,0 +50,1,0 +51,1,0 +52,1,0 +53,1,0 +54,1,0 +55,1,0 +56,1,0 +57,1,0 +58,1,0 +59,1,0 +60,1,0 +61,1,0 +62,1,0 +63,1,0 +64,1,0 +65,1,0 +66,1,0 +67,1,0 +68,1,0 +69,1,0 +70,1,0 +71,1,0 +72,1,0 +73,1,0 +74,1,0 +75,1,0 +76,1,0 +77,1,0 +78,1,0 +79,1,0 +80,1,0 +81,1,0 +82,1,0 +83,1,0 +84,1,0 +85,1,0 +86,1,0 +87,1,0 +88,1,0 +89,1,0 +90,1,0 +91,1,0 +92,1,0 +93,1,0 +94,1,0 +95,1,0 +96,1,0 +97,1,0 +98,1,0 +99,1,0 +100,1,0 \ No newline at end of file diff --git a/driver/run/rttov_channel_input_AIRS.csv b/driver/run/rttov_channel_input_AIRS.csv new file mode 100644 index 0000000000..4d71f96f24 --- /dev/null +++ b/driver/run/rttov_channel_input_AIRS.csv @@ -0,0 +1,2500 @@ +1,1,0 +2,1,0 +3,1,0 +4,1,0 +5,1,0 +6,1,0 +7,1,0 +8,1,0 +9,1,0 +10,1,0 +11,1,0 +12,1,0 +13,1,0 +14,1,0 +15,1,0 +16,1,0 +17,1,0 +18,1,0 +19,1,0 +20,1,0 +21,1,0 +22,1,0 +23,1,0 +24,1,0 +25,1,0 +26,1,0 +27,1,0 +28,1,0 +29,1,0 +30,1,0 +31,1,0 +32,1,0 +33,1,0 +34,1,0 +35,1,0 +36,1,0 +37,1,0 +38,1,0 +39,1,0 +40,1,0 +41,1,0 +42,1,0 +43,1,0 +44,1,0 +45,1,0 +46,1,0 +47,1,0 +48,1,0 +49,1,0 +50,1,0 +51,1,0 +52,1,0 +53,1,0 +54,1,0 +55,1,0 +56,1,0 +57,1,0 +58,1,0 +59,1,0 +60,1,0 +61,1,0 +62,1,0 +63,1,0 +64,1,0 +65,1,0 +66,1,0 +67,1,0 +68,1,0 +69,1,0 +70,1,0 +71,1,0 +72,1,0 +73,1,0 +74,1,0 +75,1,0 +76,1,0 +77,1,0 +78,1,0 +79,1,0 +80,1,0 +81,1,0 +82,1,0 +83,1,0 +84,1,0 +85,1,0 +86,1,0 +87,1,0 +88,1,0 +89,1,0 +90,1,0 +91,1,0 +92,1,0 +93,1,0 +94,1,0 +95,1,0 +96,1,0 +97,1,0 +98,1,0 +99,1,0 +100,1,0 +101,1,0 +102,1,0 +103,1,0 +104,1,0 +105,1,0 +106,1,0 +107,1,0 +108,1,0 +109,1,0 +110,1,0 +111,1,0 +112,1,0 +113,1,0 +114,1,0 +115,1,0 +116,1,0 +117,1,0 +118,1,0 +119,1,0 +120,1,0 +121,1,0 +122,1,0 +123,1,0 +124,1,0 +125,1,0 +126,1,0 +127,1,0 +128,1,0 +129,1,0 +130,1,0 +131,1,0 +132,1,0 +133,1,0 +134,1,0 +135,1,0 +136,1,0 +137,1,0 +138,1,0 +139,1,0 +140,1,0 +141,1,0 +142,1,0 +143,1,0 +144,1,0 +145,1,0 +146,1,0 +147,1,0 +148,1,0 +149,1,0 +150,1,0 +151,1,0 +152,1,0 +153,1,0 +154,1,0 +155,1,0 +156,1,0 +157,1,0 +158,1,0 +159,1,0 +160,1,0 +161,1,0 +162,1,0 +163,1,0 +164,1,0 +165,1,0 +166,1,0 +167,1,0 +168,1,0 +169,1,0 +170,1,0 +171,1,0 +172,1,0 +173,1,0 +174,1,0 +175,1,0 +176,1,0 +177,1,0 +178,1,0 +179,1,0 +180,1,0 +181,1,0 +182,1,0 +183,1,0 +184,1,0 +185,1,0 +186,1,0 +187,1,0 +188,1,0 +189,1,0 +190,1,0 +191,1,0 +192,1,0 +193,1,0 +194,1,0 +195,1,0 +196,1,0 +197,1,0 +198,1,0 +199,1,0 +200,1,0 +201,1,0 +202,1,0 +203,1,0 +204,1,0 +205,1,0 +206,1,0 +207,1,0 +208,1,0 +209,1,0 +210,1,0 +211,1,0 +212,1,0 +213,1,0 +214,1,0 +215,1,0 +216,1,0 +217,1,0 +218,1,0 +219,1,0 +220,1,0 +221,1,0 +222,1,0 +223,1,0 +224,1,0 +225,1,0 +226,1,0 +227,1,0 +228,1,0 +229,1,0 +230,1,0 +231,1,0 +232,1,0 +233,1,0 +234,1,0 +235,1,0 +236,1,0 +237,1,0 +238,1,0 +239,1,0 +240,1,0 +241,1,0 +242,1,0 +243,1,0 +244,1,0 +245,1,0 +246,1,0 +247,1,0 +248,1,0 +249,1,0 +250,1,0 +251,1,0 +252,1,0 +253,1,0 +254,1,0 +255,1,0 +256,1,0 +257,1,0 +258,1,0 +259,1,0 +260,1,0 +261,1,0 +262,1,0 +263,1,0 +264,1,0 +265,1,0 +266,1,0 +267,1,0 +268,1,0 +269,1,0 +270,1,0 +271,1,0 +272,1,0 +273,1,0 +274,1,0 +275,1,0 +276,1,0 +277,1,0 +278,1,0 +279,1,0 +280,1,0 +281,1,0 +282,1,0 +283,1,0 +284,1,0 +285,1,0 +286,1,0 +287,1,0 +288,1,0 +289,1,0 +290,1,0 +291,1,0 +292,1,0 +293,1,0 +294,1,0 +295,1,0 +296,1,0 +297,1,0 +298,1,0 +299,1,0 +300,1,0 +301,1,0 +302,1,0 +303,1,0 +304,1,0 +305,1,0 +306,1,0 +307,1,0 +308,1,0 +309,1,0 +310,1,0 +311,1,0 +312,1,0 +313,1,0 +314,1,0 +315,1,0 +316,1,0 +317,1,0 +318,1,0 +319,1,0 +320,1,0 +321,1,0 +322,1,0 +323,1,0 +324,1,0 +325,1,0 +326,1,0 +327,1,0 +328,1,0 +329,1,0 +330,1,0 +331,1,0 +332,1,0 +333,1,0 +334,1,0 +335,1,0 +336,1,0 +337,1,0 +338,1,0 +339,1,0 +340,1,0 +341,1,0 +342,1,0 +343,1,0 +344,1,0 +345,1,0 +346,1,0 +347,1,0 +348,1,0 +349,1,0 +350,1,0 +351,1,0 +352,1,0 +353,1,0 +354,1,0 +355,1,0 +356,1,0 +357,1,0 +358,1,0 +359,1,0 +360,1,0 +361,1,0 +362,1,0 +363,1,0 +364,1,0 +365,1,0 +366,1,0 +367,1,0 +368,1,0 +369,1,0 +370,1,0 +371,1,0 +372,1,0 +373,1,0 +374,1,0 +375,1,0 +376,1,0 +377,1,0 +378,1,0 +379,1,0 +380,1,0 +381,1,0 +382,1,0 +383,1,0 +384,1,0 +385,1,0 +386,1,0 +387,1,0 +388,1,0 +389,1,0 +390,1,0 +391,1,0 +392,1,0 +393,1,0 +394,1,0 +395,1,0 +396,1,0 +397,1,0 +398,1,0 +399,1,0 +400,1,0 +401,1,0 +402,1,0 +403,1,0 +404,1,0 +405,1,0 +406,1,0 +407,1,0 +408,1,0 +409,1,0 +410,1,0 +411,1,0 +412,1,0 +413,1,0 +414,1,0 +415,1,0 +416,1,0 +417,1,0 +418,1,0 +419,1,0 +420,1,0 +421,1,0 +422,1,0 +423,1,0 +424,1,0 +425,1,0 +426,1,0 +427,1,0 +428,1,0 +429,1,0 +430,1,0 +431,1,0 +432,1,0 +433,1,0 +434,1,0 +435,1,0 +436,1,0 +437,1,0 +438,1,0 +439,1,0 +440,1,0 +441,1,0 +442,1,0 +443,1,0 +444,1,0 +445,1,0 +446,1,0 +447,1,0 +448,1,0 +449,1,0 +450,1,0 +451,1,0 +452,1,0 +453,1,0 +454,1,0 +455,1,0 +456,1,0 +457,1,0 +458,1,0 +459,1,0 +460,1,0 +461,1,0 +462,1,0 +463,1,0 +464,1,0 +465,1,0 +466,1,0 +467,1,0 +468,1,0 +469,1,0 +470,1,0 +471,1,0 +472,1,0 +473,1,0 +474,1,0 +475,1,0 +476,1,0 +477,1,0 +478,1,0 +479,1,0 +480,1,0 +481,1,0 +482,1,0 +483,1,0 +484,1,0 +485,1,0 +486,1,0 +487,1,0 +488,1,0 +489,1,0 +490,1,0 +491,1,0 +492,1,0 +493,1,0 +494,1,0 +495,1,0 +496,1,0 +497,1,0 +498,1,0 +499,1,0 +500,1,0 +501,1,0 +502,1,0 +503,1,0 +504,1,0 +505,1,0 +506,1,0 +507,1,0 +508,1,0 +509,1,0 +510,1,0 +511,1,0 +512,1,0 +513,1,0 +514,1,0 +515,1,0 +516,1,0 +517,1,0 +518,1,0 +519,1,0 +520,1,0 +521,1,0 +522,1,0 +523,1,0 +524,1,0 +525,1,0 +526,1,0 +527,1,0 +528,1,0 +529,1,0 +530,1,0 +531,1,0 +532,1,0 +533,1,0 +534,1,0 +535,1,0 +536,1,0 +537,1,0 +538,1,0 +539,1,0 +540,1,0 +541,1,0 +542,1,0 +543,1,0 +544,1,0 +545,1,0 +546,1,0 +547,1,0 +548,1,0 +549,1,0 +550,1,0 +551,1,0 +552,1,0 +553,1,0 +554,1,0 +555,1,0 +556,1,0 +557,1,0 +558,1,0 +559,1,0 +560,1,0 +561,1,0 +562,1,0 +563,1,0 +564,1,0 +565,1,0 +566,1,0 +567,1,0 +568,1,0 +569,1,0 +570,1,0 +571,1,0 +572,1,0 +573,1,0 +574,1,0 +575,1,0 +576,1,0 +577,1,0 +578,1,0 +579,1,0 +580,1,0 +581,1,0 +582,1,0 +583,1,0 +584,1,0 +585,1,0 +586,1,0 +587,1,0 +588,1,0 +589,1,0 +590,1,0 +591,1,0 +592,1,0 +593,1,0 +594,1,0 +595,1,0 +596,1,0 +597,1,0 +598,1,0 +599,1,0 +600,1,0 +601,1,0 +602,1,0 +603,1,0 +604,1,0 +605,1,0 +606,1,0 +607,1,0 +608,1,0 +609,1,0 +610,1,0 +611,1,0 +612,1,0 +613,1,0 +614,1,0 +615,1,0 +616,1,0 +617,1,0 +618,1,0 +619,1,0 +620,1,0 +621,1,0 +622,1,0 +623,1,0 +624,1,0 +625,1,0 +626,1,0 +627,1,0 +628,1,0 +629,1,0 +630,1,0 +631,1,0 +632,1,0 +633,1,0 +634,1,0 +635,1,0 +636,1,0 +637,1,0 +638,1,0 +639,1,0 +640,1,0 +641,1,0 +642,1,0 +643,1,0 +644,1,0 +645,1,0 +646,1,0 +647,1,0 +648,1,0 +649,1,0 +650,1,0 +651,1,0 +652,1,0 +653,1,0 +654,1,0 +655,1,0 +656,1,0 +657,1,0 +658,1,0 +659,1,0 +660,1,0 +661,1,0 +662,1,0 +663,1,0 +664,1,0 +665,1,0 +666,1,0 +667,1,0 +668,1,0 +669,1,0 +670,1,0 +671,1,0 +672,1,0 +673,1,0 +674,1,0 +675,1,0 +676,1,0 +677,1,0 +678,1,0 +679,1,0 +680,1,0 +681,1,0 +682,1,0 +683,1,0 +684,1,0 +685,1,0 +686,1,0 +687,1,0 +688,1,0 +689,1,0 +690,1,0 +691,1,0 +692,1,0 +693,1,0 +694,1,0 +695,1,0 +696,1,0 +697,1,0 +698,1,0 +699,1,0 +700,1,0 +701,1,0 +702,1,0 +703,1,0 +704,1,0 +705,1,0 +706,1,0 +707,1,0 +708,1,0 +709,1,0 +710,1,0 +711,1,0 +712,1,0 +713,1,0 +714,1,0 +715,1,0 +716,1,0 +717,1,0 +718,1,0 +719,1,0 +720,1,0 +721,1,0 +722,1,0 +723,1,0 +724,1,0 +725,1,0 +726,1,0 +727,1,0 +728,1,0 +729,1,0 +730,1,0 +731,1,0 +732,1,0 +733,1,0 +734,1,0 +735,1,0 +736,1,0 +737,1,0 +738,1,0 +739,1,0 +740,1,0 +741,1,0 +742,1,0 +743,1,0 +744,1,0 +745,1,0 +746,1,0 +747,1,0 +748,1,0 +749,1,0 +750,1,0 +751,1,0 +752,1,0 +753,1,0 +754,1,0 +755,1,0 +756,1,0 +757,1,0 +758,1,0 +759,1,0 +760,1,0 +761,1,0 +762,1,0 +763,1,0 +764,1,0 +765,1,0 +766,1,0 +767,1,0 +768,1,0 +769,1,0 +770,1,0 +771,1,0 +772,1,0 +773,1,0 +774,1,0 +775,1,0 +776,1,0 +777,1,0 +778,1,0 +779,1,0 +780,1,0 +781,1,0 +782,1,0 +783,1,0 +784,1,0 +785,1,0 +786,1,0 +787,1,0 +788,1,0 +789,1,0 +790,1,0 +791,1,0 +792,1,0 +793,1,0 +794,1,0 +795,1,0 +796,1,0 +797,1,0 +798,1,0 +799,1,0 +800,1,0 +801,1,0 +802,1,0 +803,1,0 +804,1,0 +805,1,0 +806,1,0 +807,1,0 +808,1,0 +809,1,0 +810,1,0 +811,1,0 +812,1,0 +813,1,0 +814,1,0 +815,1,0 +816,1,0 +817,1,0 +818,1,0 +819,1,0 +820,1,0 +821,1,0 +822,1,0 +823,1,0 +824,1,0 +825,1,0 +826,1,0 +827,1,0 +828,1,0 +829,1,0 +830,1,0 +831,1,0 +832,1,0 +833,1,0 +834,1,0 +835,1,0 +836,1,0 +837,1,0 +838,1,0 +839,1,0 +840,1,0 +841,1,0 +842,1,0 +843,1,0 +844,1,0 +845,1,0 +846,1,0 +847,1,0 +848,1,0 +849,1,0 +850,1,0 +851,1,0 +852,1,0 +853,1,0 +854,1,0 +855,1,0 +856,1,0 +857,1,0 +858,1,0 +859,1,0 +860,1,0 +861,1,0 +862,1,0 +863,1,0 +864,1,0 +865,1,0 +866,1,0 +867,1,0 +868,1,0 +869,1,0 +870,1,0 +871,1,0 +872,1,0 +873,1,0 +874,1,0 +875,1,0 +876,1,0 +877,1,0 +878,1,0 +879,1,0 +880,1,0 +881,1,0 +882,1,0 +883,1,0 +884,1,0 +885,1,0 +886,1,0 +887,1,0 +888,1,0 +889,1,0 +890,1,0 +891,1,0 +892,1,0 +893,1,0 +894,1,0 +895,1,0 +896,1,0 +897,1,0 +898,1,0 +899,1,0 +900,1,0 +901,1,0 +902,1,0 +903,1,0 +904,1,0 +905,1,0 +906,1,0 +907,1,0 +908,1,0 +909,1,0 +910,1,0 +911,1,0 +912,1,0 +913,1,0 +914,1,0 +915,1,0 +916,1,0 +917,1,0 +918,1,0 +919,1,0 +920,1,0 +921,1,0 +922,1,0 +923,1,0 +924,1,0 +925,1,0 +926,1,0 +927,1,0 +928,1,0 +929,1,0 +930,1,0 +931,1,0 +932,1,0 +933,1,0 +934,1,0 +935,1,0 +936,1,0 +937,1,0 +938,1,0 +939,1,0 +940,1,0 +941,1,0 +942,1,0 +943,1,0 +944,1,0 +945,1,0 +946,1,0 +947,1,0 +948,1,0 +949,1,0 +950,1,0 +951,1,0 +952,1,0 +953,1,0 +954,1,0 +955,1,0 +956,1,0 +957,1,0 +958,1,0 +959,1,0 +960,1,0 +961,1,0 +962,1,0 +963,1,0 +964,1,0 +965,1,0 +966,1,0 +967,1,0 +968,1,0 +969,1,0 +970,1,0 +971,1,0 +972,1,0 +973,1,0 +974,1,0 +975,1,0 +976,1,0 +977,1,0 +978,1,0 +979,1,0 +980,1,0 +981,1,0 +982,1,0 +983,1,0 +984,1,0 +985,1,0 +986,1,0 +987,1,0 +988,1,0 +989,1,0 +990,1,0 +991,1,0 +992,1,0 +993,1,0 +994,1,0 +995,1,0 +996,1,0 +997,1,0 +998,1,0 +999,1,0 +1000,1,0 +1001,1,0 +1002,1,0 +1003,1,0 +1004,1,0 +1005,1,0 +1006,1,0 +1007,1,0 +1008,1,0 +1009,1,0 +1010,1,0 +1011,1,0 +1012,1,0 +1013,1,0 +1014,1,0 +1015,1,0 +1016,1,0 +1017,1,0 +1018,1,0 +1019,1,0 +1020,1,0 +1021,1,0 +1022,1,0 +1023,1,0 +1024,1,0 +1025,1,0 +1026,1,0 +1027,1,0 +1028,1,0 +1029,1,0 +1030,1,0 +1031,1,0 +1032,1,0 +1033,1,0 +1034,1,0 +1035,1,0 +1036,1,0 +1037,1,0 +1038,1,0 +1039,1,0 +1040,1,0 +1041,1,0 +1042,1,0 +1043,1,0 +1044,1,0 +1045,1,0 +1046,1,0 +1047,1,0 +1048,1,0 +1049,1,0 +1050,1,0 +1051,1,0 +1052,1,0 +1053,1,0 +1054,1,0 +1055,1,0 +1056,1,0 +1057,1,0 +1058,1,0 +1059,1,0 +1060,1,0 +1061,1,0 +1062,1,0 +1063,1,0 +1064,1,0 +1065,1,0 +1066,1,0 +1067,1,0 +1068,1,0 +1069,1,0 +1070,1,0 +1071,1,0 +1072,1,0 +1073,1,0 +1074,1,0 +1075,1,0 +1076,1,0 +1077,1,0 +1078,1,0 +1079,1,0 +1080,1,0 +1081,1,0 +1082,1,0 +1083,1,0 +1084,1,0 +1085,1,0 +1086,1,0 +1087,1,0 +1088,1,0 +1089,1,0 +1090,1,0 +1091,1,0 +1092,1,0 +1093,1,0 +1094,1,0 +1095,1,0 +1096,1,0 +1097,1,0 +1098,1,0 +1099,1,0 +1100,1,0 +1101,1,0 +1102,1,0 +1103,1,0 +1104,1,0 +1105,1,0 +1106,1,0 +1107,1,0 +1108,1,0 +1109,1,0 +1110,1,0 +1111,1,0 +1112,1,0 +1113,1,0 +1114,1,0 +1115,1,0 +1116,1,0 +1117,1,0 +1118,1,0 +1119,1,0 +1120,1,0 +1121,1,0 +1122,1,0 +1123,1,0 +1124,1,0 +1125,1,0 +1126,1,0 +1127,1,0 +1128,1,0 +1129,1,0 +1130,1,0 +1131,1,0 +1132,1,0 +1133,1,0 +1134,1,0 +1135,1,0 +1136,1,0 +1137,1,0 +1138,1,0 +1139,1,0 +1140,1,0 +1141,1,0 +1142,1,0 +1143,1,0 +1144,1,0 +1145,1,0 +1146,1,0 +1147,1,0 +1148,1,0 +1149,1,0 +1150,1,0 +1151,1,0 +1152,1,0 +1153,1,0 +1154,1,0 +1155,1,0 +1156,1,0 +1157,1,0 +1158,1,0 +1159,1,0 +1160,1,0 +1161,1,0 +1162,1,0 +1163,1,0 +1164,1,0 +1165,1,0 +1166,1,0 +1167,1,0 +1168,1,0 +1169,1,0 +1170,1,0 +1171,1,0 +1172,1,0 +1173,1,0 +1174,1,0 +1175,1,0 +1176,1,0 +1177,1,0 +1178,1,0 +1179,1,0 +1180,1,0 +1181,1,0 +1182,1,0 +1183,1,0 +1184,1,0 +1185,1,0 +1186,1,0 +1187,1,0 +1188,1,0 +1189,1,0 +1190,1,0 +1191,1,0 +1192,1,0 +1193,1,0 +1194,1,0 +1195,1,0 +1196,1,0 +1197,1,0 +1198,1,0 +1199,1,0 +1200,1,0 +1201,1,0 +1202,1,0 +1203,1,0 +1204,1,0 +1205,1,0 +1206,1,0 +1207,1,0 +1208,1,0 +1209,1,0 +1210,1,0 +1211,1,0 +1212,1,0 +1213,1,0 +1214,1,0 +1215,1,0 +1216,1,0 +1217,1,0 +1218,1,0 +1219,1,0 +1220,1,0 +1221,1,0 +1222,1,0 +1223,1,0 +1224,1,0 +1225,1,0 +1226,1,0 +1227,1,0 +1228,1,0 +1229,1,0 +1230,1,0 +1231,1,0 +1232,1,0 +1233,1,0 +1234,1,0 +1235,1,0 +1236,1,0 +1237,1,0 +1238,1,0 +1239,1,0 +1240,1,0 +1241,1,0 +1242,1,0 +1243,1,0 +1244,1,0 +1245,1,0 +1246,1,0 +1247,1,0 +1248,1,0 +1249,1,0 +1250,1,0 +1251,1,0 +1252,1,0 +1253,1,0 +1254,1,0 +1255,1,0 +1256,1,0 +1257,1,0 +1258,1,0 +1259,1,0 +1260,1,0 +1261,1,0 +1262,1,0 +1263,1,0 +1264,1,0 +1265,1,0 +1266,1,0 +1267,1,0 +1268,1,0 +1269,1,0 +1270,1,0 +1271,1,0 +1272,1,0 +1273,1,0 +1274,1,0 +1275,1,0 +1276,1,0 +1277,1,0 +1278,1,0 +1279,1,0 +1280,1,0 +1281,1,0 +1282,1,0 +1283,1,0 +1284,1,0 +1285,1,0 +1286,1,0 +1287,1,0 +1288,1,0 +1289,1,0 +1290,1,0 +1291,1,0 +1292,1,0 +1293,1,0 +1294,1,0 +1295,1,0 +1296,1,0 +1297,1,0 +1298,1,0 +1299,1,0 +1300,1,0 +1301,1,0 +1302,1,0 +1303,1,0 +1304,1,0 +1305,1,0 +1306,1,0 +1307,1,0 +1308,1,0 +1309,1,0 +1310,1,0 +1311,1,0 +1312,1,0 +1313,1,0 +1314,1,0 +1315,1,0 +1316,1,0 +1317,1,0 +1318,1,0 +1319,1,0 +1320,1,0 +1321,1,0 +1322,1,0 +1323,1,0 +1324,1,0 +1325,1,0 +1326,1,0 +1327,1,0 +1328,1,0 +1329,1,0 +1330,1,0 +1331,1,0 +1332,1,0 +1333,1,0 +1334,1,0 +1335,1,0 +1336,1,0 +1337,1,0 +1338,1,0 +1339,1,0 +1340,1,0 +1341,1,0 +1342,1,0 +1343,1,0 +1344,1,0 +1345,1,0 +1346,1,0 +1347,1,0 +1348,1,0 +1349,1,0 +1350,1,0 +1351,1,0 +1352,1,0 +1353,1,0 +1354,1,0 +1355,1,0 +1356,1,0 +1357,1,0 +1358,1,0 +1359,1,0 +1360,1,0 +1361,1,0 +1362,1,0 +1363,1,0 +1364,1,0 +1365,1,0 +1366,1,0 +1367,1,0 +1368,1,0 +1369,1,0 +1370,1,0 +1371,1,0 +1372,1,0 +1373,1,0 +1374,1,0 +1375,1,0 +1376,1,0 +1377,1,0 +1378,1,0 +1379,1,0 +1380,1,0 +1381,1,0 +1382,1,0 +1383,1,0 +1384,1,0 +1385,1,0 +1386,1,0 +1387,1,0 +1388,1,0 +1389,1,0 +1390,1,0 +1391,1,0 +1392,1,0 +1393,1,0 +1394,1,0 +1395,1,0 +1396,1,0 +1397,1,0 +1398,1,0 +1399,1,0 +1400,1,0 +1401,1,0 +1402,1,0 +1403,1,0 +1404,1,0 +1405,1,0 +1406,1,0 +1407,1,0 +1408,1,0 +1409,1,0 +1410,1,0 +1411,1,0 +1412,1,0 +1413,1,0 +1414,1,0 +1415,1,0 +1416,1,0 +1417,1,0 +1418,1,0 +1419,1,0 +1420,1,0 +1421,1,0 +1422,1,0 +1423,1,0 +1424,1,0 +1425,1,0 +1426,1,0 +1427,1,0 +1428,1,0 +1429,1,0 +1430,1,0 +1431,1,0 +1432,1,0 +1433,1,0 +1434,1,0 +1435,1,0 +1436,1,0 +1437,1,0 +1438,1,0 +1439,1,0 +1440,1,0 +1441,1,0 +1442,1,0 +1443,1,0 +1444,1,0 +1445,1,0 +1446,1,0 +1447,1,0 +1448,1,0 +1449,1,0 +1450,1,0 +1451,1,0 +1452,1,0 +1453,1,0 +1454,1,0 +1455,1,0 +1456,1,0 +1457,1,0 +1458,1,0 +1459,1,0 +1460,1,0 +1461,1,0 +1462,1,0 +1463,1,0 +1464,1,0 +1465,1,0 +1466,1,0 +1467,1,0 +1468,1,0 +1469,1,0 +1470,1,0 +1471,1,0 +1472,1,0 +1473,1,0 +1474,1,0 +1475,1,0 +1476,1,0 +1477,1,0 +1478,1,0 +1479,1,0 +1480,1,0 +1481,1,0 +1482,1,0 +1483,1,0 +1484,1,0 +1485,1,0 +1486,1,0 +1487,1,0 +1488,1,0 +1489,1,0 +1490,1,0 +1491,1,0 +1492,1,0 +1493,1,0 +1494,1,0 +1495,1,0 +1496,1,0 +1497,1,0 +1498,1,0 +1499,1,0 +1500,1,0 +1501,1,0 +1502,1,0 +1503,1,0 +1504,1,0 +1505,1,0 +1506,1,0 +1507,1,0 +1508,1,0 +1509,1,0 +1510,1,0 +1511,1,0 +1512,1,0 +1513,1,0 +1514,1,0 +1515,1,0 +1516,1,0 +1517,1,0 +1518,1,0 +1519,1,0 +1520,1,0 +1521,1,0 +1522,1,0 +1523,1,0 +1524,1,0 +1525,1,0 +1526,1,0 +1527,1,0 +1528,1,0 +1529,1,0 +1530,1,0 +1531,1,0 +1532,1,0 +1533,1,0 +1534,1,0 +1535,1,0 +1536,1,0 +1537,1,0 +1538,1,0 +1539,1,0 +1540,1,0 +1541,1,0 +1542,1,0 +1543,1,0 +1544,1,0 +1545,1,0 +1546,1,0 +1547,1,0 +1548,1,0 +1549,1,0 +1550,1,0 +1551,1,0 +1552,1,0 +1553,1,0 +1554,1,0 +1555,1,0 +1556,1,0 +1557,1,0 +1558,1,0 +1559,1,0 +1560,1,0 +1561,1,0 +1562,1,0 +1563,1,0 +1564,1,0 +1565,1,0 +1566,1,0 +1567,1,0 +1568,1,0 +1569,1,0 +1570,1,0 +1571,1,0 +1572,1,0 +1573,1,0 +1574,1,0 +1575,1,0 +1576,1,0 +1577,1,0 +1578,1,0 +1579,1,0 +1580,1,0 +1581,1,0 +1582,1,0 +1583,1,0 +1584,1,0 +1585,1,0 +1586,1,0 +1587,1,0 +1588,1,0 +1589,1,0 +1590,1,0 +1591,1,0 +1592,1,0 +1593,1,0 +1594,1,0 +1595,1,0 +1596,1,0 +1597,1,0 +1598,1,0 +1599,1,0 +1600,1,0 +1601,1,0 +1602,1,0 +1603,1,0 +1604,1,0 +1605,1,0 +1606,1,0 +1607,1,0 +1608,1,0 +1609,1,0 +1610,1,0 +1611,1,0 +1612,1,0 +1613,1,0 +1614,1,0 +1615,1,0 +1616,1,0 +1617,1,0 +1618,1,0 +1619,1,0 +1620,1,0 +1621,1,0 +1622,1,0 +1623,1,0 +1624,1,0 +1625,1,0 +1626,1,0 +1627,1,0 +1628,1,0 +1629,1,0 +1630,1,0 +1631,1,0 +1632,1,0 +1633,1,0 +1634,1,0 +1635,1,0 +1636,1,0 +1637,1,0 +1638,1,0 +1639,1,0 +1640,1,0 +1641,1,0 +1642,1,0 +1643,1,0 +1644,1,0 +1645,1,0 +1646,1,0 +1647,1,0 +1648,1,0 +1649,1,0 +1650,1,0 +1651,1,0 +1652,1,0 +1653,1,0 +1654,1,0 +1655,1,0 +1656,1,0 +1657,1,0 +1658,1,0 +1659,1,0 +1660,1,0 +1661,1,0 +1662,1,0 +1663,1,0 +1664,1,0 +1665,1,0 +1666,1,0 +1667,1,0 +1668,1,0 +1669,1,0 +1670,1,0 +1671,1,0 +1672,1,0 +1673,1,0 +1674,1,0 +1675,1,0 +1676,1,0 +1677,1,0 +1678,1,0 +1679,1,0 +1680,1,0 +1681,1,0 +1682,1,0 +1683,1,0 +1684,1,0 +1685,1,0 +1686,1,0 +1687,1,0 +1688,1,0 +1689,1,0 +1690,1,0 +1691,1,0 +1692,1,0 +1693,1,0 +1694,1,0 +1695,1,0 +1696,1,0 +1697,1,0 +1698,1,0 +1699,1,0 +1700,1,0 +1701,1,0 +1702,1,0 +1703,1,0 +1704,1,0 +1705,1,0 +1706,1,0 +1707,1,0 +1708,1,0 +1709,1,0 +1710,1,0 +1711,1,0 +1712,1,0 +1713,1,0 +1714,1,0 +1715,1,0 +1716,1,0 +1717,1,0 +1718,1,0 +1719,1,0 +1720,1,0 +1721,1,0 +1722,1,0 +1723,1,0 +1724,1,0 +1725,1,0 +1726,1,0 +1727,1,0 +1728,1,0 +1729,1,0 +1730,1,0 +1731,1,0 +1732,1,0 +1733,1,0 +1734,1,0 +1735,1,0 +1736,1,0 +1737,1,0 +1738,1,0 +1739,1,0 +1740,1,0 +1741,1,0 +1742,1,0 +1743,1,0 +1744,1,0 +1745,1,0 +1746,1,0 +1747,1,0 +1748,1,0 +1749,1,0 +1750,1,0 +1751,1,0 +1752,1,0 +1753,1,0 +1754,1,0 +1755,1,0 +1756,1,0 +1757,1,0 +1758,1,0 +1759,1,0 +1760,1,0 +1761,1,0 +1762,1,0 +1763,1,0 +1764,1,0 +1765,1,0 +1766,1,0 +1767,1,0 +1768,1,0 +1769,1,0 +1770,1,0 +1771,1,0 +1772,1,0 +1773,1,0 +1774,1,0 +1775,1,0 +1776,1,0 +1777,1,0 +1778,1,0 +1779,1,0 +1780,1,0 +1781,1,0 +1782,1,0 +1783,1,0 +1784,1,0 +1785,1,0 +1786,1,0 +1787,1,0 +1788,1,0 +1789,1,0 +1790,1,0 +1791,1,0 +1792,1,0 +1793,1,0 +1794,1,0 +1795,1,0 +1796,1,0 +1797,1,0 +1798,1,0 +1799,1,0 +1800,1,0 +1801,1,0 +1802,1,0 +1803,1,0 +1804,1,0 +1805,1,0 +1806,1,0 +1807,1,0 +1808,1,0 +1809,1,0 +1810,1,0 +1811,1,0 +1812,1,0 +1813,1,0 +1814,1,0 +1815,1,0 +1816,1,0 +1817,1,0 +1818,1,0 +1819,1,0 +1820,1,0 +1821,1,0 +1822,1,0 +1823,1,0 +1824,1,0 +1825,1,0 +1826,1,0 +1827,1,0 +1828,1,0 +1829,1,0 +1830,1,0 +1831,1,0 +1832,1,0 +1833,1,0 +1834,1,0 +1835,1,0 +1836,1,0 +1837,1,0 +1838,1,0 +1839,1,0 +1840,1,0 +1841,1,0 +1842,1,0 +1843,1,0 +1844,1,0 +1845,1,0 +1846,1,0 +1847,1,0 +1848,1,0 +1849,1,0 +1850,1,0 +1851,1,0 +1852,1,0 +1853,1,0 +1854,1,0 +1855,1,0 +1856,1,0 +1857,1,0 +1858,1,0 +1859,1,0 +1860,1,0 +1861,1,0 +1862,1,0 +1863,1,0 +1864,1,0 +1865,1,0 +1866,1,0 +1867,1,0 +1868,1,0 +1869,1,0 +1870,1,0 +1871,1,0 +1872,1,0 +1873,1,0 +1874,1,0 +1875,1,0 +1876,1,0 +1877,1,0 +1878,1,0 +1879,1,0 +1880,1,0 +1881,1,0 +1882,1,0 +1883,1,0 +1884,1,0 +1885,1,0 +1886,1,0 +1887,1,0 +1888,1,0 +1889,1,0 +1890,1,0 +1891,1,0 +1892,1,0 +1893,1,0 +1894,1,0 +1895,1,0 +1896,1,0 +1897,1,0 +1898,1,0 +1899,1,0 +1900,1,0 +1901,1,0 +1902,1,0 +1903,1,0 +1904,1,0 +1905,1,0 +1906,1,0 +1907,1,0 +1908,1,0 +1909,1,0 +1910,1,0 +1911,1,0 +1912,1,0 +1913,1,0 +1914,1,0 +1915,1,0 +1916,1,0 +1917,1,0 +1918,1,0 +1919,1,0 +1920,1,0 +1921,1,0 +1922,1,0 +1923,1,0 +1924,1,0 +1925,1,0 +1926,1,0 +1927,1,0 +1928,1,0 +1929,1,0 +1930,1,0 +1931,1,0 +1932,1,0 +1933,1,0 +1934,1,0 +1935,1,0 +1936,1,0 +1937,1,0 +1938,1,0 +1939,1,0 +1940,1,0 +1941,1,0 +1942,1,0 +1943,1,0 +1944,1,0 +1945,1,0 +1946,1,0 +1947,1,0 +1948,1,0 +1949,1,0 +1950,1,0 +1951,1,0 +1952,1,0 +1953,1,0 +1954,1,0 +1955,1,0 +1956,1,0 +1957,1,0 +1958,1,0 +1959,1,0 +1960,1,0 +1961,1,0 +1962,1,0 +1963,1,0 +1964,1,0 +1965,1,0 +1966,1,0 +1967,1,0 +1968,1,0 +1969,1,0 +1970,1,0 +1971,1,0 +1972,1,0 +1973,1,0 +1974,1,0 +1975,1,0 +1976,1,0 +1977,1,0 +1978,1,0 +1979,1,0 +1980,1,0 +1981,1,0 +1982,1,0 +1983,1,0 +1984,1,0 +1985,1,0 +1986,1,0 +1987,1,0 +1988,1,0 +1989,1,0 +1990,1,0 +1991,1,0 +1992,1,0 +1993,1,0 +1994,1,0 +1995,1,0 +1996,1,0 +1997,1,0 +1998,1,0 +1999,1,0 +2000,1,0 +2001,1,0 +2002,1,0 +2003,1,0 +2004,1,0 +2005,1,0 +2006,1,0 +2007,1,0 +2008,1,0 +2009,1,0 +2010,1,0 +2011,1,0 +2012,1,0 +2013,1,0 +2014,1,0 +2015,1,0 +2016,1,0 +2017,1,0 +2018,1,0 +2019,1,0 +2020,1,0 +2021,1,0 +2022,1,0 +2023,1,0 +2024,1,0 +2025,1,0 +2026,1,0 +2027,1,0 +2028,1,0 +2029,1,0 +2030,1,0 +2031,1,0 +2032,1,0 +2033,1,0 +2034,1,0 +2035,1,0 +2036,1,0 +2037,1,0 +2038,1,0 +2039,1,0 +2040,1,0 +2041,1,0 +2042,1,0 +2043,1,0 +2044,1,0 +2045,1,0 +2046,1,0 +2047,1,0 +2048,1,0 +2049,1,0 +2050,1,0 +2051,1,0 +2052,1,0 +2053,1,0 +2054,1,0 +2055,1,0 +2056,1,0 +2057,1,0 +2058,1,0 +2059,1,0 +2060,1,0 +2061,1,0 +2062,1,0 +2063,1,0 +2064,1,0 +2065,1,0 +2066,1,0 +2067,1,0 +2068,1,0 +2069,1,0 +2070,1,0 +2071,1,0 +2072,1,0 +2073,1,0 +2074,1,0 +2075,1,0 +2076,1,0 +2077,1,0 +2078,1,0 +2079,1,0 +2080,1,0 +2081,1,0 +2082,1,0 +2083,1,0 +2084,1,0 +2085,1,0 +2086,1,0 +2087,1,0 +2088,1,0 +2089,1,0 +2090,1,0 +2091,1,0 +2092,1,0 +2093,1,0 +2094,1,0 +2095,1,0 +2096,1,0 +2097,1,0 +2098,1,0 +2099,1,0 +2100,1,0 +2101,1,0 +2102,1,0 +2103,1,0 +2104,1,0 +2105,1,0 +2106,1,0 +2107,1,0 +2108,1,0 +2109,1,0 +2110,1,0 +2111,1,0 +2112,1,0 +2113,1,0 +2114,1,0 +2115,1,0 +2116,1,0 +2117,1,0 +2118,1,0 +2119,1,0 +2120,1,0 +2121,1,0 +2122,1,0 +2123,1,0 +2124,1,0 +2125,1,0 +2126,1,0 +2127,1,0 +2128,1,0 +2129,1,0 +2130,1,0 +2131,1,0 +2132,1,0 +2133,1,0 +2134,1,0 +2135,1,0 +2136,1,0 +2137,1,0 +2138,1,0 +2139,1,0 +2140,1,0 +2141,1,0 +2142,1,0 +2143,1,0 +2144,1,0 +2145,1,0 +2146,1,0 +2147,1,0 +2148,1,0 +2149,1,0 +2150,1,0 +2151,1,0 +2152,1,0 +2153,1,0 +2154,1,0 +2155,1,0 +2156,1,0 +2157,1,0 +2158,1,0 +2159,1,0 +2160,1,0 +2161,1,0 +2162,1,0 +2163,1,0 +2164,1,0 +2165,1,0 +2166,1,0 +2167,1,0 +2168,1,0 +2169,1,0 +2170,1,0 +2171,1,0 +2172,1,0 +2173,1,0 +2174,1,0 +2175,1,0 +2176,1,0 +2177,1,0 +2178,1,0 +2179,1,0 +2180,1,0 +2181,1,0 +2182,1,0 +2183,1,0 +2184,1,0 +2185,1,0 +2186,1,0 +2187,1,0 +2188,1,0 +2189,1,0 +2190,1,0 +2191,1,0 +2192,1,0 +2193,1,0 +2194,1,0 +2195,1,0 +2196,1,0 +2197,1,0 +2198,1,0 +2199,1,0 +2200,1,0 +2201,1,0 +2202,1,0 +2203,1,0 +2204,1,0 +2205,1,0 +2206,1,0 +2207,1,0 +2208,1,0 +2209,1,0 +2210,1,0 +2211,1,0 +2212,1,0 +2213,1,0 +2214,1,0 +2215,1,0 +2216,1,0 +2217,1,0 +2218,1,0 +2219,1,0 +2220,1,0 +2221,1,0 +2222,1,0 +2223,1,0 +2224,1,0 +2225,1,0 +2226,1,0 +2227,1,0 +2228,1,0 +2229,1,0 +2230,1,0 +2231,1,0 +2232,1,0 +2233,1,0 +2234,1,0 +2235,1,0 +2236,1,0 +2237,1,0 +2238,1,0 +2239,1,0 +2240,1,0 +2241,1,0 +2242,1,0 +2243,1,0 +2244,1,0 +2245,1,0 +2246,1,0 +2247,1,0 +2248,1,0 +2249,1,0 +2250,1,0 +2251,1,0 +2252,1,0 +2253,1,0 +2254,1,0 +2255,1,0 +2256,1,0 +2257,1,0 +2258,1,0 +2259,1,0 +2260,1,0 +2261,1,0 +2262,1,0 +2263,1,0 +2264,1,0 +2265,1,0 +2266,1,0 +2267,1,0 +2268,1,0 +2269,1,0 +2270,1,0 +2271,1,0 +2272,1,0 +2273,1,0 +2274,1,0 +2275,1,0 +2276,1,0 +2277,1,0 +2278,1,0 +2279,1,0 +2280,1,0 +2281,1,0 +2282,1,0 +2283,1,0 +2284,1,0 +2285,1,0 +2286,1,0 +2287,1,0 +2288,1,0 +2289,1,0 +2290,1,0 +2291,1,0 +2292,1,0 +2293,1,0 +2294,1,0 +2295,1,0 +2296,1,0 +2297,1,0 +2298,1,0 +2299,1,0 +2300,1,0 +2301,1,0 +2302,1,0 +2303,1,0 +2304,1,0 +2305,1,0 +2306,1,0 +2307,1,0 +2308,1,0 +2309,1,0 +2310,1,0 +2311,1,0 +2312,1,0 +2313,1,0 +2314,1,0 +2315,1,0 +2316,1,0 +2317,1,0 +2318,1,0 +2319,1,0 +2320,1,0 +2321,1,0 +2322,1,0 +2323,1,0 +2324,1,0 +2325,1,0 +2326,1,0 +2327,1,0 +2328,1,0 +2329,1,0 +2330,1,0 +2331,1,0 +2332,1,0 +2333,1,0 +2334,1,0 +2335,1,0 +2336,1,0 +2337,1,0 +2338,1,0 +2339,1,0 +2340,1,0 +2341,1,0 +2342,1,0 +2343,1,0 +2344,1,0 +2345,1,0 +2346,1,0 +2347,1,0 +2348,1,0 +2349,1,0 +2350,1,0 +2351,1,0 +2352,1,0 +2353,1,0 +2354,1,0 +2355,1,0 +2356,1,0 +2357,1,0 +2358,1,0 +2359,1,0 +2360,1,0 +2361,1,0 +2362,1,0 +2363,1,0 +2364,1,0 +2365,1,0 +2366,1,0 +2367,1,0 +2368,1,0 +2369,1,0 +2370,1,0 +2371,1,0 +2372,1,0 +2373,1,0 +2374,1,0 +2375,1,0 +2376,1,0 +2377,1,0 +2378,1,0 +2379,1,0 +2380,1,0 +2381,1,0 +2382,1,0 +2383,1,0 +2384,1,0 +2385,1,0 +2386,1,0 +2387,1,0 +2388,1,0 +2389,1,0 +2390,1,0 +2391,1,0 +2392,1,0 +2393,1,0 +2394,1,0 +2395,1,0 +2396,1,0 +2397,1,0 +2398,1,0 +2399,1,0 +2400,1,0 +2401,1,0 +2402,1,0 +2403,1,0 +2404,1,0 +2405,1,0 +2406,1,0 +2407,1,0 +2408,1,0 +2409,1,0 +2410,1,0 +2411,1,0 +2412,1,0 +2413,1,0 +2414,1,0 +2415,1,0 +2416,1,0 +2417,1,0 +2418,1,0 +2419,1,0 +2420,1,0 +2421,1,0 +2422,1,0 +2423,1,0 +2424,1,0 +2425,1,0 +2426,1,0 +2427,1,0 +2428,1,0 +2429,1,0 +2430,1,0 +2431,1,0 +2432,1,0 +2433,1,0 +2434,1,0 +2435,1,0 +2436,1,0 +2437,1,0 +2438,1,0 +2439,1,0 +2440,1,0 +2441,1,0 +2442,1,0 +2443,1,0 +2444,1,0 +2445,1,0 +2446,1,0 +2447,1,0 +2448,1,0 +2449,1,0 +2450,1,0 +2451,1,0 +2452,1,0 +2453,1,0 +2454,1,0 +2455,1,0 +2456,1,0 +2457,1,0 +2458,1,0 +2459,1,0 +2460,1,0 +2461,1,0 +2462,1,0 +2463,1,0 +2464,1,0 +2465,1,0 +2466,1,0 +2467,1,0 +2468,1,0 +2469,1,0 +2470,1,0 +2471,1,0 +2472,1,0 +2473,1,0 +2474,1,0 +2475,1,0 +2476,1,0 +2477,1,0 +2478,1,0 +2479,1,0 +2480,1,0 +2481,1,0 +2482,1,0 +2483,1,0 +2484,1,0 +2485,1,0 +2486,1,0 +2487,1,0 +2488,1,0 +2489,1,0 +2490,1,0 +2491,1,0 +2492,1,0 +2493,1,0 +2494,1,0 +2495,1,0 +2496,1,0 +2497,1,0 +2498,1,0 +2499,1,0 +2500,1,0 \ No newline at end of file diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 45786a4562..43510a11d6 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -1009,7 +1009,10 @@ subroutine construct_cospIN(npoints,ncolumns,nlevels,y) y%Npart = 4 y%Nrefl = PARASOL_NREFL allocate(y%frac_out(npoints, ncolumns,nlevels)) - + if (Lrttov) then + y%nChannels_rttov = rttov_Nchannels ! RTTOV dimension + endif + if (Lmodis .or. Lmisr .or. Lisccp) then allocate(y%tau_067(npoints, ncolumns,nlevels),& y%emiss_11(npoints, ncolumns,nlevels)) @@ -1052,7 +1055,6 @@ subroutine construct_cospIN(npoints,ncolumns,nlevels,y) y%asym(npoints, ncolumns,nlevels),& y%ss_alb(npoints, ncolumns,nlevels)) endif - end subroutine construct_cospIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 4d33bcb505..b6d183d08a 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -32,7 +32,8 @@ ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MODULE MOD_COSP_RTTOV_INTERFACE USE COSP_KINDS, ONLY: wp - use mod_cosp_rttov, only: nChannels,iChannel,coef_rttov,opts,rttov_in, & + use mod_cosp_rttov, only: nChannels,iChannel,emisChannel,reflChannel, & + coef_rttov,opts,rttov_in, & do_rttov_bt,do_rttov_rad,do_rttov_refl, & do_rttov_cld,do_rttov_aer,rttov_cld_optparam, & rttov_aer_optparam,rttov_direct_nthreads, & @@ -74,7 +75,7 @@ MODULE MOD_COSP_RTTOV_INTERFACE !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_init !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, & + SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, & Lrttov_cld,Lrttov_aer,Lrttov_cldparam,Lrttov_aerparam, & rttov_input_namelist) integer,intent(in) :: & @@ -104,7 +105,8 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, cld_coef_file, & OD_coef_filepath, & aer_coef_filepath, & - cld_coef_filepath + cld_coef_filepath, & + channel_filepath real(wp) :: & SO2_mr, & @@ -124,17 +126,15 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, character(len=256) :: cosp_status integer :: & + i, & rttov_nthreads - - integer,dimension(NchanIN) :: & - rttov_Channels ! RTTOV channels - + ! Read RTTOV namelist fields - namelist/RTTOV_INPUT/rttov_srcDir,rttov_coefDir, & + namelist/RTTOV_INPUT/channel_filepath,rttov_srcDir,rttov_coefDir, & OD_coef_filepath,aer_coef_filepath,cld_coef_filepath, & SO2_mr,N2O_mr,CO_mr,CH4_mr,CO2_mr,rttov_ZenAng, & ! Mixing ratios SO2_data,N2O_data,CO_data,CH4_data,CO2_data,ozone_data, & - rttov_nthreads,rttov_Channels + rttov_nthreads !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Read in namelists @@ -143,11 +143,26 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, read(10,nml=RTTOV_INPUT) close(10) + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Read in channel indices, emissivities, and reflectivities from .csv + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + allocate(iChannel(NchanIN)) + allocate(emisChannel(NchanIN)) + allocate(reflChannel(NchanIN)) + + open(18,file=channel_filepath,access='sequential',form="formatted") + do i = 1, NchanIN + read(18,*) iChannel(i), emisChannel(i), reflChannel(i) + end do + close(18) + +! print*,'iChannel: ',iChannel +! print*,'emisChannel: ',emisChannel +! print*,'reflChannel: ',reflChannel + ! Initialize fields in module memory (cosp_rttovXX.F90) rttovDir = rttov_srcDir nChannels = NchanIN - allocate(iChannel(NchanIN)) - iChannel = rttov_Channels ! Set logicals for RTTOV options do_rttov_bt = Lrttov_bt @@ -402,9 +417,7 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, refl_total,refl_clear) ! print*,'cosp_rttov_save_and_deallocate_profiles successful' ! jks call cpu_time(driver_time(6)) - -! print*,'RTTOV Tb output: ',bt_total - + print*,'Time to run "cosp_rttov_allocate": ', driver_time(2)-driver_time(1) print*,'Time to run "cosp_rttov_construct_profiles": ', driver_time(3)-driver_time(2) print*,'Time to run "cosp_rttov_setup_emissivity_reflectance": ',driver_time(4)-driver_time(3) diff --git a/src/simulator/investigate_Reff_UKMOinput.ipynb b/src/simulator/investigate_Reff_UKMOinput.ipynb new file mode 100644 index 0000000000..c9e34ebd18 --- /dev/null +++ b/src/simulator/investigate_Reff_UKMOinput.ipynb @@ -0,0 +1,564 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "b383f9ab-8645-4946-abbf-c368a9df3aef", + "metadata": {}, + "source": [ + "" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "50923d7e-3f95-4dda-b13c-18abc2848391", + "metadata": {}, + "outputs": [], + "source": [ + "import xarray as xr\n", + "import numpy as np\n", + "\n", + "import sys\n", + "import os\n", + "import glob" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "4247ee33-73ef-430a-952a-34cbb98c66f9", + "metadata": {}, + "outputs": [], + "source": [ + "cosp_input_dir = '/glade/u/home/jonahshaw/Scripts/git_repos/COSPv2.0/driver/data/inputs/UKMO/'" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "6b3ebe12-5659-4043-b1c1-65dd7b433cc0", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['cosp_input_um_2d.nc',\n", + " 'cosp_input.um_global.nc',\n", + " 'cosp_input_um.nc',\n", + " 'cosp_input.um_global.nc.md5']" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "os.listdir(cosp_input_dir)" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "a2f77fe4-f91e-4fee-9e2b-fb9c29b86fa9", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['/glade/u/home/jonahshaw/Scripts/git_repos/COSPv2.0/driver/data/inputs/UKMO/cosp_input.um_global.nc', '/glade/u/home/jonahshaw/Scripts/git_repos/COSPv2.0/driver/data/inputs/UKMO/cosp_input_um.nc', '/glade/u/home/jonahshaw/Scripts/git_repos/COSPv2.0/driver/data/inputs/UKMO/cosp_input_um_2d.nc']\n" + ] + } + ], + "source": [ + "cosp_input_files = glob.glob('%s/*.nc' % cosp_input_dir)\n", + "cosp_input_files.sort()\n", + "print(cosp_input_files)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "9207936f-5417-4d23-b466-30d083be4841", + "metadata": {}, + "outputs": [], + "source": [ + "testfile = xr.open_dataset(cosp_input_files[1])" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "5f1de400-ab33-4643-bb61-f423792e3599", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAERCAYAAAB2CKBkAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy86wFpkAAAACXBIWXMAAAsTAAALEwEAmpwYAAAgsUlEQVR4nO3deZQmdX3v8feHYWBkC+KMAWZA0DtH3BB0AigeL3FjkQseRQNXNIq5kxg3EjWukahZrlGJeFFx1EGMBKKABhRBgguuyMwIjDB4RNwGEBzZXWCm+3P/qGp5aLr7qe6u6qeers/rnDrdtTz1/dWg/X3qt8o2ERHRXVsNugARETFYSQQRER2XRBAR0XFJBBERHZdEEBHRcUkEEREdl0QQEUNL0mpJt0r6QU33G5F0ZbmdX8c9h4EyjiAihpWkpwP3AJ+y/fga7neP7R1mX7LhkjeCiBhati8Dbus9JulRki6StFbSNyTtM6DiDY0kgoiYb1YBr7H9ZOANwIen8dlFktZI+q6k5zVSuhbaetAFiIioi6QdgKcCn5U0dnjb8tzzgXdN8LEbbR9a/r6n7ZskPRL4iqT1tn/cdLkHLYkgIuaTrYA7bO83/oTt84Dzpvqw7ZvKnzdI+hqwPzDvE0GqhiJi3rB9F/ATSS8EUOGJVT4r6aGSxt4eFgMHA9c2VtgWSSKIiKEl6SzgO8CjJW2U9ArgxcArJF0FXAMcXfF2jwHWlJ/7KvB/bXciEaT7aEREx+WNICKi41rVWLyNtvUith90MSKi5e7m9k22l8zmHof+6fb+9W0jla5de/W9F9s+bDbx2qxViWAR23OgnjnoYkREy/23z/nZbO/x69tG+N7Fe1a6dsFuP1o823ht1qpEEBExVwyMMjroYrRCEkFEdJIxm12tami+SyKIiM7KG0EhiSAiOsmYkXSfB5IIIqLDRkkigCSCiOgoAyNJBEASQUR0WN4ICo0mAkl/A/wFRfJdD7zc9u+bjBkRUYWBzWkjABqcYkLSUuC1wIpyCbkFwLFNxYuImA5jRipu813TVUNbAw+RtBnYDrip4XgREdUYRub/3/hKGnsjsH0j8D7g58DNwJ22vzz+Okkry6Xh1mzm3qaKExHxAMXI4mrbfNdk1dBDKeYB3xvYHdhe0vHjr7O9yvYK2ysWFivKRUTMATFScZvvmpyG+lnAT2z/yvZmiiXintpgvIiIyorGYlXa5rsm2wh+DhwkaTvgd8AzgTUNxouIqKwYRzD//8hX0VgisH25pHOAdcAW4PvAqqbiRURM12gHvu1X0WivIdsnASc1GSMiYibyRnC/jCyOiE4yYiSr9QJJBBHRYakaKiQdRkQnGXGfF1Ta+pG0h6SvStog6RpJr5vgmkMk3SnpynJ7RyMPNgN5I4iITioGlNX2XXgL8Hrb6yTtCKyVdInta8dd9w3bR9YVtC5JBBHRWXU1Ftu+mWIGBWzfLWkDsBQYnwhaKVVDEdFJthjxVpU2YPHYVDjltnKy+0raC9gfuHyC00+RdJWkL0l6XDNPNn15I4iIzhqt/kawyfaKfhdJ2gE4FzjR9l3jTq8DHmH7HklHAJ8Hlk+juI3JG0FEdFLRWLx1pa0KSQspksCZts97UDz7Ltv3lL9fCCyUtLjOZ5qpvBFERCfV2VgsScAngA22T57kml2BW2xb0gEUX8R/XUsBZimJICI6a6S+cQQHAy8B1ku6sjz2VmBPANunAccAr5S0hWL+tWPtdiyRlkQQEZ1U58hi29+EqRscbJ8KnFpLwJolEUREZ406zaSQRBARHVVMOpdEAEkEEdFRRmyuMH1EFyQRREQn2YwNFuu8JtcsfnTP5EpXSrpL0olNxYuImB4xWnGb75pcoeyHwH4AkhYANwKfaypeRMR0mLwRjJmrqqFnAj+2/bM5ihcR0VcaiwtzlQiOBc6ao1gREX0ZZWGaUuOJQNI2wFHAWyY5vxJYCbCI7ZouTkQEUFQNba44j9B8NxfvRYcD62zfMtFJ26tsr7C9YiHbzkFxIiIAxEjFbWAllF5YLnSDpLdLOk/Sk+qOMxeJ4DhSLRQRLWOKkcVVtgH6+3Khm6cBhwJnAB+pO0ijTyhpO+DZwIOmZI2IGLS2vxEAI+XP5wIfsf1fwDZ1B2m0gsz2b4GHNRkjImImbA36234VN0r6KPAs4D2StqWBL/BpKYmITioai1s/xcSLgMOA99m+Q9JuwBvrDpJEEBEdpWEYULYYWAMgac/y2HV1B0kiiIhOKhqLWz+O4IsURRWwCNgb+CFQ68L3SQQR0VltH1ls+wm9+2XX0b+sO04SQUR00jCOLLa9TtKf1H3fJIKI6Ky6Fq9viqS/7dndCngS8Ku64yQRREQn2bB5tN2JANix5/ctFG0G59YdJIkgIjqpqBpqdyKw/c65iJNEEBGdNeBRw5OS9AHbJ0q6gKLX0APYPqrOeEkEEdFJLe8++u/lz/fNRbAkgojoqPZWDdleW/78+lzESyKIiM5q63rEktYzQZXQGNv71hkviSAiOqnoNdTauYaOLH++qvw5VlX0YuC3dQdLIoiITmrzgLKx9d0lHWz74J5Tb5b0LeBddcZrZwVZRMQcGEWVtgHavlyUBgBJTwW2rztI3ggiopNa3mtozCuA1ZL+qNy/Azih7iCNJgJJOwMfBx5P8e9+gu3vNBkzIqKqtvYaGlP2HnqipJ0A2b6ziThNvxGcAlxk+xhJ2wDbNRwvIqISW2ypKRFI2gP4FLArMAqssn3KuGtE8TfxCIoG35fZXlfh3s+lmHZ6UXELsF1rG0FjiaDMYE8HXgZg+z7gvqbiRURMV41VQ1uA15ezg+4IrJV0ie1re645HFhebgdSLEJ/4FQ3lXQaxRfoP6WoXTkG+F5dhR7T5HvRIylmyTtd0vclfVzSgxo5JK2UtEbSms3c22BxIiLuN9ZGUGXrey/75rFv97bvBjYAS8dddjTwKRe+C+xcLj05lafafilweznv0FOAPab5qH01mQi2ppgy9SO29wd+A7x5/EW2V9leYXvFQrZtsDgREQ80jUSweOwLa7mtnOyekvYC9gcuH3dqKfCLnv2NPDhZjPf78udvJe0ObKZYpaxWTbYRbAQ22h77xziHCRJBRMQgTHMcwSbbK/pdJGkHimmiT7R91/jTExZjaheUnW7eC6wrr/9Y/+JOT2OJwPYvJf1C0qNt/xB4JnBtv89FRMyVOscISFpIkQTOtH3eBJds5IHVOsuAm6a431bApbbvAM6V9AVgURM9h5ruNfQa4Myyx9ANwMsbjhcRUYkNW2pamKbsEfQJYIPtkye57Hzg1ZLOpmgkvtP2zZOXz6OS3k/RLoDte6GZhtRGE4HtK4G+r1MREYNQY6+hg4GXAOslXVkeeyuwJ4Dt04ALKbqOXk/RfbTKF+MvS3oBcJ7tftVIM5aRxRHRSXXONWT7m0zcBtB7jbl/Ermq/pZiSoktkn5fxrDtnWZU0EkkEUREZ7nlU0zY3nGq85IeZ/ua2cZp9/jqiIgGDcGkc/38e/9L+ssbQUR0kj0Uk871U8sDJBFEREeJkZp6DQ1QLQ3ISQQR0VltbyOYK0kEMW9cfNNVDzp26O5PHEBJYhgMyXoE/dQykefQvxdFRMyIi3aCKtugqHC8pHeU+3tKOuAPj2AfVEecJIKI6Kwh6DX0YYqRxceV+3cDH6o7SKqGIqKTPByNxQfafpKk7wPYvr2csqdWSQQR0VmDrPapaLOkBZS9gyQtoVgBrVZJBBHRWUPQa+iDwOeAh0v6J4oVyt5ed5AkgojopKIhuN2JwPaZktZSTOMv4Hm2N9QdJ4kgIjqr7d1HJZ0C/Kft2huIe7W+pSQioilt7z5KsSrZ2yVdL+m9khqZ1r/RNwJJP6Xo7jQCbKmy1FtExFwwYrTlvYZsnwGcIWkX4AXAeyTtaXt5nXHmomroT21vmoM4ERHT0v5OQ3/wP4B9gL1oYMnftBFERDcNQWOxpPcAzwd+DHwGeHe5hnGtmk4EplhqzcBHba8af4GklcBKgEVs13BxIiJ6tP+V4CfAU5quVWk6ERxs+yZJDwcukXSd7ct6LyiTwyqAnbRL+/+zRMS80dY3Akn72L4O+B6wp6Q9e8/bXldnvKYXr7+p/HmrpM8BBwCXTf2piIjmGRgdbWcioFireCXw/gnOGXhGncEaSwSStge2sn13+ftzgHc1FS8iYloMtPSNwPbK8tfDbf++95ykRXXHa7Lv1B8D35R0FcXrzRdtX9RgvIiIaRmCcQTfrnhsVhp7I7B9A5BVQSKivVraKilpV2Ap8BBJ+3P/2sQ7Qf29atJ9NCI6Sq1tLAYOBV4GLKNoJxgr6F3AW+sOlkQQEd3V0jeCnhHFL7B9btPx2j2+OiKiKQaPqtI2QE+WtPPYjqSHSvrHuoMkEUREh6niNjCH944ktn07cETdQZIIIqK7XHEbnAWSth3bkfQQYNsprp+RtBFERHe1tI2gx6eBSyWdTlHaE4Az6g7SyUSw6a+eWvlaTfQ/lAmOPWxV7V17Y5oO3T29lWMaWjygbIztf5V0NfAsijqqd9u+uO44laqGJC2T9DlJv5J0i6RzJS2ruzAREXOprgFlklZLulXSDyY5f4ikOyVdWW7vmEYxNwAX2X498A1JO07js5VUbSM4HTgf2I1ikMMF5bGIiOE1qmpbf58EDutzzTds71dulabbkfR/gHOAj5aHlgKfr/LZ6aiaCJbYPt32lnL7JLCk7sJERMwludrWTzmr8m0NFPFVwMEUA8mw/SPg4XUHqZoINkk6XtKCcjse+HXdhYmImDNVewwViWCxpDU928oJ7zm1p0i6StKXJD2u4mfutX3f2I6krWmgibtqY/EJwKnAv5WF+HZ5LCJiSGk6jcWbZrnm+jrgEbbvkXQERfVOlXWHvy7prRRzDj0b+GuKqvla9U0EkhYA/2z7qLqDR0QM1Bx1H7V9V8/vF0r6sKTFFVYeezPwCmA98JfAhcDH6y5f30Rge0TSEknb9L6iREQMvdG5CVPOJnqLbUs6gKJaftLqdUmX2n4m8C+23wR8rM/9z69QjNtsv2yiE1Wrhn4KfKsM9puxg7ZPrvj5iIh2qXEcgaSzgEMo2hI2AicBCwFsnwYcA7xS0hbgd8Cx9pQdU3eT9D+BoySdzbh5LiZYqvIxwF9MVUTgQ5OdrJoIbiq3rYBp9WEtq5bWADfaPnI6n42IaFKVHkFV2D6uz/lTKdpZq3oHRbXQMmD8F+6Jlqp8m+2vT3VDSe+c7FylRGB70htU8DqKARE7zeIeERH1a+8UEzfbPlzSO6qMObD9mdlcM2UikHQBU/xT9WtALkcfPxf4J4rFmCMior8PAk8Gnsc01nqXtAJ4G/AIir/vAmx736k+1++N4H3lz+cDu1JMgARwHEW7QT8fAP6OKaqTyv64KwEW1b8CW0TEpOqqGmrA5nKiuaWSPjj+pO3XTvK5M4E3UvQyqtwUPmUiGKtzkvRu20/vOXWBpMum+qykI4Fbba+VdMgUMVYBqwB20i7t/c8SEfOLqTp9xCAcSTHR3DOAtdP43K9sV+lB9ABVG4uXSHpkuSA9kvam/xQTB1O0eB8BLAJ2kvRp28dPt5AREY1o6VfPcnzB2ZI22L5qGh89SdLHgUuBe3vud95UH6qaCP4G+JqkG8r9vSircyZj+y3AW6CYeQ94Q5JARLRJi6uGxvxO0qXAH9t+vKR9gaNsT7Zc5cuBfSi6ro5VDRmYfSKwfZGk5WUAgOts3zvVZyIiWq/9ieBjFHX+HwWwfbWk/wAmSwRPtP2E6Qapuh7BGophzj+3fdV0k4Dtr2UMQUS0TvuXqtzO9vfGHdsyxfXflfTY6QapOvvosRTzYF8h6WxJh0pqbStLREQ/VaegHnD10SZJj6JMR5KOAW6e4vqnAVdK+qGkqyWtL1c4m1LVqqHrgbdJ+nuK1uzVwKik1cAptpuYhzsiolnt7TU05lUUvSr3kXQj8BPgxVNc329xnAlVXrO4bKQ4ATgcOJeiv+rTgK8A+80keETEILW9sbjsqfksSdsDW9m+u/e8pD+3fYakdbafZPtnk91r7JqJzlVKBJLWAndQTH/6pp42gsslHVzlHhERrdPyRDDG9m8mOfU64AzgMX2qgAT80WQnq74RvATYH9gbeNNY84Dtd9l+fsV7RES0x+Dr/+swVre1z5RXFUYmO1E1EZxM8Uawjp5BChERQ234E4EBpqoSqqJqIlhme0aNEBERbaU5WpimQbW0dldNBN+W9ATb6+sIOmiLT/v2oIsQETElSVsBx/SZYvpbdcTqNw31eopXj62Bl5dTTNxLxalNIyJarcVVQ7ZHJb0amDQR2H51HbH6vRFkNHBEzE/D0Vh8iaQ3AP/JA5cJrnXsVr9pqGfVABER0WrtTwQnlD9f1XPMwCPrDFJ5QFlExLzT8kRge++5iJNEEBGdJNrfa0jSQuCVwNjCYF8DPmp7c51xkggiopuGo43gIxRrC3y43H9Jeewv6gySRBAR3dX+RPAntp/Ys/8VSdNZsaySqtNQT5ukRZK+J+kqSddIemdTsSIiZqT96xGMlNNQAyDpkUwxVcRMNflGcC/wDNv3lPVc35T0JdvfbTBmRERlQ1A19Ebgq+UYLgGPoFiOslaNJQLbBu4pdxeWW/v/2SOiO1r+F8n2peUywY+mSASNLBPcWNUQgKQFkq4EbgUusX35BNeslLRG0prNmc8uIuaKi15DVbZBkbQdxVvBa2xfBewpqfaBvo0mAtsjtvcDlgEHSHr8BNessr3C9oqFbNtkcSIiHqj9bQSnA/cBTyn3NzL5wvUz1mgiGGP7Dor+r5nBNCJaYwjWLH6U7X8FNgPY/h01zTjaq8leQ0sk7Vz+/hDgWcB1TcWLiJi29r8R3Ff+/RxbvP5RNLAmTJNvBLtRtHZfDVxB0UbwhQbjRURUVzUJVEgEklZLulXSDyY5L0kflHS9pKslTbh28AT+AbgI2EPSmcClwJsqfrayJnsNXU2xvGVEROuIWqt9PgmcCnxqkvOHA8vL7UCK0cEH9rup7S+Xa8YfRFHk19neVEeBe81JG0FERBvV1UZg+zJgqqmhjwY+5cJ3gZ0l7da3fNKltn9t+4u2v2B7k6RLqz5fVZliIiK6q/obwWJJa3r2V9leNY1IS4Ff9OxvLI/dPNHFkhYB25VxH8r9DcQ7AbtPI24lSQQR0V3VE8Em2ytmEWminj5TRf9L4ESKP/rreo7fBXxoFuWYUBJBRHTT3HYN3Qjs0bO/DLhpsottnwKcIuk1tv9f04VLG0FEdNfcdR89H3hp2XvoIOBO2xNWC42zWtLbJa0CkLS8iZHFeSOIiM6qa/oISWcBh1DU6W8ETqKYXw3bpwEXAkcA1wO/pfrEcauBtcBTy/2NwGeBWrviJxFERGfVVTVk+7g+580D1x2u6lG2/0zSceV9fiep9pHFSQQR0U2DHzVcxZyMLE4iiIjuan8iOIkHjiw+GHhZ3UGSCCKik2oeWdwI25dIWkfDI4uTCCKiszTa8kxQWAosoPh7/XRJ2D6vzgBJBBHRTUPQRiBpNbAvcA0w1sfJQBJBREQd2l41BBxk+7FNB8mAsojorvavR/AdSY0ngrwRRERnDcEbwRkUyeCXFN1GRTEsYd86gzSWCCTtQTE3964UdVuryvkzIiLaof2JYDXwEmA997cR1K7JN4ItwOttr5O0I7BW0iW2r20wZkRENa5viokG/dz2+U0HaXKFspsp59q2fbekDRTdoJIIImLghmEcAXCdpP8ALqBnRPFQdh+VtBfFspWXT3BuJbASYBHbzUVxIiIKbn0meAhFAnhOz7Hh6z4qaQfgXOBE23eNP1+u8rMKYCft0vr/KhExf7T9jcB21VlKZ6XR7qOSFlIkgTPrfpWJiJiVql1HB5gsJC2T9DlJt0q6RdK5kpbVHaexRFBOlfoJYIPtk5uKExExUxqttg3Q6RSL2uxO0cZ6QXmsVk2+ERxM0e3pGZKuLLcjGowXETEtQ5AIltg+3faWcvsksKTuIE32GvomEy/YHBExeGYYGos3SToeOKvcPw74dd1BMsVERHSWXG0boBOAFwG/pOiOf0x5rFaZYiIiuqvFLwSSFgD/bPuopmMlEUREJ7V9QJntEUlLJG1j+74mYyURREQ32cOwMM1PgW9JOh/4zdjBuntiJhFERHe1Pg9wU7ltBezYVJAkgojorDZXDQHYfudcxEkiiIhuMtDSqiFJFzDF+0rdDchJBDFv+Gn7PejY1ut/8qBjI3feOQeliaHQzjwA8L7y5/Mp1nT5dLl/HEW7Qa2SCCKis9paNWT76wCS3m376T2nLpB0Wd3xMqAsIjpLo660DdASSY/8Q3mlvRmmKSYiIlpt8AvTV/E3wNck3VDu70W5fkudkggiopOKAWXtzgS2L5K0HNinPHSd7Xun+sxMpGooIrprtOI2IJLWAK+gWLv4qiaSACQRRESHya60VbqXdJikH0q6XtKbJzh/iKQ7e6blf0eF2x5LsQ7BFZLOlnRoudZLrVI1FBHdVGMbQTlB3IeAZwMbKf5wn2/72nGXfsP2kZWLaF8PvE3S3wNHAquBUUmrgVNs31ZH+ZtcoWx1ubzaD5qKERExc9V6DFXsNXQAcL3tG8oJ4s4Gjq6jlJL2BU4G3kux9O8xwF3AV+q4PzRbNfRJ4LAG7x8RMTt2tQ0WS1rTs43vubMU+EXP/sby2HhPkXSVpC9Jely/4klaC/wbcDmwr+3X2r7c9vuBG6b+dHVNrlB2maS9mrp/RMSseFrLUG6yvWKK8xPV249/lVgHPML2PeWyvZ8HlveJ+xJgf2Bv4E1jzQO232X7+VUKXkUaiyOiu6q/EfSzEdijZ38ZxayhPaF8l+17yt8vBBZKWtznvicD/wvYQjEN9dhWq4E3FpevWCsBFrHdgEsTEZ1S3zCCK4Dl5cjfGyl6+/zv3gsk7QrcYtuSDqD4It5v/eFlthuvYh94IrC9ClgFsJN2affojoiYVzRazyAB21skvRq4GFgArLZ9jaS/Ks+fRtHI+0pJW4DfAcfafV83vi3pCbbX11LQSQw8EUREDISpdbBYWd1z4bhjp/X8fipwapV7SVpflnBr4OXlFBP3UrRF2Pa+dZUbGkwEks4CDqFobd8InGT7E03Fi4iYDlF9sNgAVB5rUIcmew0d19S9IyJq0dJEYPtncxkvVUMR0V0tTQRzLYkgIrqp5jaCYZZEEBGdVVevoWGXRBARHVV5sNi8l0QQEd1kkghKSQQR0V2pGQKSCCKiw1o8jmBOJRGUFjz+0RMe169uf9Cx3z9hzwcd8yTT9y388ppZlSuq0zevfNCxkbkvRgyTJAIgiSAiusqGkdQNQRJBRHRZ3giAJIKI6LIkAiCJICK6ykC19YjnvSSCiOgog9NGAEkEEdFVJo3FpSSCiOiutBEASQQR0WVJBECxeHJjJB0m6YeSrpf05iZjRURMTznpXJVtnmtyqcoFwIeAZwMbgSsknW/72qZiRkRUZiDTUAPNvhEcAFxv+wbb9wFnA0c3GC8iYnryRgA020awFPhFz/5G4MDxF0laCawEWMR2DRYnIqJXppgY02Qi0ATHHpRaba8CVgHspF3mf+qNiHYwOOMIgGYTwUZgj579ZcBNDcaLiJiejCwGmm0juAJYLmlvSdsAxwLnNxgvImJ60kYANPhGYHuLpFcDFwMLgNW2r2kqXkTEtNjpNVRqdECZ7QuBC5uMERExYx34tl9FRhZHREcZj2QNO0giiIiuyjTUf5BEEBHdle6jQMNzDUVEtJUBj7rSVkW/udVU+GB5/mpJT6r7mWYqiSAiusnlwjRVtj565lY7HHgscJykx4677HBgebmtBD5S7wPNXBJBRHSWR0YqbRVUmVvtaOBTLnwX2FnSbvU+0cy0qo3gbm7f9N8+52fAYmDTnAZfP41rfznjKHP/XM2bj88Eea62e8Rsb3A3t1/83z5nccXLF0la07O/qpweZ0yVudUmumYpcHPFMjSmVYnA9hIASWtsrxh0eeo2H59rPj4T5Lm6wPZhNd6uytxqleZfG4RUDUVEzF6VudVaO/9aEkFExOxVmVvtfOClZe+hg4A7bQ+8WghaVjXUY1X/S4bSfHyu+fhMkOeKaZhsbjVJf1WeP41iup0jgOuB3wIvH1R5x5Mz10ZERKelaigiouOSCCIiOq51iaDfMO1hIWm1pFsl/aDn2C6SLpH0o/LnQwdZxumStIekr0raIOkaSa8rjw/tc0laJOl7kq4qn+md5fGhfaZekhZI+r6kL5T78+K5ol6tSgQVh2kPi08C4/spvxm41PZy4NJyf5hsAV5v+zHAQcCryv8+w/xc9wLPsP1EYD/gsLJHxzA/U6/XARt69ufLc0WNWpUIqDZMeyjYvgy4bdzho4Ezyt/PAJ43l2WaLds3215X/n43xR+YpQzxc5XD/e8pdxeWmxniZxojaRnwXODjPYeH/rmifm1LBJMNwZ4v/nis33D58+EDLs+MSdoL2B+4nCF/rrL65ErgVuAS20P/TKUPAH8H9M6aNh+eK2rWtkTQ2iHYcT9JOwDnAifavmvQ5Zkt2yO296MY6XmApMcPuEizJulI4Fbbawddlmi/tiWC1g7BrsktY7MNlj9vHXB5pk3SQookcKbt88rDQ/9cALbvAL5G0bYz7M90MHCUpJ9SVLE+Q9KnGf7niga0LRFUGaY9zM4H/rz8/c+B/xpgWaZNkoBPABtsn9xzamifS9ISSTuXvz8EeBZwHUP8TAC232J7me29KP5/9BXbxzPkzxXNaN3IYklHUNRtjg3T/qfBlmhmJJ0FHEIx7e8twEnA54HPAHsCPwdeaHt8g3JrSXoa8A2KSbvH6p3fStFOMJTPJWlfikbTBRRfjD5j+12SHsaQPtN4kg4B3mD7yPn0XFGf1iWCiIiYW22rGoqIiDmWRBAR0XFJBBERHZdEEBHRcUkEEREdl0QQAyHpnv5XDf6eEV2QRBAR0XFJBDFwkt4o6QpJV/esB/AeSX/dc80/SHr9ZNdHxMwlEcRASXoOsJxiCvL9gCdLejrF/Dh/1nPpi4DPTnF9RMzQ1oMuQHTec8rt++X+DsBy25+Q9HBJuwNLgNtt/1zSaye6HrhsjssdMW8kEcSgCfgX2x+d4Nw5wDHArhRvCP2uj4gZSNVQDNrFwAnlGgdIWippbLGUsylmzjyGIin0uz4iZiBvBDFQtr8s6THAd4pZrrkHOJ5iUZVrJO0I3Nizqtak1w/kASLmgcw+GhHRcakaiojouCSCiIiOSyKIiOi4JIKIiI5LIoiI6LgkgoiIjksiiIjouP8PcKbnmCfswJ4AAAAASUVORK5CYII=\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], + "source": [ + "testfile['Reff'].sel(point=1).plot()" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "73a2a2f1-63b2-4a8e-93b9-1cffdef85b8d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXkAAAERCAYAAACepNcKAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy86wFpkAAAACXBIWXMAAAsTAAALEwEAmpwYAAAd1klEQVR4nO3debAlZZ3m8e9DsRSFlEJTLlAiYNOCjSxajQgOo4ACSqCB6EgIo6BTxowi7uJKo2N32NqE2KMOJYK0IKiACuqwNDbSKgJVrCIY0qhYgAICAi5QdeuZPzKvHIq75KmbefKck88nIuPezJMnf29i+Ku8b77v+5NtIiJiPK3XdgMiIqI5SfIREWMsST4iYowlyUdEjLEk+YiIMZYkHxExxpLkI2JkSTpF0l2SflLT9baWdJGkmyT9VNI2dVy3TUnyETHKvgQcUOP1/hX4pO0dgd2Bu2q8diuS5CNiZNm+DLi395ikZ0q6QNIKSf8haYcq15L0bGB92xeX137I9h/rb/VgJclHxLhZBhxt+3nAu4HPVfze3wD3SzpX0jWSPilpXmOtHJD1225ARERdJD0B2BP4uqTJwxuVnx0CfHSKr91ue3+KfPhfgN2A24CvAm8Avthsq5uVJB8R42Q94H7bu679ge1zgXNn+O5K4BrbtwJI+iawByOe5NNdExFjw/YDwC8kvRpAhV0qfv0qYDNJi8r9fYCfNtDMgUqSj4iRJelM4HLgWZJWSnoj8DrgjZKuA24EXlHlWrYnKPrwL5F0AyDgC820fHCUpYYjIsZXnuQjIsbYUL143VAbeT6btN2MiBhyD3LfPbYXzX7m9PZ/8Sb+3b0Tlc5dcf3DF9quc9LVwAxVkp/PJjxf+7bdjIgYcv/ms38112v87t4Jrrxw60rnznvaz7eYa7y2DFWSj4gYFANrWNN2MxqXJB8RnWTMKlfrrhllSfIR0Vl5ko+IGFPGTHRgCHmSfER01hqS5CMixpKBiST5iIjxlSf5OZL0DuBNFP9o3gAcafvPTcaMiKjCwKoO9Mk3tqyBpK2AtwFLbO8EzANe21S8iIh+GDNRcRtlTXfXrA9sLGkVsAC4o+F4ERHVGCZGO39X0tiTvO3bgU9RVFi5E/i97YvWPk/SUknLJS1fxcNNNSci4jGKGa/VtlHWZHfNZhTrOG8LbAlsIunwtc+zvcz2EttLNiiqdEVEDICYqLiNsiaXGt4P+IXtu22voii7tWeD8SIiKitevKrSNsqa7JO/DdhD0gLgT8C+wPIG40VEVFaMkx/tBF5FY0ne9hWSzgauBlYD1wDLmooXEdGvNSP+lF5Fo6NrbB8HHNdkjIiIdZEn+YiIMWbERAcqoCbJR0RnpbsmImJMGfGI57XdjMYlyUdEJxWTodJdExExtvLiNSJiTNliwnmSj4gYW2vyJB8RMZ6KF6/jnwLH/w4jIqaQF68REWNuIuPkIyLGU2a8RkSMuTUZXRMRMZ6KBcqS5CMixpIRq7KsQUTEeLLpxGSoJmu8PkvStT3bA5Le3lS8iIj+iDUVt1HWZGWonwG7AkiaB9wOfKOpeBER/TDdeJIfVHfNvsB/2v7VgOJFRMwqL17r81rgzAHFioiYlVGKhtRB0obAwcD7p/l8KbAUYD4Lmm5ORARQdNes6sDaNYP4W+VA4Grbv53qQ9vLbC+xvWQDNhpAcyIiAMRExa32yNKrJW1a/v4hSedKem7tgRhMkj+MdNVExJAxxYzXKlsVkt4h6UZJP5F0pqT5M5z+YdsPSnohsD9wGvD5ud/V4zWa5CUtAF4CnNtknIiIdVHXk7ykrYC3AUts7wTMo3gXOX3owsuBz9v+FrDhHG9nSo12SNn+I/BXTcaIiFgXtupeu2Z9YGNJq4AFwB0znHu7pJOA/YBPSNqIhh66x3/8UETEFIoXr/MqbcAWkpb3bEsfcy37duBTwG3AncDvbV80Q/jXABcCB9i+H9gceE8Dt5llDSKiq/qq8XqP7SXTXknaDHgFsC1wP/B1SYfbPn2ar2wBLC+/u3V57OaqjelHknxEdFLx4rW2kTP7Ab+wfTeApHOBPYHpkvx3yiYImE/xj8PPgL+tq0GTkuQjorNqnPF6G7BHOdjkTxSz/JdPd7Lt5/Tul8Mn31xXY3olyUdEJ9U549X2FZLOBq4GVgPXAMv6+P7Vkv6ulsasJUk+IjqrzkLeto8DjqtyrqR39uyuBzwXuLu2xvRIko+ITrJh1ZrWBhhu2vP7aoo++nOaCJQkHxGdVHTXtJPkbR8/qFhJ8hHRWU2sSzMTSZ+2/XZJ51OMrnkM2wfXHTNJPiI6qeYhlFV9ufz5qUEFTJKPiI4afHeN7RXlz+8PKmaSfER01qDrt0q6gSm6aSbZ3rnumEnyEdFJxeiaeYMOe1D58y3lz8num9cBf2wiYJJ8RHRSG+X/JutcS9rL9l49Hx0r6YfAR+uOmVUoI6Kz1qBKWwM2KQuGACBpT2CTJgLlST4iOqml0TWT3gicIumJ5f79wFFNBGo0yUt6EnAysBPFf9OjbF/eZMyIiKpanAy1AthF0kJAtn/fVKymn+RPBC6wfaikDSmqpUREtM4Wq1tK8gCSXk6xtPB8SWWbXHuffGNJvvwXam/gDQC2HwEeaSpeRES/2uqukfR/KR56X0zR23EocGUTsZr8Z2w7ilXVTpV0jaSTJT3uxYKkpZMltVbxcIPNiYh41GSffJWtAXva/u/AfeU6Ni8Ant5EoCaT/PoUy2d+3vZuwB+AY9c+yfYy20tsL9mAjRpsTkTEY7WY5P9c/vyjpC2BVRTVoWrXZJJfCay0fUW5fzZF0o+IaN3kOPmWkvz55cCUT1IUGvklcGYTgRrrk7f9G0m/lvQs2z+jKIf106biRUT0a9DLGgBIWg+4xPb9wDmSvg3Mb2qETdOja44GzihH1twKHNlwvIiISmxY3ULRENtrJP0zRT88th+G5l5INprkbV8LLGkyRkTEumpxMtRFkl4FnGt72gXL6pAZrxHRSW2sXdPjnRTLGKyW9GdAgG0vrDtQknxEdJZbSvK2N53pc0l/a/vGOmJlgbKI6KwWFyibzZdnP6WaPMlHRCfZrfbJz6a2hiXJR0RHiYkWRtdUVNvL2CT5iOistvrkBylJPiI6qeX15GdT22KOQ/u3SkREo1z0y1fZ6qbC4ZI+Uu5vLWn3vzTN3qOuWEnyEdFZLY6u+RzFjNfDyv0Hgc82ESjdNRHRSW73xevzbT9X0jUAtu8rl3+pXZJ8RHRWswsKzGiVpHmUo2gkLQLWNBEoST4iOqvF0TWfAb4BPFnSxykqQ32oiUBJ8hHRScVL1daWNThD0gqKJdgFvNL2TU3ESpKPiM5qscbricBXbTfysrVXRtdERGe1NYSSohrUhyTdIumTkhpbkr3RJ3lJv6QYGjQBrLadteUjYigYsaal0TW2TwNOk7Q58CrgE5K2tr193bEG0V3zYtv3DCBORERf6nxIL2u2ngzsVF76KNuXz/K1vwZ2ALahofKo6ZOPiG6q/8XricAFtg8tx7wvmO5ESZ8ADgH+E/ga8LGy5mvtmk7ypihzZeAk28vWPkHSUmApwPzp/5tERNSvpkd5SQuBvYE3ANh+hJnXn/kF8IJB9HI0neT3sn2HpCcDF0u62fZlvSeUiX8ZwEJt3t7UhIjonD6e5LeQtLxnf9laD63bAXcDp0raBVgBHGP7D70XkbSD7ZuBK4GtJW392Pb46n7vYTZNF/K+o/x5l6RvALsDl838rYiI5hlYs6Zykr9nloEj6wPPBY62fUU5RPJY4MNrnfdOip6Lf56mSftUbVBVjSV5SZsA69l+sPz9pcBHm4oXEdEXA/X1ya8EVtq+otw/myLJPzakvbT89UDbf+79TNL8uhrTq8nxQ08BfiDpOoo/Tb5j+4IG40VE9KWucfK2fwP8WtKzykP7MvNomR9VPDZnjT3J274V2KWp60dEzFm9bwGPBs4oR9bcChy59gmSngpsBWwsaTcereW6kBlG48xFhlBGREep1iGUtq8FZpvwuT/FCJzFFP3ykw14APhAbY3pkSQfEd014PF8PTNdX2X7nEHEzNo1EdFNBq9Rpa0BzytnyAIgaTNJ/7uJQEnyEdFhqrjV7sDeGa627wNe1kSgJPmI6C5X3Oo3T9JGkzuSNgY2muH8dZY++Yjorvbm2J8OXCLp1LIVRwGnNRGok0n+t9/a8XHHpnvLPjFFf9xUy5NOV3xgqv68NROP/76nqe74zMOvmfqDiJibeidD9Rfa/idJ1wP7UfQHfcz2hU3EqpTkJS0G/gV4IUWx2R9QrMuwsolGRUQMQouFvAFuoqiz8W+SFkja1PaDdQep2id/KnAe8DSKgfznl8ciIkbXGlXbaibpf1AsfXBSeWgr4Ju1B6J6kl9k+1Tbq8vtS8CiJhoUETEocrWtAW8B9qKYBIXtnwNPbiJQ1SR/j6TDJc0rt8OB3zXRoIiIgag6sqaZJP9wueY8AJLWbypS1SR/FPAa4DfAncCh5bGIiBGl4sVrla1+35f0AYo1bF4CfJ2iG7x2s754lTQP+AfbBzfRgIiI1rT34vVY4I3ADcCbge9S1Iet3axJ3vaEpEWSNuz98yIiYuRNM3S5KZIusb0v8I+23wd8ocJ3zqtw6Xttv2GqD6qOk/8l8MMy2F/KWdk+oeL3IyKGSzvj5J8m6b8CB0s6i7XWTJim/N+OwJtmuKaAz073YdUkf0e5rQdsWvE7RfSiu2c5cLvtg/r5bkREkxoaOTOTj1B01SwG1n5Inq783wdtf3+mi0o6frrPKiV529NeoIJjKAb9L5zDNSIi6jf4JH+n7QMlfcR2pXKotr82l3NmTPKSzmeG/wyzvYwtZ8q+HPg4RQHbiIgu+wzwPOCV9FnzWtIS4IPAMyhytwDb3nmm7832JP+p8uchwFMpFtUBOIyin342nwbeywxdPJKWUlQvZ34z1a8iIqbUQnfNqnJRsq0kfWbtD22/bYbvngG8h2JETuVXxjMm+cl+IEkfs713z0fnS7pspu9KOgi4y/YKSS+aIcYyYBnAQm3e7koSEdEdppElC2ZxEMWiZPsAK/r87t22q4y0eYyqL14XSdquLM6NpG2ZfVmDvSjeIL8MmA8slHS67cP7bWRERCMGX/7vHuAsSTfZvq7Prx8n6WTgEuDhnmueO9OXqib5dwCXSrq13N+GsotlOrbfD7wfoHySf3cSfEQMkxa6ayb9SdIlwFNs7yRpZ+Bg2zOVADwS2AHYgEe7awzMPcnbvkDS9mUAgJttPzzTdyIihl57Sf4LFP3rJwHYvl7SV4CZkvwutp/Tb6BKa9dIWk4xBfc229f1m+BtX5ox8hExdNpboGyB7SvXOrZ6lu/8WNKz+w1UdYGy11Ksd3yVpLMk7S+pnZIqERE1qLrMcENdOvdIeiblPyGSDqVY/HEmLwSulfQzSddLuqGsLjWjqt01twAflPRhirfDpwBrJJ0CnGj73irXiYgYKoMfXTPpLRSjCneQdDvwC+B1s3zngHUJVLnGa/li4CjgQOAcijGbLwS+B+y6LsEjItrU1ovXcqTifpI2AdZbu+yfpNfbPq38/Wrbz7X9q+muN3nOVJ9VrfG6ArifYinM9/X0yV8haa8q14iIGDotz8yx/YdpPjoGOK38fcdZumUEPHG6D6s+yR8B7AZsC7xvsjve9kdtH1LxGhERw6O5/vY69PYj7TDtWY+amO6Dqkn+BIon+avpGYQfETHShjfJ/6VlM3XTVFE1yS+2vU6d/hERw0oDLhrSh9reCFdN8j+S9BzbN9QVuE1PecVNbTchIjpK0nrAobMsIfzDuuLNttTwDRR/NqwPHFkua/AwFZe4jIgYai1019heI+mtwLRJ3vZb64o325N8ZqlGxHhq98XrxZLeDXyVx5ZUrX3O0WxLDc+pwz8iYqi1l+SPKn++peeYge3qDlR5MlRExNhpbzLUtoOKlSQfEZ0k6h1dI2kesBy4fbYFGSVtAPxPYLIY06XASbZX1deiQpJ8RHRT/X3yxwA3AQsrnPt5inXhP1fuH1Eee1OtLSJJPiK6rKYkL2kx8HLg48A7K3zl72zv0rP/PUn9VoqqpOpSw32TNF/SlZKuk3SjpOObihURsU6qrye/haTlPdvalfE+DbyX6gW2J8qlhgGQtB0zLE0wF00+yT8M7GP7obL/6QeS/p/tHzcYMyKisj66a+6xvWTKa0gHAXfZXlGWOq3iPcC/l3OPBDyDorxf7RpL8rYNPFTublBuw7tSRER0Tz0ZaS/gYEkvA+YDCyWdPlNNa9uXlCVVn0WR5BsrqdpYdw0Ub5slXQvcBVxs+4opzlk6+SfQqqx9FhGD4mJ0TZVtxsvY77e92PY2FFX0vjdTggeQtIDiaf5o29cBW5d/EdSu0SRve8L2rsBiYHdJO01xzjLbS2wv2YCNmmxORMRjtVfj9VTgEeAF5f5KZi7ivc4aTfKTbN9PMQ40K1lGxNCou8ar7UtnGyNfeqbtfwJWld/7EzWuPNmrydE1iyQ9qfx9Y2A/4Oam4kVE9K29J/lHyrw4Wcj7mTRUq6PJ0TVPA04rZ4GtB3zN9rcbjBcRUV1zCbyKvwcuAJ4u6QyKl7cjN7rmeoqSgRERQ0e0Wsj7orJ29h5lU46xfU8TsTLjNSI6q60kL+kS2/sC35niWK2S5COiuwac5CXNBxZQzKDdjEdfti4EtmwiZpJ8RHTX4J/k3wy8nSKhX91z/AHgs00ETJKPiG5qoTKU7ROBEyUdbftfBhFzIOPkIyKGUntDKE+R9CFJywAkbT+SM14jIoZZHcsarKNTKGa87lnuj/aM14iIYVT3jNc+DGzGa/rkI6Kb2p0MNRYzXiMihlt7Sf44Hj/j9Q1NBEqSj4hOannG68WSriYzXiMimqM1rdYx2gqYR5GH95aE7XPrDpIkHxHd1GKfvKRTgJ2BG3m0LqyBJPmIiLq01V0D7GH72YMIlCGUEdFd7U2GulzSQJJ8nuQjorNafJI/jSLR/4Zi6KQA29657kCNJXlJTwf+FXgqRZ/TsnLdhoiI4dBekj8FOAK4gUf75BvR5JP8auBdtq+WtCmwQtLFtn/aYMyIiGrc2JIFVdxm+7xBBGqyMtSdwJ3l7w9KuoliyFCSfES0rs1x8sDNkr4CnE/PTNeRHUIpaRuKUoBXTPHZUmApwHwWDKI5EREFt5blN6ZI7i/tOTaaQyglPQE4B3i77QfW/tz2MmAZwEJt3urMhIjolhZnvDZStHsqjQ6hlLQBRYI/o4k/QyIi1lnV4ZMN/EMgabGkb0i6S9JvJZ0jaXH9kRpM8pIEfBG4yfYJTcWJiFhXLa4nfypwHkUZwK0o+uZPbSJQk0/ye1EMEdpH0rXl9rIG40VE9KXFJL/I9qm2V5fbl4BFTQRqcnTND2hoEfyIiDkzbb54vUfS4cCZ5f5hwO+aCJRlDSKis1qsDHUU8BrgNxRDzQ8tj9UuyxpERHe18CAvaR7wD7YPHkS8JPmI6KS2JkPZnpC0SNKGth9pOl6SfER0k91m0ZBfAj+UdB7wh0ebVP9IxCT5iOiu9qZf3lFu6wGbNhkoST4iOqvFGa/HDypWknxEdJOBAXfXSDqfGf5+aOJlbJJ8DLUL77juccf233KXKc/9/REveNyxJ3758trbFGNk8E/ynyp/HkJRa+P0cv8win762iXJR0Rn1dVdU7VIku3vl+d/zPbePR+dL+myelrzWEnyEdFZNY6u6bdI0iJJ29m+FUDStozasgYREUOtxhUm16FI0juASyXdWu5vQ1lXo25J8hHRScVkqMpZfgtJy3v2l5W1MB5/3RmKJE2yfYGk7YEdykM32354uvPnIkk+Irqr+gqT99heMttJsxVJ6jlvOUUx7zNt31e5FesgC5RFRGfJrrRVulZ/RZJeS9Gdc5WksyTtX9bgqF2SfER0U42VofotkmT7FtsfBP4G+ArFU/1tko6XtPm63M50mqwMdUpZ2uonTcWIiFh3xdo1VbYK+i6SJGln4ATgkxR/ARwKPAB8b2739VhN9sl/Cfg/FGNHIyKGT01FQ/otkiRpBXA/cDLwvp6XrldI2quWRpWarAx1WfmWOSJi+Lix0n5VHEExAmdb4H2T3fG2P2r7kDoDZXRNRHRXe+X/TqB4kr8aaGTo5KTWk7ykpZSTAOazoOXWRESntLfU8GLbBwwiUOuja2wvs73E9pIN2Kjt5kREh2jNmkpbA34k6TlNXHhtrT/JR0S0wvQzGaoWkm4oI68PHFkua/AwxUtb29657piNJXlJZwIvopgOvBI4zvYXm4oXEdEPUX2iU40OGnTAJkfXHNbUtSMiajHgJG/7VwMNSLprIqLL2htdMzBJ8hHRTS30ybchST4iOquhkTNDJUk+IjrK6a6JiBhbJkk+ImKsjX9vTZJ8RHRXC+PkB27sk/wtn9njccf++m0/ftyxNXvvNuX317vsmtrbFNXtv+Uulc994pcvb7AlMZaS5CMixpQNE+PfX5MkHxHdlSf5iIgxliQfETGmDFSr3zrSkuQjoqMMTp98RMR4MnnxGhEx1tInHxExxjqQ5But8SrpAEk/k3SLpGObjBUR0Z9ygbIq2whrsvzfPOCzwEuAlcBVks6z/dOmYkZEVGagA0sNN/kkvztwi+1bbT8CnAW8osF4ERH9yZP8nGwF/LpnfyXw/LVPkrQUWAownwUNNicioleWNZgrTXHscf8k2l4GLANYqM1H+5/MiBgdBmec/JysBJ7es78YuKPBeBER/enAjNcm++SvAraXtK2kDYHXAuc1GC8ioj/pk193tldLeitwITAPOMX2jU3Fi4joi92J0TWNToay/V3gu03GiIhYZyP+lF5FZrxGREcZT0y03YjGJclHRDdlqeGIiDHXgSGUja5dExExrAx4jSttVQzrWl1J8hHRTS6LhlTZZtGzVteBwLOBwyQ9u+E7qCTdNRHRWTW+eP3LWl0AkibX6mp9QUZ5iIYQSbob+BWwBXBPy81pwjje1zjeE+S+ht0zbC+aywUkXUDx36OK+cCfe/aXlUuyTF7rUOAA228q948Anm/7rXNpYx2G6kl+8n80ScttL2m7PXUbx/sax3uC3FcX2D6gxstVWqurDemTj4iYu6FdqytJPiJi7oZ2ra6h6q7psWz2U0bSON7XON4T5L6iD8O8VtdQvXiNiIh6pbsmImKMJclHRIyxoUvywzo1uF+STpF0l6Sf9BzbXNLFkn5e/tyszTb2S9LTJf27pJsk3SjpmPL4yN6XpPmSrpR0XXlPx5fHR/aeekmaJ+kaSd8u98fivqK6oUrywzw1eB18CVh7HO6xwCW2twcuKfdHyWrgXbZ3BPYA3lL+7zPK9/UwsI/tXYBdgQMk7cFo31OvY4CbevbH5b6ioqFK8vRMDbb9CDA5NXjk2L4MuHetw68ATit/Pw145SDbNFe277R9dfn7gxTJYytG+L5ceKjc3aDczAjf0yRJi4GXAyf3HB75+4r+DFuS3wr4dc/+yvLYuHiK7TuhSJjAk1tuzzqTtA2wG3AFI35fZZfGtcBdwMW2R/6eSp8G3gv0rrA1DvcVfRi2JD+0U4PjUZKeAJwDvN32A223Z65sT9jelWKW4u6Sdmq5SXMm6SDgLtsr2m5LtGvYkvzQTg2uyW8lPQ2g/HlXy+3pm6QNKBL8GbbPLQ+P/H0B2L4fuJTiXcqo39NewMGSfknR7bmPpNMZ/fuKPg1bkh/aqcE1OQ94ffn764FvtdiWvkkS8EXgJtsn9Hw0svclaZGkJ5W/bwzsB9zMCN8TgO33215sexuK/x99z/bhjPh9Rf+GbsarpJdR9CVOTg3+eLstWjeSzgReRLGU6W+B44BvAl8DtgZuA15te+2Xs0NL0guB/wBu4NF+3g9Q9MuP5H1J2pniBeQ8ioeer9n+qKS/YkTvaW2SXgS82/ZB43RfUc3QJfmIiKjPsHXXREREjZLkIyLGWJJ8RMQYS5KPiBhjSfIREWMsST5aIemh2c9q/5oRoy5JPiJijCXJR+skvUfSVZKu71nP/ROS/lfPOX8v6V3TnR8RU0uSj1ZJeimwPcUy07sCz5O0N8V6K/+t59TXAF+f4fyImML6bTcgOu+l5XZNuf8EYHvbX5T0ZElbAouA+2zfJultU50PXDbgdkeMhCT5aJuAf7R90hSfnQ0cCjyV4sl+tvMjYi3prom2XQgcVa5Rj6StJE0WsjiLYgXFQykS/mznR8Ra8iQfrbJ9kaQdgcuLlYx5CDicouDFjZI2BW7vqWY07fmt3EDEkMsqlBERYyzdNRERYyxJPiJijCXJR0SMsST5iIgxliQfETHGkuQjIsZYknxExBj7/2FSjqJ3woo9AAAAAElFTkSuQmCC\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], + "source": [ + "testfile['Reff'].sel(point=10).plot()" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "01b07acd-e4a3-4ee2-a45a-7813265d80ed", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
<xarray.DataArray 'hydro' (hydro: 9)>\n",
+       "array([0, 1, 2, 3, 4, 5, 6, 7, 8])\n",
+       "Dimensions without coordinates: hydro
" + ], + "text/plain": [ + "\n", + "array([0, 1, 2, 3, 4, 5, 6, 7, 8])\n", + "Dimensions without coordinates: hydro" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "testfile.hydro" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6be757aa-c224-48aa-9afa-193fa23634f7", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python [conda env:miniconda3-cheydask]", + "language": "python", + "name": "conda-env-miniconda3-cheydask-py" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.8" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/src/simulator/rttov/cosp_rttovSTUB.F90 b/src/simulator/rttov/cosp_rttovSTUB.F90 index a1b0945c24..c8a3a668e3 100644 --- a/src/simulator/rttov/cosp_rttovSTUB.F90 +++ b/src/simulator/rttov/cosp_rttovSTUB.F90 @@ -65,11 +65,6 @@ MODULE MOD_COSP_RTTOV ch4, & ! Methane n2o, & ! n2o co ! Carbon monoxide -! real(wp),dimension(:),pointer :: & -! surfem ! Surface emissivities for the channels -! refl, & ! Surface reflectances for the channels -! integer,dimension(:),pointer :: & -! channels ! Surface reflectances for the channels real(wp),dimension(:),pointer :: & h_surf, & ! Surface height u_surf, & ! U component of surface wind diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 40ac637928..d41c5ce0f2 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -107,9 +107,10 @@ module mod_cosp_rttov nChannels ! Number of channels integer(kind=jpim) :: & ! Parallelization is default off rttov_direct_nthreads = 1_jpim -! integer,dimension(nChannels) :: & integer(kind=jpim),allocatable :: & - iChannel(:) ! RTTOV channel numbers + iChannel(:), & ! RTTOV channel indices + emisChannel(:), & ! RTTOV channel emissivity + reflChannel(:) ! RTTOV channel reflectivity ! Scattering coefficients (read in once during initialization) type(rttov_coefs) :: & @@ -173,7 +174,7 @@ module mod_cosp_rttov nPoints, & ! Number of profiles to simulate nLevels, & ! Number of levels nSubCols, & ! Number of subcolumns - nChannels, & ! Number of channels to simulate + nChannels, & ! Number of channels to simulate ! JKS month ! Month (needed for surface emissivity calculation) real(wp),pointer :: & ! Could change the dimensionality of these in the future co2, & ! Carbon dioxide @@ -243,7 +244,7 @@ end subroutine rttov_error subroutine cosp_rttov_allocate(rttovIN & ) - type(rttov_in),intent(in) :: & ! What is the best way to do this? Should rttovIN be a module-wide DDT? Yes. + type(rttov_in),intent(in) :: & rttovIN ! Loop variables @@ -255,17 +256,7 @@ subroutine cosp_rttov_allocate(rttovIN & ! Largely from RTTOV documentation. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Determine the total number of radiances to simulate (nchanprof). - ! We aren't doing subcolumn sampling (RTTOV already does this and it would be slow) -! nchanprof = nchannels * nprof - - ! Allocate and fill in channel_list -! allocate(channel_list(rttovIN%nChannels)) -! channel_list(1:nChannels) = rttovIN%channels(1:nChannels) - -! print*,'rttovIN%channels: ',rttovIN%channels -! print*,'channel_list: ',channel_list - + ! Determine the total number of radiances to simulate (nchanprof). nchanprof = rttovIN%nChannels * rttovIN%nPoints ! Allocate structures for rttov_direct @@ -296,14 +287,13 @@ subroutine cosp_rttov_allocate(rttovIN & ! ------------------------------------------------------ ! Largely from RTTOV documentation. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - + nch = 0_jpim do j = 1, rttovIN%nPoints - do jch = 1, rttovIN%nChannels + do jch = 1, rttovIN%nChannels ! nChannels nch = nch + 1_jpim chanprof(nch)%prof = j chanprof(nch)%chan = iChannel(jch) ! Example code used channel_list -! chanprof(nch)%chan = rttovIN%channels(jch) ! Example code used channel_list end do end do @@ -333,12 +323,12 @@ subroutine cosp_rttov_construct_profiles(rttovIN & ! ozone_data, co2_data and so on in the options structure should be ! set to false." - print*,'co2: ',co2 - print*,'n2o: ',n2o - print*,'co: ',co - print*,'ch4: ',ch4 - print*,'so2: ',so2 - print*,'zenang: ',zenang +! print*,'co2: ',co2 +! print*,'n2o: ',n2o +! print*,'co: ',co +! print*,'ch4: ',ch4 +! print*,'so2: ',so2 +! print*,'zenang: ',zenang profiles(:)%gas_units = 1 ! kg/kg over moist air (default) @@ -584,7 +574,6 @@ subroutine cosp_rttov_save_and_deallocate_profiles(rttovIN, ! JKS - Need to allow options for Tb and radiance for clear- and cloudy-skies ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -! print *,"present check: ",present(four),present(five) ! Documentation for RTTOV radiance structure in RTTOV User Guide pg 166 diff --git a/src/simulator/rttov/cosp_rttov_v13_old.F90 b/src/simulator/rttov/cosp_rttov_v13_old.F90 new file mode 100644 index 0000000000..d52670ae01 --- /dev/null +++ b/src/simulator/rttov/cosp_rttov_v13_old.F90 @@ -0,0 +1,1319 @@ +! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +! Copyright (c) 2016, Regents of the University of Colorado +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are +! permitted provided that the following conditions are met: +! +! 1. Redistributions of source code must retain the above copyright notice, this list of +! conditions and the following disclaimer. +! +! 2. Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other +! materials provided with the distribution. +! +! 3. Neither the name of the copyright holder nor the names of its contributors may be +! used to endorse or promote products derived from this software without specific prior +! written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +! MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +! THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +! OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +! +! History +! March 2016 - M. Johnston - Original version +! April 2016 - D. Swales - Modified for use in COSPv2.0 +! JKS fill this in when working :) + +! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +module mod_cosp_rttov + use rttov_const, only : errorstatus_success, errorstatus_fatal, & + platform_name,inst_name +! Use RTTOV v13 types here, more may be needed + use rttov_types, only : rttov_options,rttov_coefs,rttov_profile, & + rttov_transmission,rttov_radiance,rttov_chanprof, & + rttov_emissivity,rttov_reflectance,rttov_opt_param +! use rttov_types, only : rttov_options,rttov_coefs,profile_type, & +! transmission_type,radiance_type,rttov_chanprof, & +! rttov_emissivity,profile_cloud_type,rttov_scatt_coef, & +! rttov_options_scatt + use rttov_const, only : surftype_sea, surftype_land, surftype_seaice, & + errorstatus_success,errorstatus_fatal, & + platform_name,inst_name, & + sensor_id_mw,sensor_id_po + use rttov_unix_env, only : rttov_exit + use cosp_kinds, only : wp + use mod_cosp_config, only : RTTOV_MAX_CHANNELS,N_HYDRO,rttovDir + use cosp_phys_constants, only : mdry=>amd,mO3=>amO3,mco2=>amCO2,mCH4=>amCH4, & + mn2o=>amN2O,mco=>amCO + + + ! The rttov_emis_atlas_data type must be imported separately + use mod_rttov_emis_atlas, ONLY : & + rttov_emis_atlas_data, & + atlas_type_ir, atlas_type_mw + + ! The rttov_brdf_atlas_data type must be imported separately + use mod_rttov_brdf_atlas, ONLY : rttov_brdf_atlas_data + + ! jpim, jprb and jplm are the RTTOV integer, real and logical KINDs + use parkind1, ONLY : jpim, jprb, jplm + + use rttov_unix_env, ONLY : rttov_exit + + implicit none + + +! Old includes +!#include "rttov_direct.interface" +!#include "rttov_alloc_prof.interface" +!#include "rttov_alloc_rad.interface" +!#include "rttov_alloc_transmission.interface" +!#include "rttov_dealloc_coefs.interface" +!#include "rttov_user_options_checkinput.interface" +!#include "rttov_read_coefs.interface" +!#include "rttov_get_emis.interface" +!#include "rttov_boundaryconditions.interface" + +! New includes for v13 (will need to clean up others) +#include "rttov_direct.interface" +#include "rttov_parallel_direct.interface" +#include "rttov_read_coefs.interface" +#include "rttov_dealloc_coefs.interface" +#include "rttov_alloc_direct.interface" +#include "rttov_init_emis_refl.interface" +#include "rttov_user_options_checkinput.interface" +#include "rttov_print_opts.interface" +#include "rttov_print_profile.interface" +#include "rttov_skipcommentline.interface" + +! Includes when directly inputting cloud optical parameters +#include "rttov_init_opt_param.interface" +#include "rttov_bpr_init.interface" +#include "rttov_bpr_calc.interface" +#include "rttov_bpr_dealloc.interface" +#include "rttov_legcoef_calc.interface" + + + ! Module parameters + integer, parameter :: maxlim = 10000 + real(wp),parameter :: eps = 0.622 + + ! Initialization parameters + integer :: & + platform, & ! RTTOV platform + sensor, & ! RTTOV instrument + satellite, & ! RTTOV satellite + nChannels ! Number of channels + integer,dimension(RTTOV_MAX_CHANNELS) :: & + iChannel ! RTTOV channel numbers + + ! Scattering coefficients (read in once during initialization) + type(rttov_coefs) :: & + coef_rttov +! JKS - KISS +! type(rttov_scatt_coef) :: & +! coef_scatt + ! RTTOV setup and options (set during initialization) + type(rttov_options) :: & + opts ! defaults to everything optional switched off + +! JKS - KISS +! type(rttov_options_scatt) :: & +! opts_scatt +contains + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE rttov_column + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine rttov_column(nPoints,nLevels,nSubCols,q,p,t,o3,ph,h_surf,u_surf,v_surf, & + p_surf,t_skin,t2m,q2m,lsmask,lon,lat,seaice,co2,ch4,n2o,co, & + zenang,lCleanup, & + ! Outputs + Tb,error, & + ! Optional arguments for surface emissivity calculation. + surfem,month, & +! coef_rttov, & ! JKS added coef_rttov + ! Optional arguments for all-sky calculation. + tca,ciw,clw,rain,snow) + ! Inputs + integer,intent(in) :: & + nPoints, & ! Number of gridpoints + nLevels, & ! Number of vertical levels + nSubCols ! Number of subcolumns + real(wp),intent(in) :: & + co2, & ! CO2 mixing ratio (kg/kg) + ch4, & ! CH4 mixing ratio (kg/kg) + n2o, & ! N2O mixing ratio (kg/kg) + co, & ! CO mixing ratio (kg/kg) + zenang ! Satellite zenith angle + real(wp),dimension(nPoints),intent(in) :: & + h_surf, & ! Surface height (m) + u_surf, & ! Surface u-wind (m/s) + v_surf, & ! Surface v-wind (m/s) + p_surf, & ! Surface pressure (Pa) + t_skin, & ! Skin temperature (K) + t2m, & ! 2-meter temperature (K) + q2m, & ! 2-meter specific humidity (kg/kg) + lsmask, & ! Land/sea mask + lon, & ! Longitude (deg) + lat, & ! Latitude (deg) + seaice ! Seaice fraction (0-1) + real(wp),dimension(nPoints,nLevels),intent(in) :: & + q, & ! Specific humidity (kg/kg) + p, & ! Pressure(Pa) + t, & ! Temperature (K) + o3 ! Ozone + real(wp),dimension(nPoints,nLevels+1),intent(in) :: & + ph ! Pressure @ half-levels (Pa) + logical,intent(in) :: & + lCleanup ! Flag to determine whether to deallocate RTTOV types + + ! Optional inputs (Needed for surface emissivity calculation) + integer,optional :: & + month ! Month (needed to determine table to load) + real(wp),dimension(nChannels),optional :: & + surfem ! Surface emissivity for each RTTOV channel + + ! JKS: Are these outputs + type(rttov_emis_atlas_data) :: emis_atlas ! Data structure for emissivity atlas + type(rttov_brdf_atlas_data) :: brdf_atlas ! Data structure for BRDF atlas + + ! Optional inputs (Needed for all-sky calculation) + real(wp),dimension(nPoints,nLevels),optional :: & + tca ! Total column cloud amount (0-1) + real(wp),dimension(nPoints,nSubCols,nLevels),optional :: & + ciw, & ! Cloud ice + clw, & ! Cloud liquid + rain, & ! Precipitation flux (kg/m2/s) + snow ! Precipitation flux (kg/m2/s) + + ! Outputs + real(wp),dimension(nPoints,nChannels) :: & + Tb ! RTTOV brightness temperature. + character(len=128) :: & + error ! Error messages (only populated if error encountered) + + ! Local variables + integer :: & + nloop,rmod,il,istart,istop,za,i,j,subcol,errorstatus,npts_it + integer,dimension(60) :: & + alloc_status + real(wp),dimension(nPoints) :: & + sh_surf + real(wp),dimension(nPoints,nLevels) :: & + sh,totalice + real(wp),dimension(nSubCols,nPoints,nChannels) :: & + Tbs ! Subcolumn brightness temperature + logical :: & + use_totalice, mmr_snowrain, cfrac + logical :: & + lallSky, & ! Control for type of brightness temperature calculation + ! (False(default) => clear-sky brightness temperature, True => All-sky) + lsfcEmis ! Control for surface emissivity calculation (true => compute surface emissivity, + ! provided that the field "month" is available) + + ! v13 local variables + integer(kind=jpim) :: atlas_type + +! Old includes (v11) +!#include "rttov_read_coefs.interface" +!#include "rttov_read_scattcoeffs.interface" +!#include "rttov_user_options_checkinput.interface" +!#include "rttov_dealloc_coefs.interface" +!#include "rttov_dealloc_scattcoeffs.interface" +!#include "rttov_setup_emis_atlas.interface" +!#include "rttov_deallocate_emis_atlas.interface" +!#include "rttov_print_opts.interface" +!#include "rttov_print_profile.interface" +!#include "rttov_boundaryconditions.interface" + +! New includes for v13 (will need to clean up others) +#include "rttov_direct.interface" +#include "rttov_parallel_direct.interface" +#include "rttov_read_coefs.interface" +#include "rttov_dealloc_coefs.interface" +#include "rttov_alloc_direct.interface" +#include "rttov_init_emis_refl.interface" +#include "rttov_user_options_checkinput.interface" +#include "rttov_print_opts.interface" +#include "rttov_print_profile.interface" +#include "rttov_skipcommentline.interface" + +! Includes when directly inputting cloud optical parameters +#include "rttov_init_opt_param.interface" +#include "rttov_bpr_init.interface" +#include "rttov_bpr_calc.interface" +#include "rttov_bpr_dealloc.interface" +#include "rttov_legcoef_calc.interface" + +! Use emissivity atlas +#include "rttov_setup_emis_atlas.interface" +#include "rttov_get_emis.interface" +#include "rttov_deallocate_emis_atlas.interface" + +! Use BRDF atlas +#include "rttov_setup_brdf_atlas.interface" +#include "rttov_get_brdf.interface" +#include "rttov_deallocate_brdf_atlas.interface" + + ! Initialize some things + totalice = 0._wp + Tbs(:,:,:) = 0._wp + Tb(:,:) = 0._wp + error = '' + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Setup for call to RTTOV + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! First, check to see if we are doing an all-sky or clear-sky calculation brightness + ! temperature + lallSky = .false. + if (present(tca) .and. present(clw) .and. present(ciw) .and. present(rain) & + .and. present(snow)) lallSky=.true. + + ! Check to see if we need to compute the surface emissivity (defualt is to compute + ! surface emissivity using the atlas tables) + lsfcEmis = .true. + if (present(surfem)) lsfcEmis = .false. + + ! We also need the month for the emissivity atlas, so check... + if (.not. present(month)) lsfcEmis = .false. + + if (lsfcEmis .eq. .false. .and. .not. present(surfem)) then + error = 'ERROR (rttov_column): User did not provide surface emissivity and did not '//& + 'request the surface emissivity to be calculated!!!' + return + endif + + ! Convert specific humidity to ppmv + sh = ( q / ( q + eps * ( 1._wp - q ) ) ) * 1e6 + sh_surf = ( q2m / ( q2m + eps * ( 1._wp - q2m ) ) ) * 1e6 + + ! Settings unique to all-sky call. + use_totalice = .false. + mmr_snowrain = .true. + cfrac = .true. +! opts_scatt%lusercfrac = cfrac ! This type is not in v13 + + ! RTTOV can handle only about 100 profiles at a time (fixme: check this with roger), + ! so we are putting a loop of 100 + nloop = npoints / maxlim + rmod = mod( npoints, maxlim ) + if( rmod .ne. 0 ) then + nloop = nloop + 1 + endif + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Initialize emissivity atlas data for chosen sensor. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + ! Old "rttov_setup_emis_atlas" subroutine call +! call rttov_setup_emis_atlas(errorstatus,opts,month,coef_rttov,path=trim(rttovDir)//"emis_data/") + + ! New v13 subroutine call from "example_atlas_fwd.F90" + if (coef_rttov%coef%id_sensor == sensor_id_mw .or. & + coef_rttov%coef%id_sensor == sensor_id_po) then + atlas_type = atlas_type_mw ! MW atlas + else + atlas_type = atlas_type_ir ! IR atlas + endif + call rttov_setup_emis_atlas( & + errorstatus, & + opts, & + month, & + atlas_type, & ! Selects MW (1) or IR (2) + emis_atlas, & + path = trim(rttovDir)//"emis_data/", & ! The default path to atlas data + coefs = coef_rttov) ! This is mandatory for the CNRM MW atlas, ignored by TELSEM2; + ! if supplied for IR atlases they are initialised for this sensor + ! and this makes the atlas much faster to access + + if (errorstatus /= errorstatus_success) then + error = 'ERROR (rttov_column): Error reading emis atlas data!' + return + endif + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Some quality control prior to RTTOV call + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! v11 quality control + ! Ensure the options and coefficients are consistent +! if(opts_scatt%config%do_checkinput) then +! call rttov_user_options_checkinput(errorstatus, opts, coef_rttov) +! if (errorstatus /= errorstatus_success) then +! error = 'ERROR (rttov_column): Error when checking input data!' +! return +! endif +! endif + + ! v13 quality control + ! Ensure the options and coefficients are consistent + call rttov_user_options_checkinput(errorstatus, opts, coef_rttov) + if (errorstatus /= errorstatus_success) then + write(*,*) 'error in rttov options' + error = 'ERROR (rttov_column): Error when checking input data!' + call rttov_exit(errorstatus) ! JKS not sure if this is the right way to exit in COSP + endif + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Call to RTTOV + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Looping over maxlim number of profiles + do il = 1, nloop + istart = (il - 1) * maxlim + 1 + istop = min(il * maxlim, npoints) + if( ( il .eq. nloop ) .and. ( rmod .ne. 0 ) ) then + npts_it = rmod + else + npts_it = maxlim + endif + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Clear-sky brightness temperature + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + if (.not. lallSky) then + call rttov_multprof(nChannels,iChannel,surfem,npts_it,nLevels,platform, & + satellite,sensor,opts,coef_rttov,zenang, & + p(istart:istop,:)/100._wp,t(istart:istop,:), & + sh(istart:istop,:),(mdry/mo3)*o3(istart:istop,:)*1e6, & + (mdry/mco2)*co2*1e6,(mdry/mch4)*ch4*1e6,(mdry/mn2o)*n2o*1e6,& + (mdry/mco)*co*1e6,h_surf(istart:istop),u_surf(istart:istop),& + v_surf(istart:istop),t_skin(istart:istop), & + p_surf(istart:istop)/100.,t2m(istart:istop), & + sh_surf(istart:istop),lsmask(istart:istop), & + seaice(istart:istop),lat(istart:istop),lon(istart:istop), & + Tb(istart:istop,:)) + endif + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! All-sky brightness temperature + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + if (lallSky) then + ! Loop over all subcolumns + do subcol = 1, nSubCols + ! Call RTTOV + call cosp_rttov_mwscatt(nChannels,iChannel,surfem,nPoints,nlevels,platform, & + satellite,sensor,opts,coef_rttov, & +! satellite,sensor,opts,opts_scatt,coef_rttov, & ! JKS - remove opts_scatt + coef_scatt,zenang,p(istart:istop,:)/100._wp, & + ph(istart:istop,:)/100._wp,t(istart:istop, :), & + sh(istart:istop, :), & + (mdry/mo3)*o3(istart:istop,:)*1e6, & + clw(istart:istop,subcol,:), & + ciw(istart:istop,subcol,:),tca(istart:istop, :), & + totalice(istart:istop,:),snow(istart:istop,subcol,:),& + rain(istart:istop,subcol,:),(mdry/mco2)*co2*1e6, & + (mdry/mch4)*ch4*1e6,(mdry/mn2o)*n2o*1e6, & + (mdry/mco)*co*1e6,h_surf(istart:istop), & + u_surf(istart:istop),v_surf(istart:istop), & + t_skin(istart:istop), p_surf(istart:istop)/100., & + t2m(istart:istop),sh_surf(istart:istop), & + lsmask(istart:istop),seaice(istart:istop), & + lat(istart:istop),lon(istart:istop), use_totalice, & + mmr_snowrain,cfrac,Tbs(subcol,istart:istop,:)) + enddo + endif + enddo + + ! For all-sky calculation we need to average together all of the cloudy subcolumns. + if (lallSky) then + do subcol = 1, nSubCols + Tb = Tb + tbs(subcol,:,:) + enddo + Tb = Tb/nSubCols + endif + + ! Free up space + if (lCleanup) then + call rttov_dealloc_coefs(errorstatus,coef_rttov) + call rttov_deallocate_emis_atlas(coef_rttov) + if (lallSky) call rttov_dealloc_scattcoeffs(coef_scatt) + endif + end subroutine rttov_column + + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE rttov_simulate - JKS + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine rttov_simulate(nPoints,nLevels,nSubCols,q,p,t,o3,ph,h_surf,u_surf,v_surf, & + p_surf,t_skin,t2m,q2m,lsmask,lon,lat,seaice,co2,ch4,n2o,co, & + zenang,lCleanup, & + ! Outputs + Tb,error, & + ! Optional arguments for surface emissivity calculation. + surfem,month, & +! coef_rttov, & ! JKS added coef_rttov + ! Optional arguments for all-sky calculation. + tca,ciw,clw,rain,snow) + + + ! Inputs + integer,intent(in) :: & + nPoints, & ! Number of gridpoints + nLevels, & ! Number of vertical levels + nSubCols ! Number of subcolumns + real(wp),intent(in) :: & + co2, & ! CO2 mixing ratio (kg/kg) + ch4, & ! CH4 mixing ratio (kg/kg) + n2o, & ! N2O mixing ratio (kg/kg) + co, & ! CO mixing ratio (kg/kg) + zenang ! Satellite zenith angle + real(wp),dimension(nPoints),intent(in) :: & + h_surf, & ! Surface height (m) + u_surf, & ! Surface u-wind (m/s) + v_surf, & ! Surface v-wind (m/s) + p_surf, & ! Surface pressure (Pa) + t_skin, & ! Skin temperature (K) + t2m, & ! 2-meter temperature (K) + q2m, & ! 2-meter specific humidity (kg/kg) + lsmask, & ! Land/sea mask + lon, & ! Longitude (deg) + lat, & ! Latitude (deg) + seaice ! Seaice fraction (0-1) + real(wp),dimension(nPoints,nLevels),intent(in) :: & + q, & ! Specific humidity (kg/kg) + p, & ! Pressure(Pa) + t, & ! Temperature (K) + o3 ! Ozone + real(wp),dimension(nPoints,nLevels+1),intent(in) :: & + ph ! Pressure @ half-levels (Pa) + logical,intent(in) :: & + lCleanup ! Flag to determine whether to deallocate RTTOV types + + ! Cloud fields + real(wp),dimension(nPoints,nLevels),intent(in) :: & + tca ! Total column cloud amount (0-1) + real(wp),dimension(nPoints,nSubCols,nLevels),intent(in) :: & + ciw, & ! Cloud ice + clw, & ! Cloud liquid + rain, & ! Precipitation flux (kg/m2/s) + snow ! Precipitation flux (kg/m2/s) + + ! Optional inputs (Needed for surface emissivity calculation) + integer,optional :: & + month ! Month (needed to determine table to load) + real(wp),dimension(nChannels),optional :: & + surfem ! Surface emissivity for each RTTOV channel + + ! Optional inputs (Needed for all-sky calculation) +! real(wp),dimension(nPoints,nLevels),optional :: & +! tca ! Total column cloud amount (0-1) +! real(wp),dimension(nPoints,nSubCols,nLevels),optional :: & +! ciw, & ! Cloud ice +! clw, & ! Cloud liquid +! rain, & ! Precipitation flux (kg/m2/s) +! snow ! Precipitation flux (kg/m2/s) + + ! Outputs + real(wp),dimension(nPoints,nChannels) :: & + Tb ! RTTOV brightness temperature. + character(len=128) :: & + error ! Error messages (only populated if error encountered) + + ! Initialize some things + Tb(:,:) = 0._wp + error = '' + +! Current inputs: rttovIN,cospOUT%rttov_tbs(ij:ik,:),cosp_simulator(nError+1) + +! JKS new function end + end subroutine rttov_simulate + + + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE rttov_multprof + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine rttov_multprof( & + nch_in, & ! number of channels + ichan_in, & ! channel indices + surfem_in, & ! surface emissivity values + prf_num_in, & ! number of profiles to simulate + nlevels_in, & ! number of pressure levels + plat_in, & ! platform number + sat_in, & ! satellite number + sens_in, & ! instrument number + opts, & + coef_rttov, & + zenang_in, & ! zenith angle + p_in, & ! pressure [hpa] + t_in, & ! temperature [ k ] + q_in, & ! specific humidity [ ppmv ] + o3_in, & ! ozone vmr [ ppmv ] + co2_in, & ! co2 vmr [ ppmv ] *this is a single value* + ch4_in, & ! ch4 vmr [ ppmv ] *this is a single value* + n2o_in, & ! n2o vmr [ ppmv ] *this is a single value* + co_in, & ! co vmr [ ppmv ] *this is a single value* + h_surf, & ! surface height [ m ] + u_surf, & ! u wind at 10 m [ m/s ] + v_surf, & ! v wind at 10 m [ m/s ] + t_skin, & ! skin temperatre [ k ] + p_surf, & ! surface pressure + t_surf, & ! 1.5 m temperature [ k ] + q_surf, & ! 1.5 m specific humidity [ ppmv ] + lsmask, & ! land sea mask + seaice, & ! seaice fraction + latitude, & ! latitude [ deg north ] + longitude, & ! longitude [ deg east ] + tbs & ! brightness temperature [ k ] (output) + ) + + !------ input arguments. no rttov kinds should be used here ----------------- + integer, intent(in) :: nch_in ! number of channels to be computed + integer, intent(in) :: ichan_in(nch_in) ! indices of selected channels + real(wp), intent(in) :: surfem_in(nch_in) ! surface emissivities for the channels + integer, intent(in) :: prf_num_in + integer, intent(in) :: nlevels_in + integer, intent(in) :: plat_in ! satellite platform + integer, intent(in) :: sat_in ! satellite number + integer, intent(in) :: sens_in ! satellite sensor + real(wp), intent(in) :: zenang_in ! satellite zenith angle + + type(rttov_options) :: opts + type(rttov_coefs) :: coef_rttov + + real(wp), intent(in) :: p_in(prf_num_in, nlevels_in) ! pressure profiles + real(wp), intent(in) :: t_in(prf_num_in, nlevels_in) ! temperature profiles + real(wp), intent(in) :: q_in(prf_num_in, nlevels_in) ! humidity profiles + real(wp), intent(in) :: o3_in(prf_num_in, nlevels_in) ! ozone profiles + + ! the following trace gases contain constant values + real(wp), intent(in) :: co2_in ! carbon dioxide + real(wp), intent(in) :: ch4_in ! methane + real(wp), intent(in) :: n2o_in ! n2o + real(wp), intent(in) :: co_in ! carbon monoxide + real(wp), intent(in) :: h_surf(prf_num_in) ! surface height + real(wp), intent(in) :: u_surf(prf_num_in) ! u component of surface wind + real(wp), intent(in) :: v_surf(prf_num_in) ! v component of surface wind + real(wp), intent(in) :: t_skin(prf_num_in) ! surface skin temperature + real(wp), intent(in) :: p_surf(prf_num_in) ! surface pressure + real(wp), intent(in) :: t_surf(prf_num_in) ! 1.5 m temperature + real(wp), intent(in) :: q_surf(prf_num_in) ! 1.5 m specific humidity + real(wp), intent(in) :: lsmask(prf_num_in) ! land-sea mask + real(wp), intent(in) :: seaice(prf_num_in) ! sea-ice fraction + real(wp), intent(in) :: latitude(prf_num_in) ! latitude + real(wp), intent(in) :: longitude(prf_num_in) ! longitude + + real(wp), intent(inout) :: tbs(prf_num_in, nch_in) ! tbs (in the right format) + + !------ local variables. use only rttov kinds or derived types. + ! logical variables are declared with the same kind + ! as integers, as they are affected inthe same way by flags like -qintsize=8 + + ! type(rttov_options) :: opts ! options structure + ! type(rttov_coefs), allocatable :: coefs(:) ! coefficients structure + type(rttov_chanprof), allocatable :: chanprof(:) ! input channel/profile list + +! JKS this type doesn't exist in RTTOV v13 - KISS +! type(profile_type), allocatable :: profiles(:) ! input profiles + type(rttov_profile), allocatable :: profiles(:) ! input profiles (v13, JKS) + logical, allocatable :: calcemis(:) ! flag to indicate calculation of emissivity within rttov + type(rttov_emissivity), allocatable :: emissivity(:) ! input/output surface emissivity + +! JKS these types do not exist in RTTOV v13 - KISS +! type(transmission_type) :: transmission ! output transmittances +! type(radiance_type) :: radiance ! output radiances + type(rttov_transmission) :: transmission ! output transmittances (v13, JKS) + type(rttov_radiance) :: radiance ! output radiances (v13, JKS) + + integer, allocatable :: instrument(:,:) ! instrument id (3 x n_instruments) + integer, allocatable :: nchan(:) ! number of channels per instrument + integer, allocatable :: ichan(:,:) ! channel list per instrument + + integer :: asw + integer :: mxchn + integer :: nrttovid ! maximum number of instruments + integer :: no_id ! instrument loop index + integer :: i, j, jch + integer :: nprof ! number of calls to rttov + integer :: nch ! intermediate variable + integer :: errorstatus + integer :: ich, ich_temp, nchanprof, nchannels, chan + integer :: alloc_status(60) + + real(wp), allocatable :: input_emissivity (:) + + character (len=14) :: nameofroutine = 'rttov_multprof' + + logical :: refrac, solrad, laerosl, lclouds, lsun, all_channels + + ! local variables for input arguments that need type casting to avoid type-mismatch with + ! rttov kinds. this happens with some compiler flags (-qintsize=8). + integer :: prof_num + integer :: nlevels + + ! -------------------------------------------------------------------------- + ! 0. initialise cosp-specific things + ! -------------------------------------------------------------------------- + + ! type-casting of input arguments that need to be passed to rttov + prof_num = prf_num_in + nlevels = nlevels_in + nprof = prof_num + + ! currently we plan to calculate only 1 instrument per call + nrttovid = 1 + mxchn = nch_in + + errorstatus = 0 + alloc_status(:) = 0 + + ! allocate(coefs(nrttovid), stat = alloc_status(1)) + + ! allocate(instrument(3, nrttovid), stat = alloc_status(4)) + + !maximum number of channels allowed for one instrument is mxchn + ! allocate(surfem(nch_in, nrttovid), stat = alloc_status(11)) + allocate(ichan(nch_in, nrttovid), stat = alloc_status(12)) + call rttov_error('ichan mem allocation error for profile array' , lalloc = .true.) + + + do no_id = 1, nrttovid + ichan(:, no_id) = ichan_in + enddo + + asw = 1 ! switch for allocation passed into rttov subroutines + + ! allocate input profile arrays + allocate(profiles(nprof), stat = alloc_status(1)) + call rttov_error('Profile mem allocation error' , lalloc = .true.) + + call rttov_alloc_prof( & + errorstatus, & + nprof, & + profiles, & + nlevels, & + opts, & + asw, & + coefs = coef_rttov, & + init = .true.) + call rttov_error('Profile 2 mem allocation error' , lalloc = .true.) + ! -------------------------------------------------------------------------- + ! 5. store profile data in profile type + ! -------------------------------------------------------------------------- + do i = 1, nprof + profiles(i)%p(:) = p_in(i, :) + profiles(i)%t(:) = t_in(i, :) + profiles(i)%q(:) = q_in(i, :) + + where(profiles(i)%q(:) < 1e-4) + profiles(i)%q(:) = 1e-4 + end where + + profiles(i)%cfraction = 0. + profiles(i)%ctp = 500. + + ! 2m parameters + profiles(i)%s2m%p = p_surf(i) + profiles(i)%s2m%t = t_surf(i) + profiles(i)%s2m%q = q_surf(i) + profiles(i)%s2m%u = u_surf(i) ! dar: hard-coded at 2ms-1? + profiles(i)%s2m%v = v_surf(i) ! dar: hard-coded at 2ms-1? + profiles(i)%s2m%wfetc = 10000. ! dar: default? + + ! skin variables for emissivity calculations + profiles(i)%skin%t = t_skin(i) + + ! fastem coefficients - for mw calculations + profiles(i)%skin%fastem(1) = 3.0 + profiles(i)%skin%fastem(2) = 5.0 + profiles(i)%skin%fastem(3) = 15.0 + profiles(i)%skin%fastem(4) = 0.1 + profiles(i)%skin%fastem(5) = 0.3 + + profiles(i)%zenangle = zenang_in ! pass in from cosp + + profiles(i)%azangle = 0. ! hard-coded in rttov9 int + + profiles(i)%latitude = latitude(i) + profiles(i)%longitude = longitude(i) + profiles(i)%elevation = h_surf(i) + + profiles(i)%sunzenangle = 0. ! hard-coded in rttov9 int + profiles(i)%sunazangle = 0. ! hard-coded in rttov9 int + + ! surface type + ! land-sea mask indicates proportion of land in grid + if (lsmask(i) < 0.5) then + profiles(i)%skin%surftype = surftype_sea + else + profiles(i)%skin%surftype = surftype_land + endif + ! sea-ice fraction + if (seaice(i) >= 0.5) then + profiles(i)%skin%surftype = surftype_seaice + endif + + ! dar: hard-coded to 1 (=ocean water) in rttov 9 int + profiles(i)%skin%watertype = 1 + profiles(i) %idg = 0. + profiles(i) %ish = 0. + enddo + ! end of 5. + + ich_temp = 1 + nchannels = nch_in + do no_id = 1, nrttovid + + ! -------------------------------------------------------------------------- + ! 3. build the list of profile/channel indices in chanprof + ! -------------------------------------------------------------------------- + + allocate(nchan(nprof)) ! number of channels per profile + nchan(:) = size(ichan(:,no_id)) ! = nch_in + + ! size of chanprof array is total number of channels over all profiles + ! square in this case - here same channels done for all profiles + nchanprof = sum(nchan(:)) + + ! pack channels and input emissivity arrays + allocate(chanprof(nchanprof)) + ! allocate(emis(nchanprof)) + chanprof(:)%chan =0 + + nch = 0 + do j = 1, nprof + do jch = 1, nchan(j) + nch = nch + 1 + chanprof(nch)%prof = j + if(ichan(jch, no_id) < 1) then + errorstatus = errorstatus_fatal + call rttov_error('Sensor channel number must be 1 or greater' , lalloc = .true.) + else + chanprof(nch)%chan = ichan(jch, no_id) + endif + enddo + enddo + ! end of 3. + + ! allocate output radiance arrays + call rttov_alloc_rad( & + errorstatus, & + nchanprof, & + radiance, & + nlevels - 1, & ! nlayers + asw) + call rttov_error('allocation error for radiance arrays' , lalloc = .true.) + + ! allocate transmittance structure + call rttov_alloc_transmission( & + errorstatus, & + transmission, & + nlevels - 1, & + nchanprof, & + asw, & + init=.true.) + call rttov_error('allocation error for transmission arrays' , lalloc = .true.) + + ! allocate arrays for surface emissivity + allocate(calcemis(nchanprof), stat=alloc_status(1)) + allocate(emissivity(nchanprof), stat=alloc_status(2)) + call rttov_error('mem allocation error for emissivity arrays' , lalloc = .true.) + + call rttov_get_emis( & + & errorstatus, & + & opts, & + & chanprof, & + & profiles, & + & coef_rttov, & + !& resolution=resolution, & ! *** MW atlas native + ! resolution is 0.25 degree lat/lon; if you know better + ! value for satellite footprint (larger than this) then + ! you can specify it here + & emissivity=emissivity(:)%emis_in) + ! & emissivity(:)%emis_in) + + call rttov_error('Get emissivity error' , lalloc = .true.) + calcemis(:) = .false. + ! calculate emissivity for missing and ocean location (fastem) + where (emissivity(:)%emis_in <= 0.0) + calcemis(:) = .true. + endwhere + + call rttov_direct( & + errorstatus, &! out + chanprof, & + opts, & + profiles, &! in + coef_rttov, &! in + transmission, &! out + radiance, & + calcemis = calcemis, &! in + emissivity = emissivity) ! inout + call rttov_error('rttov_direct error', lalloc = .true.) + + tbs(1:prof_num , ich_temp:ich_temp + size(ichan(:,no_id)) - 1) = & + transpose(reshape(radiance%bt(1:nchanprof), (/ size(ichan(:,no_id)), prof_num/) )) + + ich_temp = ich_temp + size(ichan(:,no_id)) + + ! -------------------------------------------------------------------------- + ! 8. deallocate all rttov arrays and structures + ! -------------------------------------------------------------------------- + deallocate (nchan, stat=alloc_status(3)) + deallocate (chanprof, stat=alloc_status(4)) + deallocate (emissivity, stat=alloc_status(5)) + deallocate (calcemis, stat=alloc_status(6)) + call rttov_error('rttov array deallocation error', lalloc = .true.) + + asw = 0 ! switch for deallocation passed into rttov subroutines + + ! deallocate radiance arrays + call rttov_alloc_rad(errorstatus, nchannels, radiance, nlevels - 1, asw) + call rttov_error('radiance deallocation error', lalloc = .true.) + + ! deallocate transmission arrays + call rttov_alloc_transmission(errorstatus, transmission, nlevels - 1, nchannels, asw) + call rttov_error('transmission deallocation error', lalloc = .true.) + + enddo + + ! deallocate profile arrays + call rttov_alloc_prof(errorstatus, nprof, profiles, nlevels, opts, asw) + call rttov_error('profile deallocation error', lalloc = .true.) + + deallocate(profiles, stat=alloc_status(1)) + call rttov_error('mem deallocation error for profile array', lalloc= .true.) + + contains + + subroutine rttov_error(msg, lalloc) + character(*) :: msg + logical :: lalloc + + if(lalloc) then + if (any(alloc_status /= 0)) then + write(*,*) msg + errorstatus = 1 + call rttov_exit(errorstatus) + endif + else + if (errorstatus /= errorstatus_success) then + write(*,*) msg + call rttov_exit(errorstatus) + endif + endif + end subroutine rttov_error + + end subroutine rttov_multprof + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + !----------------- subroutine cosp_rttov_mwscatt --------------- + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + subroutine cosp_rttov_mwscatt(& + nch_in, & ! number of channels + ichan_in, & ! channel indices + surfem_in, & ! surface emissivity values + prf_num_in, & ! number of profiles to simulate + nlevels_in, & ! number of pressure levels + plat_in, & ! platform number + sat_in, & ! satellite number + sens_in, & ! instrument number + opts, & +! opts_scatt, & + coef_rttov, & + coef_scatt, & + zenang_in, & ! zenith angle + p_in, & ! pressure [hpa] + ph_in, & ! pressure on half levels [hpa] + t_in, & ! temperature [ k ] + q_in, & ! specific humidity [ ppmv ] + o3_in, & ! ozone vmr [ ppmv ] + clw_in, & ! cloud water [0-1] + ciw_in, & ! cloud ice [0-1] + cc_in, & ! effective cloud fraction [0-1] + totalice_in,& ! total ice, except snow [kg/kg] or [kg/m2/s] + sp_in, & ! solid precip with snow [kg/kg] or [kg/m2/s] + rain_in, & ! total liquid water [kg/kg] or [kg/m2/s] + co2_in, & ! co2 vmr [ ppmv ] *this is a single value* + ch4_in, & ! ch4 vmr [ ppmv ] *this is a single value* + n2o_in, & ! n2o vmr [ ppmv ] *this is a single value* + co_in, & ! co vmr [ ppmv ] *this is a single value* + h_surf, & ! surface height [ m ] + u_surf, & ! u wind at 10 m [ m/s ] + v_surf, & ! v wind at 10 m [ m/s ] + t_skin, & ! skin temperatre [ k ] + p_surf, & ! surface pressure + t_surf, & ! 1.5 m temperature [ k ] + q_surf, & ! 1.5 m specific humidity [ ppmv ] + lsmask, & ! land sea mask + seaice, & ! seaice fraction + latitude, & ! latitude [ deg north ] + longitude, & ! longitude [ deg east ] + use_totalice,& ! separate ice and snow, or total ice hydrometeor types + mmr_snowrain,& ! set units for snow and rain: if true units are kg/kg (the default) + cfrac, & ! opts_scatt%lusercfrac=true., supply the effective cloud fraction + tbs & ! brightness temperature [ k ] (output) + ) + + + + + + implicit none + + !------ input arguments. no rttov kinds should be used here ----------------- + integer, intent(in) :: nch_in ! number of channels to be computed + integer, intent(in) :: ichan_in(nch_in) ! indices of selected channels + real(wp), intent(in) :: surfem_in(nch_in) ! surface emissivities for the channels + integer, intent(in) :: prf_num_in + integer, intent(in) :: nlevels_in + integer, intent(in) :: plat_in ! satellite platform + integer, intent(in) :: sat_in ! satellite number + integer, intent(in) :: sens_in ! satellite sensor + real(wp), intent(in) :: zenang_in ! satellite zenith angle + + type(rttov_options) :: opts +! type(rttov_options_scatt) :: opts_scatt ! not in v13 JKS - KISS + type(rttov_coefs) :: coef_rttov +! type(rttov_scatt_coef) :: coef_scatt ! not in v13 JKS - KISS + + real(wp), intent(in) :: p_in(prf_num_in, nlevels_in) ! pressure profiles + real(wp), intent(in) :: t_in(prf_num_in, nlevels_in) ! temperature profiles + real(wp), intent(in) :: q_in(prf_num_in, nlevels_in) ! humidity profiles + real(wp), intent(in) :: o3_in(prf_num_in, nlevels_in) ! ozone profiles + real(wp), intent(in) :: clw_in(prf_num_in, nlevels_in) + real(wp), intent(in) :: ciw_in(prf_num_in, nlevels_in) + real(wp), intent(in) :: cc_in(prf_num_in, nlevels_in) + real(wp), intent(in) :: totalice_in(prf_num_in, nlevels_in) + real(wp), intent(in) :: sp_in(prf_num_in, nlevels_in) + real(wp), intent(in) :: rain_in(prf_num_in, nlevels_in) + real(wp), intent(in) :: ph_in(prf_num_in, nlevels_in+1) + + ! the following trace gases contain constant values + real(wp), intent(in) :: co2_in ! carbon dioxide + real(wp), intent(in) :: ch4_in ! methane + real(wp), intent(in) :: n2o_in ! n2o + real(wp), intent(in) :: co_in ! carbon monoxide + real(wp), intent(in) :: h_surf(prf_num_in) ! surface height + real(wp), intent(in) :: u_surf(prf_num_in) ! u component of surface wind + real(wp), intent(in) :: v_surf(prf_num_in) ! v component of surface wind + real(wp), intent(in) :: t_skin(prf_num_in) ! surface skin temperature + real(wp), intent(in) :: p_surf(prf_num_in) ! surface pressure + real(wp), intent(in) :: t_surf(prf_num_in) ! 1.5 m temperature + real(wp), intent(in) :: q_surf(prf_num_in) ! 1.5 m specific humidity + real(wp), intent(in) :: lsmask(prf_num_in) ! land-sea mask + real(wp), intent(in) :: seaice(prf_num_in) ! seaice fraction + real(wp), intent(in) :: latitude(prf_num_in) ! latitude + real(wp), intent(in) :: longitude(prf_num_in) ! longitude + logical, intent(in) :: cfrac, use_totalice, mmr_snowrain + + real(wp), intent(inout) :: tbs(prf_num_in, nch_in) ! tbs (in the right format) + !****************** local variables ********************************************** + logical , allocatable :: calcemis (:) + type(rttov_emissivity) , allocatable :: emissivity (:) + integer , allocatable :: frequencies (:) + type(rttov_chanprof) , allocatable :: chanprof (:) ! channel and profile indices + type(rttov_profile) , allocatable :: profiles (:) +! type(profile_type) , allocatable :: profiles (:) ! JKS - this type is not in v13 +! type(profile_cloud_type) , allocatable :: cld_profiles(:) ! JKS - KISS, v13 cloud types unclear + + integer, allocatable :: ichan(:,:) ! channel list per instrument + + integer :: errorstatus +! type (radiance_type) :: radiance ! JKS - this type is not in v13 + type (rttov_radiance) :: radiance ! JKS + ! type (rttov_options) :: opts ! defaults to everything optional switched off + ! type (rttov_options_scatt) :: opts_scatt + ! type (rttov_coefs) :: coef_rttov + ! type (rttov_scatt_coef) :: coef_scatt + + ! integer, allocatable :: instrument (:,:) + integer :: j,k,asw + integer :: nchanxnprof, ninstruments + real(wp) :: zenangle + character (len=256) :: outstring + integer :: alloc_status(60) + +#include "rttov_init_rad.interface" +#include "rttov_scatt_setupindex.interface" +#include "rttov_scatt.interface" +#include "rttov_alloc_rad.interface" +#include "rttov_alloc_prof.interface" +#include "rttov_alloc_scatt_prof.interface" +#include "rttov_get_emis.interface" +#include "rttov_boundaryconditions.interface" + + errorstatus = 0 + alloc_status(:) = 0 + ninstruments = 1 ! number of sensors or platforms + + allocate(ichan(nch_in, ninstruments), stat = alloc_status(3)) + + do j = 1, ninstruments + ichan(:, j) = ichan_in + enddo + + nchanxnprof = prf_num_in * nch_in ! total channels to simulate * profiles + + allocate (chanprof(nchanxnprof)) + allocate (frequencies(nchanxnprof)) + allocate (emissivity(nchanxnprof)) + allocate (calcemis(nchanxnprof)) + allocate (profiles(prf_num_in)) + allocate (cld_profiles(prf_num_in)) + + ! request rttov / fastem to calculate surface emissivity + calcemis = .true. + emissivity % emis_in = 0.0 + + ! setup indices + call rttov_scatt_setupindex ( & + & prf_num_in, & ! in + & nch_in, & ! in + & coef_rttov%coef, & ! in + & nchanxnprof, & ! in + & chanprof, & ! out + & frequencies) ! out + + ! allocate profiles (input) and radiance (output) structures + asw = 1 + call rttov_alloc_prof( errorstatus,prf_num_in,profiles,nlevels_in,opts,asw, init = .true.) + call rttov_alloc_scatt_prof(prf_num_in,cld_profiles, nlevels_in, .false., 1, init = .true.) + call rttov_alloc_rad(errorstatus,nchanxnprof,radiance,nlevels_in-1,asw) + + ! fill the profile structures with data + do j = 1, prf_num_in + profiles(j)%latitude = latitude(j) + profiles(j)%longitude = longitude(j) + profiles(j)%elevation = h_surf(j) + profiles(j)%sunzenangle = 0.0 ! hard-coded in rttov9 int + profiles(j)%sunazangle = 0.0 ! hard-coded in rttov9 int + profiles(j)%azangle = 0.0 + profiles(j)%zenangle = zenang_in + profiles(j)%s2m%t = t_surf(j) + profiles(j)%s2m%q = q_surf(j) + profiles(j)%s2m%u = u_surf(j) + profiles(j)%s2m%v = v_surf(j) + profiles(j)%s2m%wfetc = 10000. + profiles(j)%skin%t = t_skin(j) + profiles(j)%skin%watertype = 1 ! ocean water + if (lsmask(j) < 0.5) then + profiles(j)%skin%surftype = surftype_sea + else + profiles(j)%skin%surftype = surftype_land + endif + if (seaice(j) >= 0.5) then + profiles(j)%skin%surftype = surftype_seaice + endif + profiles(j)%skin%fastem(1) = 3.0 + profiles(j)%skin%fastem(2) = 5.0 + profiles(j)%skin%fastem(3) = 15.0 + profiles(j)%skin%fastem(4) = 0.1 + profiles(j)%skin%fastem(5) = 0.3 + profiles(j)%cfraction = 0.0 + profiles(j)%ctp = 500.0 ! not used but still required by rttov + profiles(j)%p(:) = p_in(j,:) + profiles(j)%t(:) = t_in(j,:) + profiles(j)%q(:) = q_in(j,:) + profiles(j)%idg = 0. + profiles(j)%ish = 0. + where(profiles(j)%q(:) < 1e-4) + profiles(j)%q(:) = 1e-4 + end where + cld_profiles(j)%ph(:) = ph_in(j,:) + cld_profiles(j)%cc(:) = cc_in(j,:) + cld_profiles(j)%clw(:) = clw_in(j,:) + cld_profiles(j)%ciw(:) = ciw_in(j,:) + cld_profiles(j)%rain(:) = rain_in(j,:) + cld_profiles(j)%sp(:) = sp_in(j,:) + profiles(j)%s2m%p = cld_profiles(j)%ph(nlevels_in+1) + enddo + + call rttov_get_emis( & + & errorstatus, & + & opts, & + & chanprof, & + & profiles, & + & coef_rttov, & + ! & resolution=resolution, & ! *** MW atlas native resolution is + ! 0.25 degree lat/lon; if you know better value for satellite + ! footprint (larger than this) then you can specify it here + & emissivity=emissivity(:)%emis_in) + if (errorstatus /= errorstatus_success) then + write(*,*) 'In COSP_RTTOV11: Error RTTOV_GET_EMIS!' + call rttov_exit(errorstatus) + endif + + calcemis(:) = .false. + where (emissivity(:)%emis_in <= 0.) + calcemis(:) = .true. + endwhere + +! OLD: Call RTTOV forward model +! call rttov_scatt (& +! & errorstatus, &! out +! & opts_scatt, &! in +! & nlevels_in, &! in +! & chanprof, &! in +! & frequencies, &! in +! & profiles, &! in +! & cld_profiles, &! in +! & coef_rttov, &! in +! & coef_scatt, &! in +! & calcemis, &! in +! & emissivity, &! in +! & radiance) ! out + +! if (errorstatus /= errorstatus_success) then +! write(*,*) 'In COSP_RTTOV11: Error RTTOV_SCATT!' +! call rttov_exit(errorstatus) +! endif +! END Old RTTOV Call + +! New rttov_direct Call (from example_aer_file_fwd) + if (nthreads <= 1) then + call rttov_direct( & + errorstatus, &! out error flag + chanprof, &! in channel and profile index structure + opts, &! in options structure + profiles, &! in profile array + coef_rttov, &! in coefficients structure + transmission, &! inout computed transmittances + radiance, &! inout computed radiances + calcemis = calcemis, &! in flag for internal emissivity calcs + emissivity = emissivity, &! inout input/output emissivities per channel + calcrefl = calcrefl, &! in flag for internal BRDF calcs + reflectance = reflectance) ! inout input/output BRDFs per channel + else + call rttov_parallel_direct( & + errorstatus, &! out error flag + chanprof, &! in channel and profile index structure + opts, &! in options structure + profiles, &! in profile array + coef_rttov, &! in coefficients structure + transmission, &! inout computed transmittances + radiance, &! inout computed radiances + calcemis = calcemis, &! in flag for internal emissivity calcs + emissivity = emissivity, &! inout input/output emissivities per channel + calcrefl = calcrefl, &! in flag for internal BRDF calcs + reflectance = reflectance,&! inout input/output BRDFs per channel + nthreads = nthreads) ! in number of threads to use + endif + + if (errorstatus /= errorstatus_success) then + write (*,*) 'rttov_direct error' + call rttov_exit(errorstatus) + endif +! END New RTTOV Call + + + !write(*,*) 'Checking emissivities: ', maxval(emissivity(:)%emis_out), \ + ! minval(emissivity(:)%emis_out) + tbs(1:prf_num_in,1:1+size(ichan(:,1))-1) = & + transpose(reshape(radiance%bt(1:nchanxnprof),(/ size(ichan(:,1)),prf_num_in/) )) + + ! deallocate all storage + asw = 0 + ! call rttov_dealloc_coefs(errorstatus,coef_rttov) + ! call rttov_dealloc_scattcoeffs(coef_scatt) + call rttov_alloc_prof(errorstatus,prf_num_in,profiles,nlevels_in,opts,asw) + call rttov_alloc_scatt_prof(prf_num_in,cld_profiles,nlevels_in,.false.,asw) + call rttov_alloc_rad(errorstatus,nchanxnprof,radiance,nlevels_in-1,asw) + deallocate(ichan,chanprof,frequencies,emissivity,calcemis) !instrument, + !*************************************************************************** + !-------- end section -------- + !*************************************************************************** + end subroutine cosp_rttov_mwscatt + function construct_rttov_coeffilename(platform,satellite,instrument) + ! Inputs + integer,intent(in) :: platform,satellite,instrument + ! Outputs + character(len=256) :: construct_rttov_coeffilename + ! Local variables + character(len=256) :: coef_file + integer :: error + + ! Initialize + error = 0 + + ! Platform + if (platform .eq. 1) coef_file = 'rtcoef_noaa_' + if (platform .eq. 10) coef_file = 'rtcoef_metop_' + if (platform .eq. 11) coef_file = 'rtcoef_envisat_' + if (platform .ne. 1 .and. platform .ne. 10 .and. platform .ne. 11) then + error=error+1 + write ( *,* ) 'Unsupported platform ID ',platform + return + endif + + ! Satellite + if (satellite .lt. 10) then + coef_file = trim(coef_file) // char(satellite+48) + else if (satellite .lt. 100) then + coef_file = trim(coef_file) // char(int(satellite/10)+48) + coef_file = trim(coef_file) // char(satellite-int(satellite/10)*10+48) + else + error=error+1 + write ( *,* ) 'Unsupported satellite number ',satellite + return + endif + + ! Sensor + if (sensor .eq. 3) coef_file = trim(coef_file) // '_amsua.dat' + if (sensor .eq. 5) coef_file = trim(coef_file) // '_avhrr.dat' + if (sensor .eq. 49) coef_file = trim(coef_file) // '_mwr.dat' + if (sensor .ne. 3 .and. sensor .ne. 5 .and. sensor .ne. 49) then + error=error+1 + write ( *,* ) 'Unsupported sensor number ', sensor + return + endif + + if (error .eq. 0) construct_rttov_coeffilename=coef_file + + end function construct_rttov_coeffilename + function construct_rttov_scatfilename(platform,satellite,instrument) + ! Inputs + integer,intent(in) :: platform,satellite,instrument + ! Outputs + character(len=256) :: construct_rttov_scatfilename + ! Local variables + character(len=256) :: coef_file + integer :: error + + ! Initialize + error = 0 + + ! Platform + if (platform .eq. 1) coef_file = 'sccldcoef_noaa_' + if (platform .eq. 10) coef_file = 'sccldcoef_metop_' + if (platform .eq. 11) coef_file = 'sccldcoef_envisat_' + if (platform .ne. 1 .and. platform .ne. 10 .and. platform .ne. 11) then + error=error+1 + write ( *,* ) 'Unsupported platform ID ',platform + return + endif + + ! Satellite + if (satellite .lt. 10) then + coef_file = trim(coef_file) // char(satellite+48) + else if (satellite .lt. 100) then + coef_file = trim(coef_file) // char(int(satellite/10)+48) + coef_file = trim(coef_file) // char(satellite-int(satellite/10)*10+48) + else + error=error+1 + write ( *,* ) 'Unsupported satellite number ',satellite + return + endif + + ! Sensor + if (sensor .eq. 3) coef_file = trim(coef_file) // '_amsua.dat' + if (sensor .eq. 5) coef_file = trim(coef_file) // '_avhrr.dat' + if (sensor .eq. 49) coef_file = trim(coef_file) // '_mwr.dat' + if (sensor .ne. 3 .and. sensor .ne. 5 .and. sensor .ne. 49) then + error=error+1 + write ( *,* ) 'Unsupported sensor number ', sensor + return + endif + + if (error .eq. 0) construct_rttov_scatfilename=coef_file + + end function construct_rttov_scatfilename + +end module mod_cosp_rttov From 9b842f9a8edcd87c23cc95906772e471b2cb516b Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Mon, 3 Apr 2023 16:52:32 -0600 Subject: [PATCH 043/159] Separate output saving and profile deallocation into separate subroutines to prepare for PC-RTTOV --- src/simulator/cosp_rttov_interface_v13.F90 | 24 ++++++---- src/simulator/rttov/cosp_rttov_v13.F90 | 54 ++++++++++------------ 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index b6d183d08a..d1461e1047 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -375,7 +375,8 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, cosp_rttov_construct_profiles, & cosp_rttov_setup_emissivity_reflectance, & cosp_rttov_call_direct, & - cosp_rttov_save_and_deallocate_profiles, & + cosp_rttov_save_output, & + cosp_rttov_deallocate_profiles, & cosp_rttov_deallocate_coefs type(rttov_in),intent(in) :: & @@ -411,25 +412,28 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, ! print*,'cosp_rttov_call_direct successful' ! jks call cpu_time(driver_time(5)) - call cosp_rttov_save_and_deallocate_profiles(rttovIN, & - bt_total,bt_clear, & - rad_total,rad_clear,rad_cloudy, & - refl_total,refl_clear) + call cosp_rttov_save_output(rttovIN, & + bt_total,bt_clear, & + rad_total,rad_clear,rad_cloudy, & + refl_total,refl_clear) ! print*,'cosp_rttov_save_and_deallocate_profiles successful' ! jks call cpu_time(driver_time(6)) - + call cosp_rttov_deallocate_profiles(rttovIN) + call cpu_time(driver_time(7)) + print*,'Time to run "cosp_rttov_allocate": ', driver_time(2)-driver_time(1) print*,'Time to run "cosp_rttov_construct_profiles": ', driver_time(3)-driver_time(2) print*,'Time to run "cosp_rttov_setup_emissivity_reflectance": ',driver_time(4)-driver_time(3) print*,'Time to run "cosp_rttov_call_direct": ', driver_time(5)-driver_time(4) - print*,'Time to run "cosp_rttov_save_and_deallocate_profiles": ',driver_time(6)-driver_time(5) + print*,'Time to run "cosp_rttov_save_output": ', driver_time(6)-driver_time(5) + print*,'Time to run "cosp_rttov_deallocate_profiles": ', driver_time(7)-driver_time(6) ! Deallocate the coefficient files if directed if (lCleanup) then - call cpu_time(driver_time(7)) - call cosp_rttov_deallocate_coefs() call cpu_time(driver_time(8)) - print*,'Time to run "cosp_rttov_deallocate_coefs": ',driver_time(8)-driver_time(7) + call cosp_rttov_deallocate_coefs() + call cpu_time(driver_time(9)) + print*,'Time to run "cosp_rttov_deallocate_coefs": ',driver_time(9)-driver_time(8) endif ! print*,'Total RTTOV run time: ',driver_time(8)-driver_time(1) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index d41c5ce0f2..70b92459fb 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -352,17 +352,11 @@ subroutine cosp_rttov_construct_profiles(rttovIN & profiles(i)%t(:) = rttovIN%t(i, :) profiles(i)%q(:) = rttovIN%q(i, :) - ! q coefficient limit is 09=.1e-10 + ! q coefficient limit is 0.1e-10 where(profiles(i)%q(:) < 0.1e-10) profiles(i)%q(:) = 0.11e-10 end where -! if (any(profiles%q < 0.1e-10)) then -! write(*,*) 'q profile less than RTTOV minimum. Rewritten to 1e-11' -! errorstatus = 1 -! call rttov_exit(errorstatus) -! endif - ! Gas profiles profiles(i)%o3 = rttovIN%o3(i, :) @@ -417,9 +411,9 @@ subroutine cosp_rttov_construct_profiles(rttovIN & ! JKS - nothing to check here, this will never trigger. call rttov_error('error in profile initialization' , lalloc = .false.) -! print*,'profiles(90)%p(:): ',profiles(90)%p(:) -! print*,'profiles(90)%q(:): ',profiles(90)%q(:) -! print*,'profiles(90)%t(:): ',profiles(90)%t(:) +! print*,'profiles(1)%p(:): ',profiles(1)%p(:) +! print*,'profiles(1)%q(:): ',profiles(1)%q(:) +! print*,'profiles(1)%t(:): ',profiles(1)%t(:) ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Only add the cloud fields if simulating cloud. @@ -550,14 +544,15 @@ subroutine cosp_rttov_call_direct() end subroutine cosp_rttov_call_direct - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! rttov_save_and_deallocate - 8. Save output data, 9. Deallocate all RTTOV arrays and structures + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 8. Save output data ! ------------------------------------------------------ - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_rttov_save_and_deallocate_profiles(rttovIN, & - bt_total,bt_clear, & - rad_total,rad_clear,rad_cloudy, & - refl_total,refl_clear) + ! JKS - Need to allow options for Tb and radiance for clear- and cloudy-skies + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine cosp_rttov_save_output(rttovIN, & + bt_total,bt_clear, & + rad_total,rad_clear,rad_cloudy, & + refl_total,refl_clear) type(rttov_in),intent(in) :: & rttovIN real(wp),dimension(rttovIN%nPoints,rttovIN%nChannels),intent(inout) :: & ! Can I do this? I guess so! @@ -568,12 +563,6 @@ subroutine cosp_rttov_save_and_deallocate_profiles(rttovIN, rad_cloudy, & refl_total, & refl_clear - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! 8. Save output data - ! ------------------------------------------------------ - ! JKS - Need to allow options for Tb and radiance for clear- and cloudy-skies - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Documentation for RTTOV radiance structure in RTTOV User Guide pg 166 @@ -607,11 +596,18 @@ subroutine cosp_rttov_save_and_deallocate_profiles(rttovIN, transpose(reshape(radiance%refl_clear(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) endif - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! 9. Deallocate all RTTOV arrays and structures - ! ------------------------------------------------------ - ! From RTTOV example files. - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + end subroutine cosp_rttov_save_output + + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 9. Deallocate all RTTOV arrays and structures + ! ------------------------------------------------------ + ! From RTTOV example files. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine cosp_rttov_deallocate_profiles(rttovIN) + + type(rttov_in),intent(in) :: & + rttovIN ! JKS no longer using channel_list, rttovIN%channels instead !deallocate (channel_list, stat=alloc_status(1)) @@ -643,7 +639,7 @@ subroutine cosp_rttov_save_and_deallocate_profiles(rttovIN, call rttov_dealloc_coefs(errorstatus, coef_rttov) call rttov_error('coefs deallocation error', lalloc = .true.) - end subroutine cosp_rttov_save_and_deallocate_profiles + end subroutine cosp_rttov_deallocate_profiles subroutine cosp_rttov_deallocate_coefs() From 147d1875175542fd2c57d7092cf8534c76153703 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Mon, 3 Apr 2023 16:56:05 -0600 Subject: [PATCH 044/159] remove duplicate deallocation of RTTOV coefficients in cosp_rttov_deallocate_profiles --- src/simulator/rttov/cosp_rttov_v13.F90 | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 70b92459fb..8f82263b60 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -635,9 +635,6 @@ subroutine cosp_rttov_deallocate_profiles(rttovIN) calcrefl=calcrefl, & reflectance=reflectance) call rttov_error('deallocation error for rttov_direct structures', lalloc = .true.) - - call rttov_dealloc_coefs(errorstatus, coef_rttov) - call rttov_error('coefs deallocation error', lalloc = .true.) end subroutine cosp_rttov_deallocate_profiles From 70ef680e58df6f2668f1b778d5160d7bc0f30311 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 4 Apr 2023 17:11:13 -0600 Subject: [PATCH 045/159] Draft of PC-RTTOV code Code compiles, but I haven't tried running it yet. For later this week. --- src/simulator/cosp_rttov_interface_v13.F90 | 168 +++++++++--- src/simulator/rttov/cosp_rttov_v13.F90 | 286 ++++++++++++++++++--- 2 files changed, 390 insertions(+), 64 deletions(-) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index d1461e1047..5bcc24585e 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -35,9 +35,10 @@ MODULE MOD_COSP_RTTOV_INTERFACE use mod_cosp_rttov, only: nChannels,iChannel,emisChannel,reflChannel, & coef_rttov,opts,rttov_in, & do_rttov_bt,do_rttov_rad,do_rttov_refl, & - do_rttov_cld,do_rttov_aer,rttov_cld_optparam, & - rttov_aer_optparam,rttov_direct_nthreads, & - rttovDir,so2,ch4,co,co2,n2o,zenang + do_rttov_cld,do_rttov_aer,do_rttov_pcrttov, & + rttov_cld_optparam,rttov_aer_optparam, & + rttov_direct_nthreads,rttovDir,pc_coef_filepath, & + so2,ch4,co,co2,n2o,zenang,npcscores ! rttov_const contains useful RTTOV constants @@ -129,6 +130,9 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, i, & rttov_nthreads + integer(kind=jpim) :: ipcbnd, ipcreg + + ! Read RTTOV namelist fields namelist/RTTOV_INPUT/channel_filepath,rttov_srcDir,rttov_coefDir, & OD_coef_filepath,aer_coef_filepath,cld_coef_filepath, & @@ -252,6 +256,7 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, opts%rt_ir%dom_rayleigh = .false. ! Principal Components-only radiative transfer options: + ! Default off opts%rt_ir%pc%addpc = .false. opts%rt_ir%pc%npcscores = -1 opts%rt_ir%pc%addradrec = .false. @@ -275,29 +280,42 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, ! Developer options that may be useful: opts%dev%do_opdep_calc = .true. - ! JKS To-do: include opts_scatt settings (user guide pg 161) + !! JKS - Hardcode in some options that will eventually be moved to the namelist + ipcbnd = 1 ! This should always be one per the User Guide + ipcreg = 2 ! 300 predictors (channels). See RTTOV user guide Table 31. + npcscores = 100 ! 100 principal component scores + + ! If using PC-RTTOV, some settings must be a certain way. This isn't always true though... + if (do_rttov_pcrttov) then + opts % rt_ir % pc % addpc = .true. + opts % rt_ir % pc % ipcbnd = ipcbnd + opts % rt_ir % pc % ipcreg = ipcreg + opts % rt_ir % pc % npcscores = npcscores + ! In this example we reconstruct radiances if there is an input file + ! containing a channel list +! INQUIRE(file=radrec_filename, exist=exists) ! exists is a logical, but I don't think we need it + opts % rt_ir % pc % addradrec = .true. ! exists, I could add a logical in the namelist to determine this - ! Old configured options + opts % interpolation % addinterp = .true. ! Allow interpolation of input profile + opts % interpolation % interp_mode = 1 ! Set interpolation method + opts % rt_all % addrefrac = .true. ! Include refraction in path calc (always for PC) + opts % rt_ir % addclouds = .false. ! Don't include cloud effects (always for PC?) + opts % rt_ir % addaerosl = .false. ! Don't include aerosol effects (not always for PC) + opts % rt_ir % addsolar = .false. ! Do not include solar radiation (always for PC?) - ! Options common to RTTOV clear-sky Tb calculation -! opts%interpolation%addinterp = .true. ! allow interpolation of input profile -! opts%rt_all%use_q2m = .true. -! opts%config%do_checkinput = .false. -! opts%config%verbose = .false. -! opts%rt_all%addrefrac = .true. ! include refraction in path calc -! opts%interpolation%reg_limit_extrap = .true. - -! opts%rt_mw%clw_data = .true. - ! Options common to RTTOV clear-sky Tb calculation + ! These options will depend on the coefficients used and should be left up to the user +! opts % rt_all % ozone_data = .TRUE. ! We have an ozone profile +! opts % rt_all % co2_data = .FALSE. ! We do not have profiles +! opts % rt_all % n2o_data = .FALSE. ! for any other constituents +! opts % rt_all % ch4_data = .FALSE. ! +! opts % rt_all % co_data = .FALSE. ! +! opts % rt_all % so2_data = .FALSE. ! +! opts % rt_mw % clw_data = .FALSE. ! + + endif - ! These scattering options are depreciated in v13 -! opts_scatt%config%do_checkinput = .false. -! opts_scatt%config%verbose = .false. -! opts_scatt%config%apply_reg_limits = .true. -! opts_scatt%interp_mode = 1 -! opts_scatt%reg_limit_extrap = .true. -! opts_scatt%use_q2m = .true. + ! JKS To-do: include opts_scatt settings (user guide pg 161) ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -307,9 +325,10 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Construct optical depth and cloud coefficient files + pc_coef_filepath = 'test' ! rttovDir should be "/glade/u/home/jonahshaw/w/RTTOV/" and is defined in cosp_config.F90 - OD_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(OD_coef_filepath) + OD_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(OD_coef_filepath) aer_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(aer_coef_filepath) cld_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(cld_coef_filepath) @@ -317,21 +336,30 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, ! print*,'aer_coef_filepath: ',aer_coef_filepath ! print*,'cld_coef_filepath: ',cld_coef_filepath - ! Read optical depth and cloud coefficient files together - call rttov_read_coefs(errorstatus, coef_rttov, opts, & - file_coef=OD_coef_filepath, & - file_scaer=aer_coef_filepath, & - file_sccld=cld_coef_filepath) + ! Do I need logicals here to direct how to read the coefficients? + + + if (do_rttov_pcrttov) then ! PC-RTTOV cannot handle cloud, some aerosols + pc_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(pc_coef_filepath) + + call rttov_read_coefs(errorstatus, coef_rttov, opts, & + file_coef=OD_coef_filepath, & + file_scaer=aer_coef_filepath, & ! Needs to be PC-RTTOV compatible + file_pccoef=pc_coef_filepath) + else ! Read optical depth and cloud coefficient files together + call rttov_read_coefs(errorstatus, coef_rttov, opts, & + file_coef=OD_coef_filepath, & + file_scaer=aer_coef_filepath, & + file_sccld=cld_coef_filepath) + ! Ensure input number of channels is not higher than number stored in coefficient file + if (nchannels > coef_rttov % coef % fmv_chn) then + nchannels = coef_rttov % coef % fmv_chn + endif + endif ! We aren't checking an allocation steps so this seems more appropriate. call rttov_error('fatal error reading coefficients' , lalloc = .false.) - - ! Ensure input number of channels is not higher than number stored in coefficient file - if (nchannels > coef_rttov % coef % fmv_chn) then - nchannels = coef_rttov % coef % fmv_chn - endif - ! Ensure the options and coefficients are consistent call rttov_user_options_checkinput(errorstatus, opts, coef_rttov) @@ -439,7 +467,79 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, ! print*,'Total RTTOV run time: ',driver_time(8)-driver_time(1) END SUBROUTINE COSP_RTTOV_SIMULATE + + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE cosp_rttov_simulate - Call subroutines in mod_cosp_rttov to run RTTOV + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,lCleanup, & ! Inputs + bt_total,rad_total, & ! Outputs + error) + use mod_cosp_rttov, only: & + cosp_pc_rttov_allocate, & + cosp_rttov_construct_profiles, & + cosp_pc_rttov_setup_emissivity, & + cosp_pc_rttov_call_direct, & + cosp_pc_rttov_save_output, & + cosp_pc_rttov_deallocate_profiles, & + cosp_rttov_deallocate_coefs + + type(rttov_in),intent(in) :: & + rttovIN + logical,intent(in) :: & + lCleanup ! Flag to determine whether to deallocate RTTOV types + real(wp),intent(inout),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! + bt_total, & ! All-sky + rad_total ! All-sky + character(len=128) :: & + error ! Error messages (only populated if error encountered) + + real(wp),dimension(10) :: driver_time + + ! Run each step for running RTTOV from mod_cosp_rttov (and time them) +! print*,'cosp_rttov_allocate begin' ! jks + call cpu_time(driver_time(1)) + call cosp_pc_rttov_allocate(rttovIN) +! print*,'cosp_rttov_allocate successful' ! jks + call cpu_time(driver_time(2)) + call cosp_rttov_construct_profiles(rttovIN) +! print*,'cosp_rttov_construct_profiles successful' ! jks + call cpu_time(driver_time(3)) + call cosp_pc_rttov_setup_emissivity() +! print*,'cosp_rttov_setup_emissivity_reflectance successful' ! jks + call cpu_time(driver_time(4)) + call cosp_pc_rttov_call_direct() +! print*,'cosp_rttov_call_direct successful' ! jks + call cpu_time(driver_time(5)) + + call cosp_pc_rttov_save_output(rttovIN, & + bt_total,rad_total) +! print*,'cosp_rttov_save_and_deallocate_profiles successful' ! jks + call cpu_time(driver_time(6)) + call cosp_pc_rttov_deallocate_profiles(rttovIN) + call cpu_time(driver_time(7)) + + print*,'Time to run "cosp_pc_rttov_allocate": ', driver_time(2)-driver_time(1) + print*,'Time to run "cosp_rttov_construct_profiles": ', driver_time(3)-driver_time(2) + print*,'Time to run "cosp_pc_rttov_setup_emissivity": ', driver_time(4)-driver_time(3) + print*,'Time to run "cosp_pc_rttov_call_direct": ', driver_time(5)-driver_time(4) + print*,'Time to run "cosp_pc_rttov_save_output": ', driver_time(6)-driver_time(5) + print*,'Time to run "cosp_pc_rttov_deallocate_profiles": ', driver_time(7)-driver_time(6) + + ! Deallocate the coefficient files if directed + if (lCleanup) then + call cpu_time(driver_time(8)) + call cosp_rttov_deallocate_coefs() + call cpu_time(driver_time(9)) + print*,'Time to run "cosp_rttov_deallocate_coefs": ',driver_time(9)-driver_time(8) + endif + +! print*,'Total RTTOV run time: ',driver_time(8)-driver_time(1) + + END SUBROUTINE COSP_PC_RTTOV_SIMULATE + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! END MODULE ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 8f82263b60..d430830f55 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -39,7 +39,8 @@ module mod_cosp_rttov ! Use RTTOV v13 types here, more may be needed use rttov_types, only : rttov_options,rttov_coefs,rttov_profile, & rttov_transmission,rttov_radiance,rttov_chanprof, & - rttov_emissivity,rttov_reflectance,rttov_opt_param + rttov_emissivity,rttov_reflectance,rttov_opt_param, & + rttov_pccomp use rttov_const, only : surftype_sea, surftype_land, surftype_seaice, & errorstatus_success,errorstatus_fatal, & platform_name,inst_name, & @@ -66,29 +67,16 @@ module mod_cosp_rttov implicit none -! Old includes -!#include "rttov_direct.interface" -!#include "rttov_alloc_prof.interface" -!#include "rttov_alloc_rad.interface" -!#include "rttov_alloc_transmission.interface" -!#include "rttov_dealloc_coefs.interface" -!#include "rttov_user_options_checkinput.interface" -!#include "rttov_read_coefs.interface" -!#include "rttov_get_emis.interface" -!#include "rttov_boundaryconditions.interface" - ! New includes for v13 (will need to clean up others) #include "rttov_direct.interface" #include "rttov_parallel_direct.interface" -#include "rttov_read_coefs.interface" -#include "rttov_read_scattcoeffs.interface" #include "rttov_dealloc_coefs.interface" #include "rttov_alloc_direct.interface" #include "rttov_init_emis_refl.interface" #include "rttov_user_options_checkinput.interface" +#include "rttov_get_pc_predictindex.interface" #include "rttov_print_opts.interface" #include "rttov_print_profile.interface" -#include "rttov_skipcommentline.interface" ! Includes when directly inputting cloud optical parameters #include "rttov_init_opt_param.interface" @@ -113,20 +101,17 @@ module mod_cosp_rttov reflChannel(:) ! RTTOV channel reflectivity ! Scattering coefficients (read in once during initialization) - type(rttov_coefs) :: & - coef_rttov ! JKS - KISS ! type(rttov_scatt_coef) :: & ! coef_scatt ! RTTOV setup and options (set during initialization) - type(rttov_options) :: & - opts ! defaults to everything optional switched off logical :: & do_rttov_cld, & ! Include clouds in RTTOV calculations do_rttov_aer, & ! Include aerosols in RTTOV calculations do_rttov_bt, & ! Return brightness temps in RTTOV calculations do_rttov_rad, & ! Return radiances in RTTOV calculations do_rttov_refl, & ! Return reflectances in RTTOV calculations + do_rttov_pcrttov, & ! Do computations using PC-RTTOV rttov_cld_optparam, & ! Use user-supplied optical cloud parameters rttov_aer_optparam ! Use user-supplied optical aerosol parameters @@ -139,8 +124,9 @@ module mod_cosp_rttov real(wp) :: zenang = 0._wp ! NADIR default character(len=256) :: & - rttovDir ! Directory for the RTTOV source code - + rttovDir, & ! Directory for the RTTOV source code + pc_coef_filepath + ! JKS - KISS ! type(rttov_options_scatt) :: & ! opts_scatt @@ -149,8 +135,9 @@ module mod_cosp_rttov !==================== integer(kind=jpim) :: dosolar integer(kind=jpim) :: nchanprof ! JKS - jpim is RTTOV integer type -! integer(kind=jpim), allocatable :: channel_list(:) ! JKS this needs to be specified - + + TYPE(rttov_options) :: opts ! defaults to everything optional switched off + TYPE(rttov_coefs) :: coef_rttov ! Coefficients structure TYPE(rttov_chanprof), POINTER :: chanprof(:) => NULL() ! Input channel/profile list LOGICAL(KIND=jplm), POINTER :: calcemis(:) => NULL() ! Flag to indicate calculation of emissivity within RTTOV TYPE(rttov_emissivity), POINTER :: emissivity(:) => NULL() ! Input/output surface emissivity @@ -159,10 +146,18 @@ module mod_cosp_rttov TYPE(rttov_profile), POINTER :: profiles(:) => NULL() ! Input profiles TYPE(rttov_transmission) :: transmission ! Output transmittances TYPE(rttov_radiance) :: radiance ! Output radiances + TYPE(rttov_pccomp) :: pccomp ! Output PC structure + INTEGER(KIND=jpim), POINTER :: channels_rec(:) => NULL() ! Reconstructed radiance channel list INTEGER(KIND=jpim) :: errorstatus ! Return error status of RTTOV subroutine calls INTEGER(KIND=jpim) :: alloc_status(60) + + ! JKS additional variables used in PC-RTTOV +! INTEGER(KIND=jpim) :: ipcbnd, ipcreg, npcscores ! JKS delete? + INTEGER(KIND=jpim), POINTER :: predictindex(:) + INTEGER(KIND=jpim) :: nchannels_rec, nchannels_comp, npcscores + INTEGER(KIND=jpim) :: lo, hi ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! TYPE rttov_in @@ -242,7 +237,7 @@ end subroutine rttov_error ! 4. Build the list of profile/channel indices in chanprof ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine cosp_rttov_allocate(rttovIN & - ) + ) type(rttov_in),intent(in) :: & rttovIN @@ -263,16 +258,13 @@ subroutine cosp_rttov_allocate(rttovIN & call rttov_alloc_direct( & errorstatus, & 1_jpim, & ! 1 => allocate -! nprof, & rttovIN%nPoints, & nchanprof, & -! nlevels, & rttovIN%nLevels, & chanprof, & opts, & profiles, & coef_rttov, & -! coefs, & transmission, & radiance, & calcemis=calcemis, & @@ -299,7 +291,109 @@ subroutine cosp_rttov_allocate(rttovIN & end subroutine cosp_rttov_allocate + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE pc_rttov_allocate - Subroutine for running PC-RTTOV + ! ------------------------------------------------------ + ! 3. Allocate RTTOV input and output structures + ! 4. Build the list of profile/channel indices in chanprof + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine cosp_pc_rttov_allocate(rttovIN & + ) + + type(rttov_in),intent(in) :: & + rttovIN + + ! Loop variables + integer(kind=jpim) :: j, jch, nch + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 3. Allocate RTTOV input and output structures + ! ------------------------------------------------------ + ! Largely from RTTOV documentation. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + ! Determine the size of the chanprof array (the number of PC-RTTOV predictor channels). + ! This is determined by ipcbnd and ipcreg and is the same for all simulated profiles. + ! The channel list in chanprof is the set of predictor channels for the PC scheme. + ! The channel list may be obtained using the rttov_get_pc_predictindex subroutine: + + nullify(predictindex) + call rttov_get_pc_predictindex(errorstatus, opts, predictindex, file_pccoef=pc_coef_filepath) + call rttov_error('rttov_get_pc_predictindex fatal error' , lalloc = .false.) + +! IF (errorstatus /= errorstatus_success) THEN +! WRITE(*,*) 'rttov_get_pc_predictindex fatal error' +! CALL rttov_exit(errorstatus) +! ENDIF + + nchannels_rec = rttovIN%nChannels ! Number of channels to reconstruct indicated in namelist. + nchannels_comp = SIZE(predictindex) ! Number of channels to compute is determined by ipcreg in init. + nchanprof = nchannels_comp * rttovIN%nPoints ! Size of chanprof array is total number of channels over all profiles. + + ! Determine the number of reconstructed radiances per profile (nchannels_rec) + if (opts % rt_ir % pc % addradrec) then + if (nchannels_rec < 0) then + ! If the number of channels is negative, don't reconstruct radiances at all + opts % rt_ir % pc % addradrec = .FALSE. + else if (nchannels_rec == 0) then + ! If the number of channels is set to 0 then reconstruct all instrument channels + nchannels_rec = coef_rttov % coef % fmv_chn + allocate(channels_rec(nchannels_rec)) + channels_rec(:) = (/ (j, j = 1, nchannels_rec) /) + else + ! Otherwise read the channel list from the file + allocate(channels_rec(nchannels_rec)) + channels_rec(:) = iChannel ! channels_rec is just the index of the desired channels + endif + endif + + ! Ensure we don't have unassociated pointers below when addradrec is FALSE + if (nchannels_rec <= 0) allocate(channels_rec(0)) + + ! Allocate structures for rttov_direct + CALL rttov_alloc_direct( & + errorstatus, & + 1_jpim, & ! 1 => allocate + rttovIN%nPoints, & + nchanprof, & + rttovIN%nLevels, & + chanprof, & + opts, & + profiles, & + coef_rttov, & + transmission, & + radiance, & + calcemis=calcemis, & + emissivity=emissivity, & + npcscores=npcscores * rttovIN%nPoints, & + nchannels_rec=nchannels_rec * rttovIN%nPoints, & + pccomp=pccomp, & + init=.TRUE._jplm) + call rttov_error('allocation error for rttov_direct structures (PC-RTTOV)' , lalloc = .true.) + +! IF (errorstatus /= errorstatus_success) THEN +! WRITE(*,*) 'allocation error for rttov_direct structures' +! CALL rttov_exit(errorstatus) +! ENDIF + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 4. Build the list of profile/channel indices in chanprof + ! ------------------------------------------------------ + ! Largely from RTTOV documentation. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + ! Populate chanprof using the channel list obtained above in predictindex(:) + do j = 1, rttovIN%nPoints + lo = (j - 1) * nchannels_comp + 1 + hi = lo + nchannels - 1 + chanprof(lo:hi)%prof = j + chanprof(lo:hi)%chan = predictindex(:) + end do + + end subroutine cosp_pc_rttov_allocate + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 5. rttov_construct_profiles: 5. Read profile data ! ------------------------------------------------------ @@ -500,7 +594,23 @@ subroutine cosp_rttov_setup_emissivity_reflectance() calcrefl(:) = (reflectance(:) % refl_in <= 0._jprb) end subroutine cosp_rttov_setup_emissivity_reflectance + + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 6. rttov_setup_emissivity_reflectance - Specify surface emissivity for PC-RTTOV + ! ------------------------------------------------------ + ! From RTTOV example files. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine cosp_pc_rttov_setup_emissivity() + + ! PC-RTTOV requires using RTTOV to calculate the surface emissivities. + ! Reflectances are never calculated for hyper-spectral IR sounders + call rttov_init_emis_refl(emissivity) + calcemis(:) = .TRUE. + call rttov_error('error for emissivity initialization (PC-RTTOV)' , lalloc = .true.) + end subroutine cosp_pc_rttov_setup_emissivity + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 7. rttov_call_direct - Call RTTOV forward model (Woohoo!) @@ -543,7 +653,49 @@ subroutine cosp_rttov_call_direct() end subroutine cosp_rttov_call_direct + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 7. rttov_call_direct - Call PC-RTTOV forward model (Woohoo!) + ! ------------------------------------------------------ + ! From RTTOV example files. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine cosp_pc_rttov_call_direct() + + if (rttov_direct_nthreads <= 1) then + print*,'Calling rttov_direct' + call rttov_direct( & + errorstatus, &! out error flag + chanprof, &! in channel and profile index structure + opts, &! in options structure + profiles, &! in profile array + coef_rttov, &! in coefficients structure + transmission, &! inout computed transmittances + radiance, &! inout computed radiances + calcemis = calcemis, &! in flag for internal emissivity calcs + emissivity = emissivity, &! inout input/output emissivities per channel + pccomp = pccomp, &! inout computed PC scores + channels_rec = channels_rec) ! in reconstructed channel list + else + print*,'Calling rttov_parallel_direct' + call rttov_parallel_direct( & + errorstatus, &! out error flag + chanprof, &! in channel and profile index structure + opts, &! in options structure + profiles, &! in profile array + coef_rttov, &! in coefficients structure + transmission, &! inout computed transmittances + radiance, &! inout computed radiances + calcemis = calcemis, &! in flag for internal emissivity calcs + emissivity = emissivity, &! inout input/output emissivities per channel + pccomp = pccomp, &! inout computed PC scores + channels_rec = channels_rec,&! in reconstructed channel list + nthreads = rttov_direct_nthreads) ! in number of threads to use + endif + call rttov_error('rttov_direct error (PC-RTTOV)', lalloc = .true.) + end subroutine cosp_pc_rttov_call_direct + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 8. Save output data ! ------------------------------------------------------ @@ -556,7 +708,7 @@ subroutine cosp_rttov_save_output(rttovIN, & type(rttov_in),intent(in) :: & rttovIN real(wp),dimension(rttovIN%nPoints,rttovIN%nChannels),intent(inout) :: & ! Can I do this? I guess so! - bt_total, & ! RTTOV brightness temperature. + bt_total, & bt_clear, & rad_total, & rad_clear, & @@ -599,6 +751,42 @@ subroutine cosp_rttov_save_output(rttovIN, & end subroutine cosp_rttov_save_output + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 8. Save output data (PC-RTTOV) + ! ------------------------------------------------------ + ! JKS - Need to allow options for Tb and radiance for clear- and cloudy-skies + ! PC-RTTOV only does clear-sky IR calculations (can handle aerosols, but I'll ignore that for now. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +! subroutine cosp_pc_rttov_save_output(rttovIN, & +! bt_total,bt_clear, & +! rad_total,rad_clear,rad_cloudy, & +! refl_total,refl_clear) + + subroutine cosp_pc_rttov_save_output(rttovIN, & + bt_total,rad_total) + + type(rttov_in),intent(in) :: & + rttovIN + real(wp),dimension(rttovIN%nPoints,rttovIN%nChannels),intent(inout) :: & ! Can I do this? I guess so! + bt_total, & + rad_total + + ! Documentation for RTTOV radiance structure in RTTOV User Guide pg 166 + + ! Only save output if appropriate + if (do_rttov_bt) then + bt_total(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & + transpose(reshape(pccomp%bt_pccomp(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) + endif + + if (do_rttov_rad) then + rad_total(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & + transpose(reshape(pccomp%total_pccomp(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) + endif + + end subroutine cosp_pc_rttov_save_output + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 9. Deallocate all RTTOV arrays and structures ! ------------------------------------------------------ @@ -619,10 +807,8 @@ subroutine cosp_rttov_deallocate_profiles(rttovIN) call rttov_alloc_direct( & errorstatus, & 0_jpim, & ! 0 => deallocate -! nprof, & rttovIN%nPoints, & nchanprof, & -! nlevels, & rttovIN%nLevels, & chanprof, & opts, & @@ -637,7 +823,47 @@ subroutine cosp_rttov_deallocate_profiles(rttovIN) call rttov_error('deallocation error for rttov_direct structures', lalloc = .true.) end subroutine cosp_rttov_deallocate_profiles + + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 9. Deallocate all RTTOV arrays and structures (PC-RTTOV) + ! ------------------------------------------------------ + ! From RTTOV example files. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine cosp_pc_rttov_deallocate_profiles(rttovIN) + + type(rttov_in),intent(in) :: & + rttovIN + + if (ASSOCIATED(predictindex)) deallocate (predictindex, stat=alloc_status(10)) + call rttov_error('mem dellocation error for "predictindex"', lalloc = .true.) + + if (ASSOCIATED(channels_rec)) deallocate (channels_rec, stat=alloc_status(11)) + call rttov_error('mem dellocation error for "channels_rec"', lalloc = .true.) + + ! Deallocate structures for rttov_direct + call rttov_alloc_direct( & + errorstatus, & + 0_jpim, & ! 0 => deallocate + rttovIN%nPoints, & + nchanprof, & + rttovIN%nLevels, & + chanprof, & + opts, & + profiles, & + coef_rttov, & + transmission, & + radiance, & + calcemis=calcemis, & + emissivity=emissivity, & + npcscores=npcscores * rttovIN%nPoints, & + nchannels_rec=nchannels_rec * rttovIN%nPoints, & + pccomp=pccomp) + call rttov_error('deallocation error for rttov_direct structures (PC-RTTOV)', lalloc = .true.) + + end subroutine cosp_pc_rttov_deallocate_profiles + subroutine cosp_rttov_deallocate_coefs() call rttov_dealloc_coefs(errorstatus, coef_rttov) From 3c7c28ea5ef431162d668d6d3b66ff2c04766c2b Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 3 May 2023 19:18:39 -0600 Subject: [PATCH 046/159] Namelist file updates for PC-RTTOV --- driver/run/cosp2_input_rttov_nl.txt | 2 +- driver/run/cosp2_output_pcrttov_nl.txt | 160 +++++++++++++++++++++++++ driver/run/cosp2_output_rttov_nl.txt | 1 + driver/run/cosp2_pcrttov_nl.txt | 55 +++++++++ driver/run/cosp2_rttov_nl.txt | 13 +- 5 files changed, 224 insertions(+), 7 deletions(-) create mode 100644 driver/run/cosp2_output_pcrttov_nl.txt create mode 100644 driver/run/cosp2_pcrttov_nl.txt diff --git a/driver/run/cosp2_input_rttov_nl.txt b/driver/run/cosp2_input_rttov_nl.txt index 6fdec1c40f..53a4b644d5 100644 --- a/driver/run/cosp2_input_rttov_nl.txt +++ b/driver/run/cosp2_input_rttov_nl.txt @@ -82,7 +82,7 @@ !---------------------------------------------------------------------------------- !-------------- RTTOV inputs !---------------------------------------------------------------------------------- - rttov_Nchannels=200, ! Number of channels to be computed + rttov_Nchannels=2300, ! Number of channels to be computed rttov_Nlocaltime=2, rttov_localtime=10.0,13.0, ! To implement local time rttov_localtimewindow=1.0,1.0, ! To implement local time width diff --git a/driver/run/cosp2_output_pcrttov_nl.txt b/driver/run/cosp2_output_pcrttov_nl.txt new file mode 100644 index 0000000000..58b7aa30ac --- /dev/null +++ b/driver/run/cosp2_output_pcrttov_nl.txt @@ -0,0 +1,160 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +! Namelist that sets up output-related variables. It controls +! the instrument simulators to run and the list of variables +! to be written to file +&COSP_OUTPUT + !- CloudSat + Lcfaddbze94=.true., + Ldbze94=.true., + !- CALIPSO + Latb532=.true., + LcfadLidarsr532=.true., + Lclcalipso=.true., + Lclhcalipso=.true., + Lcllcalipso=.true., + Lclmcalipso=.true., + Lcltcalipso=.true., + LparasolRefl=.true., + ! CALIPSO phase diagnostics + Lclcalipsoliq=.true., + Lclcalipsoice=.true., + Lclcalipsoun=.true., + Lclcalipsotmp=.true., + Lclcalipsotmpliq=.true., + Lclcalipsotmpice=.true., + Lclcalipsotmpun=.true., + Lclhcalipsoliq=.true., + Lcllcalipsoliq=.true., + Lclmcalipsoliq=.true., + Lcltcalipsoliq=.true., + Lclhcalipsoice=.true., + Lcllcalipsoice=.true., + Lclmcalipsoice=.true., + Lcltcalipsoice=.true., + Lclhcalipsoun=.true., + Lcllcalipsoun=.true., + Lclmcalipsoun=.true., + Lcltcalipsoun=.true., + ! CALIPSO OPAQ diagnostics + Lclopaquecalipso=.true., + Lclthincalipso=.true., + Lclzopaquecalipso=.true., + Lclcalipsoopaque=.true., + Lclcalipsothin=.true., + Lclcalipsozopaque=.true., + Lclcalipsoopacity=.true., + Lclopaquetemp=.true., + Lclthintemp=.true., + Lclzopaquetemp=.true., + Lclopaquemeanz=.true., + Lclthinmeanz=.true., + Lclthinemis=.true., + Lclopaquemeanzse=.true., + Lclthinmeanzse=.true., + Lclzopaquecalipsose=.true., + ! GROUND LIDAR diagnostics + LlidarBetaMol532gr=.true., + LcfadLidarsr532gr=.true., + Latb532gr=.true., + LclgrLidar532=.true., + LclhgrLidar532=.true., + LcllgrLidar532=.true., + LclmgrLidar532=.true., + LcltgrLidar532=.true., + ! ATLID diagnostics + LlidarBetaMol355=.true., + LcfadLidarsr355=.true., + Latb355=.true., + Lclatlid=.true., + Lclhatlid=.true., + Lcllatlid=.true., + Lclmatlid=.true., + Lcltatlid=.true., + !- ISCCP + Lalbisccp=.true., + Lboxptopisccp=.true., + Lboxtauisccp=.true., + Lpctisccp=.true., + Lclisccp=.true., + Ltauisccp=.true., + Lcltisccp=.true., + Lmeantbisccp=.true., + Lmeantbclrisccp=.true., + !- MISR + LclMISR=.true., + !- Use lidar and radar + Lclcalipso2=.true., + Lcltlidarradar=.true., + Lcloudsat_tcc=.true., + Lcloudsat_tcc2=.true., + !- These are provided for debugging or special purposes + Lfracout=.true., + LlidarBetaMol532=.true., + !- MODIS + Lcltmodis=.true., + Lclwmodis=.true., + Lclimodis=.true., + Lclhmodis=.true., + Lclmmodis=.true., + Lcllmodis=.true., + Ltautmodis=.true., + Ltauwmodis=.true., + Ltauimodis=.true., + Ltautlogmodis=.true., + Ltauwlogmodis=.true., + Ltauilogmodis=.true., + Lreffclwmodis=.true., + Lreffclimodis=.true., + Lpctmodis=.true., + Llwpmodis=.true., + Liwpmodis=.true., + Lclmodis=.true., + !- RTTOV + Lrttov_bt=.true., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aer=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_localtime=.false., ! May not be necessary at this level + Lrttov_pc=.true., + ! -CLOUDSAT precipitation frequency/occurence diagnostics + Lptradarflag0=.true., + Lptradarflag1=.true., + Lptradarflag2=.true., + Lptradarflag3=.true., + Lptradarflag4=.true., + Lptradarflag5=.true., + Lptradarflag6=.true., + Lptradarflag7=.true., + Lptradarflag8=.true., + Lptradarflag9=.true., + Lradarpia=.true., + !- CloudSat+MODIS joint diagnostics + Lwr_occfreq=.true., + Lcfodd=.true. +/ diff --git a/driver/run/cosp2_output_rttov_nl.txt b/driver/run/cosp2_output_rttov_nl.txt index fc50562f28..15524d5e67 100755 --- a/driver/run/cosp2_output_rttov_nl.txt +++ b/driver/run/cosp2_output_rttov_nl.txt @@ -141,6 +141,7 @@ Lrttov_aer=.true., ! Calculate RTTOV all-sky + cloudy-sky values Lrttov_aerparam=.false., ! Use user input aerosol optical parameters Lrttov_localtime=.false., ! May not be necessary at this level + Lrttov_pc=.false., ! -CLOUDSAT precipitation frequency/occurence diagnostics Lptradarflag0=.true., Lptradarflag1=.true., diff --git a/driver/run/cosp2_pcrttov_nl.txt b/driver/run/cosp2_pcrttov_nl.txt new file mode 100644 index 0000000000..2b6de1f74f --- /dev/null +++ b/driver/run/cosp2_pcrttov_nl.txt @@ -0,0 +1,55 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- RTTOV Filepaths + channel_filepath='rttov_channel_input_AIRS.csv' + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/' + OD_coef_filepath='rttov9pred101L/rtcoef_eos_2_airs_pcrttov_compat.H5', + aer_coef_filepath='cldaer_visir/scaercoef_eos_2_airs_cams.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_airs.H5', + PC_coef_filepath='pc/pccoef_eos_2_airs_landsea.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.false., + CO_data=.false., + CO2_data=.true., + CH4_data=.false., + ozone_data=.true., + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + N2O_mr=4.665e-07, + CO_mr=2.098e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=16, + rttov_ZenAng=0.0, ! Satellite Zenith Angle +/ diff --git a/driver/run/cosp2_rttov_nl.txt b/driver/run/cosp2_rttov_nl.txt index 7e1813967b..2abd9ac9e1 100644 --- a/driver/run/cosp2_rttov_nl.txt +++ b/driver/run/cosp2_rttov_nl.txt @@ -39,18 +39,19 @@ SO2_data=.false., N2O_data=.false., CO_data=.false., - CO2_data=.false., + CO2_data=.true., CH4_data=.false., - ozone_data=.false., - !--------------- RTTOV Trace Gas Concentrations + ozone_data=.true., + ! -------------- RTTOV Trace Gas Concentrations ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air CO2_mr=5.241e-04, CH4_mr=9.139e-07, N2O_mr=4.665e-07, CO_mr=2.098e-07, - SO2_mr=0.0, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv !-------------- RTTOV Other --------------- ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_ZenAng=50.0, ! Satellite Zenith Angle + rttov_nthreads=16, + rttov_ZenAng=0.0, ! Satellite Zenith Angle / From 8f65dfd6dd4f7488e619ddd256fb36528873e8db Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 3 May 2023 19:22:31 -0600 Subject: [PATCH 047/159] Added PC-RTTOV functionality. Not fully operational yet. Still need to figure out the segmentation error likely related to not being able to deallocate coefficients (see notes). Also need to compare with standard RTTOV output. Consider returning the indices of channels as an output as well since that is determined under the hood. --- driver/src/cosp2_io.f90 | 32 +- driver/src/cosp2_test.F90 | 59 ++- src/cosp.F90 | 178 +++++--- src/simulator/cosp_rttov_interfaceSTUB.F90 | 41 +- src/simulator/cosp_rttov_interface_v13.F90 | 108 +++-- src/simulator/rttov/cosp_rttov_v13.F90 | 448 ++++++++++++++++++++- 6 files changed, 742 insertions(+), 124 deletions(-) diff --git a/driver/src/cosp2_io.f90 b/driver/src/cosp2_io.f90 index f294daaaa2..ddf7879581 100644 --- a/driver/src/cosp2_io.f90 +++ b/driver/src/cosp2_io.f90 @@ -1495,7 +1495,26 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, lev, lon, l status = nf90_put_att(fileID,varID(154),"standard_name", "bleh") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) endif - + if (associated(cospOUT%rttov_bt_total_pc)) then + status = nf90_def_var(fileID,"rttov_bt_total_pc",nf90_float, (/dimID(1),dimID(19)/),varID(155)) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(154),"long_name","PC-RTTOV All-sky Brightness Temperature") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(154),"units", "Degrees Kelvin") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(154),"standard_name", "bleh") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_rad_total_pc)) then + status = nf90_def_var(fileID,"rttov_rad_total_pc",nf90_float, (/dimID(1),dimID(19)/),varID(156)) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(154),"long_name","PC-RTTOV All-sky Radiance") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(154),"units", "mW/cm-1/sr/m2") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(154),"standard_name", "bleh") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif ! --------------------------------------------------------------------------------------- ! Exit define mode @@ -2003,8 +2022,15 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, lev, lon, l status = nf90_put_var(fileID,varID(154),cospOUT%rttov_refl_clear) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) endif - - + if (associated(cospOUT%rttov_bt_total_pc)) then + status = nf90_put_var(fileID,varID(155),cospOUT%rttov_bt_total_pc) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_rad_total_pc)) then + status = nf90_put_var(fileID,varID(156),cospOUT%rttov_rad_total_pc) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + ! Close file status = nf90_close(fileID) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 43510a11d6..6ac3b49611 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -194,6 +194,7 @@ program cosp2_test logical :: Lrttov_aer = .false. logical :: Lrttov_aerparam = .false. logical :: Lrttov_localtime = .false. + logical :: Lrttov_pc = .false. namelist/COSP_OUTPUT/Lcfaddbze94,Ldbze94,Latb532,LcfadLidarsr532,Lclcalipso, & Lclhcalipso,Lcllcalipso,Lclmcalipso,Lcltcalipso,LparasolRefl, & Lclcalipsoliq,Lclcalipsoice,Lclcalipsoun,Lclcalipsotmp, & @@ -218,7 +219,7 @@ program cosp2_test Lreffclimodis,Lpctmodis,Llwpmodis,Liwpmodis,Lclmodis, & Lrttov_bt, Lrttov_rad, Lrttov_refl, & ! RTTOV output fields Lrttov_cld, Lrttov_cldparam,Lrttov_aer, Lrttov_aerparam, & ! RTTOV cld/aero - Lrttov_localtime, & ! RTTOV other + Lrttov_localtime,Lrttov_pc, & ! RTTOV other Lptradarflag0,Lptradarflag1,Lptradarflag2,Lptradarflag3, & Lptradarflag4,Lptradarflag5,Lptradarflag6,Lptradarflag7, & Lptradarflag8,Lptradarflag9,Lradarpia, & @@ -379,7 +380,11 @@ program cosp2_test Lrttov_rad = .false. Lrttov_refl = .false. endif - + if (Lrttov_pc) then + Lrttov_refl = .false. ! PC-RTTOV does not do reflectances + Lrttov_cld = .false. ! PC-RTTOV does not do aerosols + Lrttov_aer = .false. ! PC-RTTOV does not do clouds + endif !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -411,8 +416,8 @@ program cosp2_test 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, & - rttov_Nchannels, Lrttov_bt, Lrttov_rad, Lrttov_refl, Lrttov_cld, Lrttov_aer, & - Lrttov_cldparam, Lrttov_aerparam,rttov_input_namelist) + rttov_Nchannels, Lrttov_bt, Lrttov_rad, Lrttov_refl, Lrttov_cld, Lrttov_aer, & + Lrttov_cldparam, Lrttov_aerparam,Lrttov_pc,rttov_input_namelist) call cpu_time(driver_time(3)) !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -471,13 +476,13 @@ program cosp2_test !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if (iChunk .eq. 1) then call construct_cospIN(Nptsperit,nColumns,nLevels,cospIN) - call construct_cospstateIN(Nptsperit,nLevels,rttov_nChannels,cospstateIN) + call construct_cospstateIN(Nptsperit,nLevels,rttov_Nchannels,cospstateIN) endif if (iChunk .eq. nChunks) then call destroy_cospIN(cospIN) call destroy_cospstateIN(cospstateIN) call construct_cospIN(Nptsperit,nColumns,nLevels,cospIN) - call construct_cospstateIN(Nptsperit,nLevels,rttov_nChannels,cospstateIN) + call construct_cospstateIN(Nptsperit,nLevels,rttov_Nchannels,cospstateIN) endif call cpu_time(driver_time(4)) @@ -539,7 +544,8 @@ program cosp2_test ! Inputs not supplied in the UKMO test data cospstateIN%seaice(1:nPoints) = 0._wp - cospstateIN%month = 0 + cospstateIN%month = 0 + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Generate subcolumns and compute optical inputs. @@ -591,6 +597,8 @@ program cosp2_test call destroy_cospIN(cospIN) call destroy_cospstateIN(cospstateIN) call cosp_cleanUp() + ! Getting a segmentation fault here? Why? JKS + contains !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE subsample_and_optics @@ -1392,20 +1400,33 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& if (Lcloudsat_tcc2) allocate(x%cloudsat_tcc2(Npoints)) ! RTTOV - Only add non-total fields if clouds or aerosols are simulated - if (Lrttov_bt) then ! Brightness temp - allocate(x%rttov_bt_total(Npoints,Nchan)) - if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_bt_clear(Npoints,Nchan)) - endif - if (Lrttov_rad) then ! Radiance - allocate(x%rttov_rad_total(Npoints,Nchan)) - if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_rad_clear(Npoints,Nchan)) - if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_rad_cloudy(Npoints,Nchan)) - endif - if (Lrttov_refl) then ! Reflectance - allocate(x%rttov_refl_total(Npoints,Nchan)) - if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_refl_clear(Npoints,Nchan)) + if (Lrttov_pc) then ! Treat PC-RTTOV fields as clear-sky only for now + if (Lrttov_bt) then ! Brightness temp + allocate(x%rttov_bt_total_pc(Npoints,Nchan)) +! if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_bt_clear(Npoints,Nchan)) + endif + if (Lrttov_rad) then ! Radiance + allocate(x%rttov_rad_total_pc(Npoints,Nchan)) +! if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_rad_clear(Npoints,Nchan)) +! if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_rad_cloudy(Npoints,Nchan)) + endif + else + if (Lrttov_bt) then ! Brightness temp + allocate(x%rttov_bt_total(Npoints,Nchan)) + if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_bt_clear(Npoints,Nchan)) + endif + if (Lrttov_rad) then ! Radiance + allocate(x%rttov_rad_total(Npoints,Nchan)) + if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_rad_clear(Npoints,Nchan)) + if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_rad_cloudy(Npoints,Nchan)) + endif + if (Lrttov_refl) then ! Reflectance + allocate(x%rttov_refl_total(Npoints,Nchan)) + if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_refl_clear(Npoints,Nchan)) + endif endif + ! 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)) diff --git a/src/cosp.F90 b/src/cosp.F90 index 0f04584e32..733ba73e8e 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -51,7 +51,10 @@ MODULE MOD_COSP modis_histTauCenters,tau_binCenters, & cloudsat_preclvl,grLidar532_histBsct,atlid_histBsct USE MOD_COSP_MODIS_INTERFACE, ONLY: cosp_modis_init, modis_IN - USE MOD_COSP_RTTOV_INTERFACE, ONLY: cosp_rttov_init, cosp_rttov_simulate ! JKS + USE MOD_COSP_RTTOV_INTERFACE, ONLY: & + cosp_rttov_init, & + cosp_rttov_simulate, & + cosp_pc_rttov_simulate USE MOD_COSP_MISR_INTERFACE, ONLY: cosp_misr_init, misr_IN USE MOD_COSP_ISCCP_INTERFACE, ONLY: cosp_isccp_init, isccp_IN USE MOD_COSP_CALIPSO_INTERFACE, ONLY: cosp_calipso_init, calipso_IN @@ -295,11 +298,13 @@ MODULE MOD_COSP real(wp),pointer :: & rttov_bt_total(:,:) => null(), & ! Brightness Temperature rttov_bt_clear(:,:) => null(), & ! Brightness Temperature - rttov_rad_total(:,:) => null(), & ! Brightness Temperature - rttov_rad_clear(:,:) => null(), & ! Brightness Temperature - rttov_rad_cloudy(:,:) => null(), & ! Brightness Temperature - rttov_refl_total(:,:) => null(), & ! Brightness Temperature - rttov_refl_clear(:,:) => null() ! Brightness Temperature + rttov_rad_total(:,:) => null(), & ! Radiance + rttov_rad_clear(:,:) => null(), & ! Radiance + rttov_rad_cloudy(:,:) => null(), & ! Radiance + rttov_refl_total(:,:) => null(), & ! Reflectance + rttov_refl_clear(:,:) => null(), & ! Reflectance + rttov_bt_total_pc(:,:) => null(), & ! Brightness Temperature (PC-RTTOV) + rttov_rad_total_pc(:,:) => null() ! Radiance (PC-RTTOV) ! Joint CloudSat+MODIS simulators outputs real(wp),dimension(:,:,:,:),pointer :: & @@ -358,7 +363,8 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) Lparasol_column, & ! On/Off switch for column PARASOL simulator Lcloudsat_column, & ! On/Off switch for column CLOUDSAT simulator Lmodis_column, & ! On/Off switch for column MODIS simulator - Lrttov_column, & ! On/Off switch for column RTTOV simulator (not used) + Lrttov_column, & ! On/Off switch for column RTTOV simulator + Lrttov_pc, & ! On/Off switch for PC-RTTOV simulator Lradar_lidar_tcc, & ! On/Off switch from joint Calipso/Cloudsat product Lcloudsat_tcc, & ! Lcloudsat_tcc2, & ! @@ -445,6 +451,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) Lcloudsat_column = .false. Lmodis_column = .false. Lrttov_column = .false. + Lrttov_pc = .false. Lradar_lidar_tcc = .false. Llidar_only_freq_cloud = .false. Lcloudsat_tcc = .false. @@ -513,9 +520,16 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) associated(cospOUT%rttov_rad_clear) .or. & associated(cospOUT%rttov_rad_cloudy) .or. & associated(cospOUT%rttov_refl_total) .or. & - associated(cospOUT%rttov_refl_clear)) & + associated(cospOUT%rttov_refl_clear) .or. & + associated(cospOUT%rttov_bt_total_pc) .or. & + associated(cospOUT%rttov_rad_total_pc)) & Lrttov_column = .true. + ! PC-RTTOV + if (associated(cospOUT%rttov_bt_total_pc) .or. & + associated(cospOUT%rttov_rad_total_pc)) & + Lrttov_pc = .true. + ! Set flag to deallocate rttov types (only done on final call to simulator) if (size(cospOUT%isccp_meantb) .eq. stop_idx) lrttov_cleanUp = .true. @@ -1541,15 +1555,22 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! RTTOV if (Lrttov_column) then - ! Allocate memory for the outputs - I won't need all of these in every situation - allocate(rttov_bt_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky brightness temp - allocate(rttov_bt_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky brightness temp - allocate(rttov_rad_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky brightness temp - allocate(rttov_rad_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky brightness temp - allocate(rttov_rad_cloudy(rttovIN%Npoints,rttovIN%Nchannels)) ! cloudy-sky brightness temp - allocate(rttov_refl_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky Bi-directional reflectance factor - allocate(rttov_refl_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky Bi-directional reflectance factor - + ! Allocate memory for the outputs - I won't need all of these in every situation. + ! Only allocate clear-sky memory when PC-RTTOV is run. + if (Lrttov_pc) then +! allocate(rttov_bt_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky brightness temp +! allocate(rttov_rad_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky brightness temp + allocate(rttov_bt_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky brightness temp + allocate(rttov_rad_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky brightness temp + else + allocate(rttov_bt_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky brightness temp + allocate(rttov_bt_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky brightness temp + allocate(rttov_rad_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky brightness temp + allocate(rttov_rad_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky brightness temp + allocate(rttov_rad_cloudy(rttovIN%Npoints,rttovIN%Nchannels)) ! cloudy-sky brightness temp + allocate(rttov_refl_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky Bi-directional reflectance factor + allocate(rttov_refl_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky Bi-directional reflectance factor + endif ! JKS new RTTOV subroutine for v13 called from the RTTOV interface. call cpu_time(driver_time(3)) ! Run simulator @@ -1562,20 +1583,27 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) print*,'Time to run RTTOV: ',driver_time(4)-driver_time(3) ! Write to cospOUT - if (associated(cospOUT%rttov_bt_total)) & - cospOUT%rttov_bt_total(ij:ik,:) = rttov_bt_total - if (associated(cospOUT%rttov_bt_clear)) & - cospOUT%rttov_bt_clear(ij:ik,:) = rttov_bt_clear - if (associated(cospOUT%rttov_rad_total)) & - cospOUT%rttov_rad_total(ij:ik,:) = rttov_rad_total - if (associated(cospOUT%rttov_rad_clear)) & - cospOUT%rttov_rad_clear(ij:ik,:) = rttov_rad_clear - if (associated(cospOUT%rttov_rad_cloudy)) & - cospOUT%rttov_rad_cloudy(ij:ik,:) = rttov_rad_cloudy - if (associated(cospOUT%rttov_refl_total)) & - cospOUT%rttov_refl_total(ij:ik,:) = rttov_refl_total - if (associated(cospOUT%rttov_refl_clear)) & - cospOUT%rttov_refl_clear(ij:ik,:) = rttov_refl_clear + if (Lrttov_pc) then + if (associated(cospOUT%rttov_bt_total_pc)) & + cospOUT%rttov_bt_total_pc(ij:ik,:) = rttov_bt_total + if (associated(cospOUT%rttov_rad_total_pc)) & + cospOUT%rttov_rad_total_pc(ij:ik,:) = rttov_rad_total + else + if (associated(cospOUT%rttov_bt_total)) & + cospOUT%rttov_bt_total(ij:ik,:) = rttov_bt_total + if (associated(cospOUT%rttov_bt_clear)) & + cospOUT%rttov_bt_clear(ij:ik,:) = rttov_bt_clear + if (associated(cospOUT%rttov_rad_total)) & + cospOUT%rttov_rad_total(ij:ik,:) = rttov_rad_total + if (associated(cospOUT%rttov_rad_clear)) & + cospOUT%rttov_rad_clear(ij:ik,:) = rttov_rad_clear + if (associated(cospOUT%rttov_rad_cloudy)) & + cospOUT%rttov_rad_cloudy(ij:ik,:) = rttov_rad_cloudy + if (associated(cospOUT%rttov_refl_total)) & + cospOUT%rttov_refl_total(ij:ik,:) = rttov_refl_total + if (associated(cospOUT%rttov_refl_clear)) & + cospOUT%rttov_refl_clear(ij:ik,:) = rttov_refl_clear + endif ! Free up memory from output (if necessary) if (allocated(rttov_bt_total)) deallocate(rttov_bt_total) @@ -1584,7 +1612,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (allocated(rttov_rad_clear)) deallocate(rttov_rad_clear) if (allocated(rttov_rad_cloudy)) deallocate(rttov_rad_cloudy) if (allocated(rttov_refl_total)) deallocate(rttov_refl_total) - if (allocated(rttov_refl_clear)) deallocate(rttov_refl_clear) + if (allocated(rttov_refl_clear)) deallocate(rttov_refl_clear) endif print*,'Lrttov_column successful' ! jks @@ -1809,14 +1837,15 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La isccp_top_height, isccp_top_height_direction, surface_radar, rcfg, lusevgrid, & luseCSATvgrid, Nvgrid, Nlevels, cloudsat_micro_scheme, & NchanIN, Lrttov_bt, Lrttov_rad, Lrttov_refl, & - Lrttov_cld, Lrttov_aer, Lrttov_cldparam, Lrttov_aerparam, & + Lrttov_cld, Lrttov_aer, Lrttov_cldparam, Lrttov_aerparam, Lrttov_pc, & rttov_input_namelist) ! INPUTS logical,intent(in) :: Lisccp,Lmodis,Lmisr,Lcloudsat,Lcalipso,LgrLidar532,Latlid,Lparasol,Lrttov logical,intent(in) :: & Lrttov_bt, Lrttov_rad, Lrttov_refl, & - Lrttov_cld, Lrttov_aer, Lrttov_cldparam, Lrttov_aerparam + Lrttov_cld, Lrttov_aer, Lrttov_cldparam, Lrttov_aerparam, & + Lrttov_pc ! JKS to-do integer,intent(in) :: & cloudsat_use_gas_abs, & ! @@ -1825,8 +1854,11 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La isccp_top_height_direction, & ! Nlevels, & ! Nvgrid, & ! Number of levels for new L3 grid - surface_radar, & ! - NchanIN ! RTTOV arguments here and below JKS + surface_radar ! +! surface_radar, & ! +! NchanIN ! RTTOV arguments here and below JKS + integer,intent(inout) :: & + NchanIN real(wp),intent(in) :: & cloudsat_radar_freq, & ! cloudsat_k2 ! @@ -1893,7 +1925,7 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La Lrttov_bt,Lrttov_rad,Lrttov_refl, & Lrttov_cld,Lrttov_aer, & Lrttov_cldparam,Lrttov_aerparam, & - rttov_input_namelist) + Lrttov_pc,rttov_input_namelist) call cpu_time(driver_time(2)) print*,'Time to run cosp_rttov_init: ',driver_time(2)-driver_time(1) endif @@ -2645,13 +2677,15 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, endif if (.not. alloc_status) then Lrttov_column = .false. - if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF endif endif @@ -2755,7 +2789,9 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:)= R_UNDEF if (associated(cospOUT%isccp_totalcldarea)) cospOUT%isccp_totalcldarea(:) = R_UNDEF if (associated(cospOUT%isccp_meantb)) cospOUT%isccp_meantb(:) = R_UNDEF if (associated(cospOUT%isccp_meantbclr)) cospOUT%isccp_meantbclr(:) = R_UNDEF @@ -2804,6 +2840,8 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:)= R_UNDEF if (associated(cospOUT%isccp_totalcldarea)) cospOUT%isccp_totalcldarea(:) = R_UNDEF if (associated(cospOUT%isccp_meantb)) cospOUT%isccp_meantb(:) = R_UNDEF if (associated(cospOUT%isccp_meantbclr)) cospOUT%isccp_meantbclr(:) = R_UNDEF @@ -2829,6 +2867,14 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Latlid_column = .false. LgrLidar532_column = .false. if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:)= R_UNDEF if (associated(cospOUT%isccp_totalcldarea)) cospOUT%isccp_totalcldarea(:) = R_UNDEF if (associated(cospOUT%isccp_meantb)) cospOUT%isccp_meantb(:) = R_UNDEF if (associated(cospOUT%isccp_meantbclr)) cospOUT%isccp_meantbclr(:) = R_UNDEF @@ -2911,7 +2957,9 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:)= R_UNDEF if (associated(cospOUT%isccp_totalcldarea)) cospOUT%isccp_totalcldarea(:) = R_UNDEF if (associated(cospOUT%isccp_meantb)) cospOUT%isccp_meantb(:) = R_UNDEF if (associated(cospOUT%isccp_meantbclr)) cospOUT%isccp_meantbclr(:) = R_UNDEF @@ -2994,7 +3042,9 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF if (associated(cospOUT%calipso_cfad_sr)) cospOUT%calipso_cfad_sr(:,:,:) = R_UNDEF if (associated(cospOUT%calipso_lidarcld)) cospOUT%calipso_lidarcld(:,:) = R_UNDEF if (associated(cospOUT%calipso_lidarcldphase)) cospOUT%calipso_lidarcldphase(:,:,:) = R_UNDEF @@ -3035,7 +3085,9 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF if (associated(cospOUT%calipso_cfad_sr)) cospOUT%calipso_cfad_sr(:,:,:) = R_UNDEF if (associated(cospOUT%calipso_lidarcld)) cospOUT%calipso_lidarcld(:,:) = R_UNDEF if (associated(cospOUT%calipso_lidarcldphase)) cospOUT%calipso_lidarcldphase(:,:,:) = R_UNDEF @@ -3065,6 +3117,8 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:)= R_UNDEF if (associated(cospOUT%isccp_totalcldarea)) cospOUT%isccp_totalcldarea(:) = R_UNDEF if (associated(cospOUT%isccp_meantb)) cospOUT%isccp_meantb(:) = R_UNDEF if (associated(cospOUT%isccp_meantbclr)) cospOUT%isccp_meantbclr(:) = R_UNDEF @@ -3090,6 +3144,8 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF endif if (cospgridIN%ch4 .lt. 0) then nError=nError+1 @@ -3102,6 +3158,8 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF endif if (cospgridIN%n2o .lt. 0) then nError=nError+1 @@ -3114,6 +3172,8 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF endif if (cospgridIN%co.lt. 0) then nError=nError+1 @@ -3126,6 +3186,8 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF endif if (any(cospgridIN%o3 .lt. 0)) then nError=nError+1 @@ -3138,6 +3200,8 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF endif if (any(cospgridIN%emis_sfc .lt. 0. .OR. cospgridIN%emis_sfc .gt. 1)) then nError=nError+1 @@ -3150,6 +3214,8 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF endif if (any(cospgridIN%refl_sfc .lt. 0. .OR. cospgridIN%refl_sfc .gt. 1)) then nError=nError+1 @@ -3162,10 +3228,13 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF endif if (any(cospgridIN%u_sfc .lt. -100. .OR. cospgridIN%u_sfc .gt. 100.)) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospIN%u_sfc contains values out of range' + Lrttov_column = .false. if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF @@ -3173,11 +3242,13 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF - Lrttov_column = .false. + if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF endif if (any(cospgridIN%v_sfc .lt. -100. .OR. cospgridIN%v_sfc .gt. 100.)) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospIN%v_sfc contains values out of range' + Lrttov_column = .false. if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF @@ -3185,19 +3256,22 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF - Lrttov_column = .false. + if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF endif if (any(cospgridIN%lat .lt. -90 .OR. cospgridIN%lat .gt. 90)) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospIN%lat contains values out of range' + Lrttov_column = .false. if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF - Lrttov_column = .false. + if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF endif endif diff --git a/src/simulator/cosp_rttov_interfaceSTUB.F90 b/src/simulator/cosp_rttov_interfaceSTUB.F90 index 52ad33eb27..4f28c5c47d 100644 --- a/src/simulator/cosp_rttov_interfaceSTUB.F90 +++ b/src/simulator/cosp_rttov_interfaceSTUB.F90 @@ -43,7 +43,7 @@ MODULE MOD_COSP_RTTOV_INTERFACE !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, & Lrttov_cld,Lrttov_aer,Lrttov_cldparam,Lrttov_aerparam, & - rttov_input_namelist) + Lrttov_pc,rttov_input_namelist,rttov_pc_nchan) integer,intent(in) :: & NchanIN, & nlevels @@ -56,14 +56,18 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, Lrttov_cld, & Lrttov_aer, & Lrttov_cldparam, & - Lrttov_aerparam - + Lrttov_aerparam, & + Lrttov_pc + ! JKS testing using a RTTOV input namelist here ! (default cosp_rttov namelist is set in cosp.F90) character(len=256),intent(in) :: rttov_input_namelist - - print*,'Running COSP_RTTOV_INIT from STUB files.', & - 'To run RTTOV, compile COSP after setting environmental variable "RTTOV"' + + integer,intent(inout),optional :: & ! JKS return number of channels determined by ipcreg + rttov_pc_nchan + + print*,'Running COSP_RTTOV_INIT from STUB files.', & + 'To run RTTOV, compile COSP after setting environmental variable "RTTOV"' END SUBROUTINE COSP_RTTOV_INIT @@ -98,6 +102,31 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, END SUBROUTINE COSP_RTTOV_SIMULATE + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE cosp_pc_rttov_simulate + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,lCleanup, & ! Inputs + bt_total,rad_total, & ! Outputs + error) + + type(rttov_in),intent(in) :: & + rttovIN + logical,intent(in) :: & + lCleanup ! Flag to determine whether to deallocate RTTOV types + real(wp),intent(inout),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! + bt_total, & ! All-sky + rad_total ! All-sky + character(len=128) :: & + error ! Error messages (only populated if error encountered) + + print*,'Running COSP_PC_RTTOV_SIMULATE from STUB files.', & + 'To run RTTOV, compile COSP after setting environmental variable "RTTOV"' + ! How do I want the interface to function? How should it to be consistent with the rest of COSP? + + END SUBROUTINE COSP_PC_RTTOV_SIMULATE + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! END MODULE ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 5bcc24585e..525e61d7ec 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -37,8 +37,8 @@ MODULE MOD_COSP_RTTOV_INTERFACE do_rttov_bt,do_rttov_rad,do_rttov_refl, & do_rttov_cld,do_rttov_aer,do_rttov_pcrttov, & rttov_cld_optparam,rttov_aer_optparam, & - rttov_direct_nthreads,rttovDir,pc_coef_filepath, & - so2,ch4,co,co2,n2o,zenang,npcscores + rttov_direct_nthreads,rttovDir,PC_coef_filepath, & + so2,ch4,co,co2,n2o,zenang,npcscores,predictindex ! rttov_const contains useful RTTOV constants @@ -61,6 +61,7 @@ MODULE MOD_COSP_RTTOV_INTERFACE #include "rttov_read_coefs.interface" #include "rttov_user_options_checkinput.interface" #include "rttov_print_opts.interface" +#include "rttov_get_pc_predictindex.interface" ! RTTOV variables/structures !==================== @@ -78,9 +79,11 @@ MODULE MOD_COSP_RTTOV_INTERFACE !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, & Lrttov_cld,Lrttov_aer,Lrttov_cldparam,Lrttov_aerparam, & - rttov_input_namelist) + Lrttov_pc,rttov_input_namelist) + integer,intent(inout) :: & + NchanIN integer,intent(in) :: & - NchanIN, & +! NchanIN, & nlevels logical,intent(in) :: & Lrttov_bt, & @@ -89,7 +92,8 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, Lrttov_cld, & Lrttov_aer, & Lrttov_cldparam, & - Lrttov_aerparam + Lrttov_aerparam, & + Lrttov_pc ! JKS testing using a RTTOV input namelist here ! (default cosp_rttov namelist is set in cosp.F90) @@ -136,6 +140,7 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, ! Read RTTOV namelist fields namelist/RTTOV_INPUT/channel_filepath,rttov_srcDir,rttov_coefDir, & OD_coef_filepath,aer_coef_filepath,cld_coef_filepath, & + PC_coef_filepath, & SO2_mr,N2O_mr,CO_mr,CH4_mr,CO2_mr,rttov_ZenAng, & ! Mixing ratios SO2_data,N2O_data,CO_data,CH4_data,CO2_data,ozone_data, & rttov_nthreads @@ -174,6 +179,7 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, do_rttov_refl = Lrttov_refl do_rttov_cld = Lrttov_cld do_rttov_aer = Lrttov_aer + do_rttov_pcrttov = Lrttov_pc rttov_cld_optparam = Lrttov_cldparam rttov_aer_optparam = Lrttov_aerparam @@ -197,7 +203,7 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, ! General configuration options opts%config%do_checkinput = .true. opts%config%apply_reg_limits = .false. ! True in v11 - opts%config%verbose = .true. + opts%config%verbose = .false. ! JKS suppress for now opts%config%opdep13_gas_clip = .true. ! General Radiative Transfer Options @@ -279,7 +285,7 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, ! Developer options that may be useful: opts%dev%do_opdep_calc = .true. - + !! JKS - Hardcode in some options that will eventually be moved to the namelist ipcbnd = 1 ! This should always be one per the User Guide ipcreg = 2 ! 300 predictors (channels). See RTTOV user guide Table 31. @@ -317,7 +323,6 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, ! JKS To-do: include opts_scatt settings (user guide pg 161) - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 2. Read coefficients (from RTTOV example files) ! ------------------------------------------------------ @@ -325,7 +330,7 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Construct optical depth and cloud coefficient files - pc_coef_filepath = 'test' +! PC_coef_filepath = 'test' ! rttovDir should be "/glade/u/home/jonahshaw/w/RTTOV/" and is defined in cosp_config.F90 OD_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(OD_coef_filepath) @@ -340,12 +345,12 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, if (do_rttov_pcrttov) then ! PC-RTTOV cannot handle cloud, some aerosols - pc_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(pc_coef_filepath) - + PC_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(PC_coef_filepath) + call rttov_read_coefs(errorstatus, coef_rttov, opts, & file_coef=OD_coef_filepath, & - file_scaer=aer_coef_filepath, & ! Needs to be PC-RTTOV compatible - file_pccoef=pc_coef_filepath) +! file_scaer=aer_coef_filepath, & ! Needs to be PC-RTTOV compatible + file_pccoef=PC_coef_filepath) else ! Read optical depth and cloud coefficient files together call rttov_read_coefs(errorstatus, coef_rttov, opts, & file_coef=OD_coef_filepath, & @@ -364,7 +369,14 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, call rttov_user_options_checkinput(errorstatus, opts, coef_rttov) ! We aren't checking an allocation steps so this seems more appropriate. - call rttov_error('error in rttov options' , lalloc = .false.) + call rttov_error('error in rttov options' , lalloc = .false.) + + if (do_rttov_pcrttov) then + nullify(predictindex) + call rttov_get_pc_predictindex(errorstatus, opts, predictindex, file_pccoef=PC_coef_filepath) + call rttov_error('rttov_get_pc_predictindex fatal error' , lalloc = .false.) + NchanIN = SIZE(predictindex) ! Correct the number of channels + endif ! subsub routines contains @@ -396,7 +408,46 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, bt_total,bt_clear, & ! Brightness Temp Outputs rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs refl_total,refl_clear, & ! Reflectance Outputs - error) + error) + + type(rttov_in),intent(in) :: & + rttovIN + logical,intent(in) :: & + lCleanup ! Flag to determine whether to deallocate RTTOV types + real(wp),intent(inout),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! + bt_total, & ! All-sky + bt_clear, & ! Clear-sky + rad_total, & ! All-sky + rad_clear, & ! Clear-sky + rad_cloudy, & ! Cloudy-sky + refl_total, & ! All-sky + refl_clear ! Clear-sky + character(len=128) :: & + error ! Error messages (only populated if error encountered) + + ! Check options to determine if the principal component approach should be run + if (opts % rt_ir % pc % addpc) then + call COSP_PC_RTTOV_SIMULATE(rttovIN,lCleanup, & + bt_total,rad_total, & + error) + else + call COSP_REG_RTTOV_SIMULATE(rttovIN,lCleanup, & + bt_total,bt_clear, & + rad_total,rad_clear,rad_cloudy, & + refl_total,refl_clear, & + error) + endif + + END SUBROUTINE COSP_RTTOV_SIMULATE + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE cosp_rttov_simulate - Call regular subroutines in mod_cosp_rttov to run RTTOV + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,lCleanup, & ! Inputs + bt_total,bt_clear, & ! Brightness Temp Outputs + rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs + refl_total,refl_clear, & ! Reflectance Outputs + error) use mod_cosp_rttov, only: & cosp_rttov_allocate, & @@ -466,11 +517,11 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, ! print*,'Total RTTOV run time: ',driver_time(8)-driver_time(1) - END SUBROUTINE COSP_RTTOV_SIMULATE + END SUBROUTINE COSP_REG_RTTOV_SIMULATE !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE cosp_rttov_simulate - Call subroutines in mod_cosp_rttov to run RTTOV + ! SUBROUTINE cosp_pc_rttov_simulate - Call subroutines in mod_cosp_rttov to run RTTOV !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,lCleanup, & ! Inputs bt_total,rad_total, & ! Outputs @@ -483,6 +534,7 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,lCleanup, cosp_pc_rttov_call_direct, & cosp_pc_rttov_save_output, & cosp_pc_rttov_deallocate_profiles, & + cosp_rttov_deallocate_coefs2, & ! JKS check cosp_rttov_deallocate_coefs type(rttov_in),intent(in) :: & @@ -501,21 +553,22 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,lCleanup, ! print*,'cosp_rttov_allocate begin' ! jks call cpu_time(driver_time(1)) call cosp_pc_rttov_allocate(rttovIN) -! print*,'cosp_rttov_allocate successful' ! jks + print*,'cosp_pc_rttov_allocate successful' ! jks call cpu_time(driver_time(2)) call cosp_rttov_construct_profiles(rttovIN) -! print*,'cosp_rttov_construct_profiles successful' ! jks + print*,'cosp_rttov_construct_profiles successful' ! jks call cpu_time(driver_time(3)) call cosp_pc_rttov_setup_emissivity() -! print*,'cosp_rttov_setup_emissivity_reflectance successful' ! jks + print*,'cosp_pc_rttov_setup_emissivity successful' ! jks call cpu_time(driver_time(4)) call cosp_pc_rttov_call_direct() -! print*,'cosp_rttov_call_direct successful' ! jks + print*,'cosp_pc_rttov_call_direct successful' ! jks call cpu_time(driver_time(5)) call cosp_pc_rttov_save_output(rttovIN, & bt_total,rad_total) -! print*,'cosp_rttov_save_and_deallocate_profiles successful' ! jks + + print*,'cosp_pc_rttov_save_output successful' ! jks call cpu_time(driver_time(6)) call cosp_pc_rttov_deallocate_profiles(rttovIN) call cpu_time(driver_time(7)) @@ -529,10 +582,13 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,lCleanup, ! Deallocate the coefficient files if directed if (lCleanup) then - call cpu_time(driver_time(8)) - call cosp_rttov_deallocate_coefs() - call cpu_time(driver_time(9)) - print*,'Time to run "cosp_rttov_deallocate_coefs": ',driver_time(9)-driver_time(8) + print*,'NOT DEALLOCATING COEFS WHEN RUNNING PC-RTTOV. Unresolved Deallocation Error in "dealloc_fast_coefs" when using AIRS files.' + ! See error in "dealloc_fast_coefs" when using AIRS files. +! call cpu_time(driver_time(8)) +! call cosp_rttov_deallocate_coefs2() +! call cosp_rttov_deallocate_coefs() +! call cpu_time(driver_time(9)) +! print*,'Time to run "cosp_rttov_deallocate_coefs": ',driver_time(9)-driver_time(8) endif ! print*,'Total RTTOV run time: ',driver_time(8)-driver_time(1) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index d430830f55..89f67e3404 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -74,10 +74,15 @@ module mod_cosp_rttov #include "rttov_alloc_direct.interface" #include "rttov_init_emis_refl.interface" #include "rttov_user_options_checkinput.interface" -#include "rttov_get_pc_predictindex.interface" #include "rttov_print_opts.interface" #include "rttov_print_profile.interface" +! checking inputs +#include "rttov_dealloc_coef_scatt.interface" +#include "rttov_dealloc_coef.interface" +#include "rttov_dealloc_coef_pccomp.interface" + + ! Includes when directly inputting cloud optical parameters #include "rttov_init_opt_param.interface" #include "rttov_bpr_init.interface" @@ -124,8 +129,9 @@ module mod_cosp_rttov real(wp) :: zenang = 0._wp ! NADIR default character(len=256) :: & - rttovDir, & ! Directory for the RTTOV source code - pc_coef_filepath + rttovDir ! Directory for the RTTOV source code + + character(len=256) :: PC_coef_filepath = '' ! JKS - KISS ! type(rttov_options_scatt) :: & @@ -154,7 +160,6 @@ module mod_cosp_rttov INTEGER(KIND=jpim) :: alloc_status(60) ! JKS additional variables used in PC-RTTOV -! INTEGER(KIND=jpim) :: ipcbnd, ipcreg, npcscores ! JKS delete? INTEGER(KIND=jpim), POINTER :: predictindex(:) INTEGER(KIND=jpim) :: nchannels_rec, nchannels_comp, npcscores INTEGER(KIND=jpim) :: lo, hi @@ -312,22 +317,15 @@ subroutine cosp_pc_rttov_allocate(rttovIN & ! ------------------------------------------------------ ! Largely from RTTOV documentation. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - ! Determine the size of the chanprof array (the number of PC-RTTOV predictor channels). - ! This is determined by ipcbnd and ipcreg and is the same for all simulated profiles. - ! The channel list in chanprof is the set of predictor channels for the PC scheme. - ! The channel list may be obtained using the rttov_get_pc_predictindex subroutine: - - nullify(predictindex) - call rttov_get_pc_predictindex(errorstatus, opts, predictindex, file_pccoef=pc_coef_filepath) - call rttov_error('rttov_get_pc_predictindex fatal error' , lalloc = .false.) ! IF (errorstatus /= errorstatus_success) THEN ! WRITE(*,*) 'rttov_get_pc_predictindex fatal error' ! CALL rttov_exit(errorstatus) ! ENDIF - nchannels_rec = rttovIN%nChannels ! Number of channels to reconstruct indicated in namelist. +! JKS clean this up when done. +! nchannels_rec = rttovIN%nChannels ! Number of channels to reconstruct indicated in namelist. + nchannels_rec = SIZE(predictindex) ! Number of channels to reconstruct indicated in namelist. nchannels_comp = SIZE(predictindex) ! Number of channels to compute is determined by ipcreg in init. nchanprof = nchannels_comp * rttovIN%nPoints ! Size of chanprof array is total number of channels over all profiles. @@ -662,7 +660,7 @@ end subroutine cosp_rttov_call_direct subroutine cosp_pc_rttov_call_direct() if (rttov_direct_nthreads <= 1) then - print*,'Calling rttov_direct' + print*,'Calling rttov_direct (PC-RTTOV)' call rttov_direct( & errorstatus, &! out error flag chanprof, &! in channel and profile index structure @@ -676,7 +674,7 @@ subroutine cosp_pc_rttov_call_direct() pccomp = pccomp, &! inout computed PC scores channels_rec = channels_rec) ! in reconstructed channel list else - print*,'Calling rttov_parallel_direct' + print*,'Calling rttov_parallel_direct (PC-RTTOV)' call rttov_parallel_direct( & errorstatus, &! out error flag chanprof, &! in channel and profile index structure @@ -717,9 +715,10 @@ subroutine cosp_rttov_save_output(rttovIN, & refl_clear ! Documentation for RTTOV radiance structure in RTTOV User Guide pg 166 - + ! Only save output if appropriate if (do_rttov_bt) then + print*,'trying' bt_total(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & transpose(reshape(radiance%bt(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) endif @@ -747,6 +746,7 @@ subroutine cosp_rttov_save_output(rttovIN, & bt_clear(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & transpose(reshape(radiance%refl_clear(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) endif + print*,'done.' end subroutine cosp_rttov_save_output @@ -772,6 +772,9 @@ subroutine cosp_pc_rttov_save_output(rttovIN, & rad_total ! Documentation for RTTOV radiance structure in RTTOV User Guide pg 166 + + print*,'do_rttov_bt: ',do_rttov_bt + print*,'do_rttov_rad: ',do_rttov_rad ! Only save output if appropriate if (do_rttov_bt) then @@ -865,7 +868,7 @@ end subroutine cosp_pc_rttov_deallocate_profiles subroutine cosp_rttov_deallocate_coefs() - + call rttov_dealloc_coefs(errorstatus, coef_rttov) if (errorstatus /= errorstatus_success) then write(*,*) 'coefs deallocation error' @@ -873,4 +876,413 @@ subroutine cosp_rttov_deallocate_coefs() end subroutine cosp_rttov_deallocate_coefs + +! Other subroutines used for bug chasing + subroutine cosp_rttov_deallocate_coefs2() + +! print*,'dealloc2 test(1)' + CALL rttov_dealloc_coef_scatt(errorstatus, coef_rttov%coef_scatt) +! THROW(err.NE.0) + +! print*,'dealloc2 test(2)' + IF (ASSOCIATED(coef_rttov%coef_pccomp%pcreg)) THEN + print*,'running: "rttov_dealloc_coef_pccomp"' + CALL rttov_dealloc_coef_pccomp(errorstatus, coef_rttov%coef_pccomp) +! THROW(err.NE.0) + ENDIF + +! IF (ASSOCIATED(coefs%coef_mfasis_cld%lut)) THEN +! CALL rttov_dealloc_coef_mfasis(err, coefs%coef_mfasis_cld) +! THROW(err.NE.0) +! ENDIF + +! IF (ASSOCIATED(coefs%coef_mfasis_aer%lut)) THEN +! CALL rttov_dealloc_coef_mfasis(err, coefs%coef_mfasis_aer) +! THROW(err.NE.0) +! ENDIF + +! IF (ASSOCIATED(coefs%coef_mfasis_nn%nn)) THEN +! CALL rttov_dealloc_coef_mfasis_nn(err, coefs%coef_mfasis_nn) +! THROW(err.NE.0) +! ENDIF + +! IF (ASSOCIATED(coefs%coef_htfrtc%p)) THEN +! CALL rttov_dealloc_coef_htfrtc(err, coefs%coef_htfrtc) +! THROW(err.NE.0) +! ENDIF + + print*,'dealloc2 test(3)' + CALL rttov_dealloc_coef2(errorstatus, coef_rttov%coef) +! CALL rttov_dealloc_coef(errorstatus, coef_rttov%coef) +! THROW(err.NE.0) + + print*,'dealloc2 test(4)' + coef_rttov%initialised = .FALSE. + print*,'dealloc2 test(5)' + + end subroutine cosp_rttov_deallocate_coefs2 + + + SUBROUTINE rttov_dealloc_coef2(err, coef) + !INTF_OFF +#include "throw.h" + !INTF_ON + USE rttov_types, ONLY : rttov_coef + USE parkind1, ONLY : jpim + IMPLICIT NONE + + INTEGER(KIND=jpim), INTENT(OUT) :: err + TYPE(rttov_coef), INTENT(INOUT) :: coef + !INTF_END +#include "rttov_nullify_coef.interface" +#include "rttov_errorreport.interface" + !- End of header -------------------------------------------------------- + + TRY + + print*,'dealloc_coef test(0)' + + IF (ASSOCIATED(coef%fmv_gas_id)) DEALLOCATE (coef%fmv_gas_id, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%fmv_gas_pos)) DEALLOCATE (coef%fmv_gas_pos, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%fmv_var)) DEALLOCATE (coef%fmv_var, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%fmv_coe)) DEALLOCATE (coef%fmv_coe, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%fmv_ncorr)) DEALLOCATE (coef%fmv_ncorr, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%fmv_lvl)) DEALLOCATE (coef%fmv_lvl, STAT = err) + THROW(err.NE.0) + + print*,'dealloc_coef test(1)' + + IF (ASSOCIATED(coef%ff_ori_chn)) DEALLOCATE (coef%ff_ori_chn, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%ff_val_chn)) DEALLOCATE (coef%ff_val_chn, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%ff_cwn)) DEALLOCATE (coef%ff_cwn, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%ff_bco)) DEALLOCATE (coef%ff_bco, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%ff_bcs)) DEALLOCATE (coef%ff_bcs, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%ff_gam)) DEALLOCATE (coef%ff_gam, STAT = err) + THROW(err.NE.0) + + print*,'dealloc_coef test(2)' + + IF (ASSOCIATED(coef%fastem_polar)) DEALLOCATE (coef%fastem_polar, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%pol_phi)) DEALLOCATE (coef%pol_phi, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%pol_fac_v)) DEALLOCATE (coef%pol_fac_v, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%pol_fac_h)) DEALLOCATE (coef%pol_fac_h, STAT = err) + THROW(err.NE.0) + + print*,'dealloc_coef test(3)' + + IF (ASSOCIATED(coef%ssirem_a0)) DEALLOCATE (coef%ssirem_a0, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%ssirem_a1)) DEALLOCATE (coef%ssirem_a1, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%ssirem_a2)) DEALLOCATE (coef%ssirem_a2, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%ssirem_xzn1)) DEALLOCATE (coef%ssirem_xzn1, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%ssirem_xzn2)) DEALLOCATE (coef%ssirem_xzn2, STAT = err) + THROW(err.NE.0) + + print*,'dealloc_coef test(4)' + + IF (ASSOCIATED(coef%iremis_coef)) DEALLOCATE (coef%iremis_coef, STAT = err) + THROW(err.NE.0) + + + IF (ASSOCIATED(coef%ref_prfl_p)) DEALLOCATE (coef%ref_prfl_p, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%ref_prfl_t)) DEALLOCATE (coef%ref_prfl_t, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%ref_prfl_mr)) DEALLOCATE (coef%ref_prfl_mr, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%bkg_prfl_mr)) DEALLOCATE (coef%bkg_prfl_mr, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%lim_prfl_p)) DEALLOCATE (coef%lim_prfl_p, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%env_prfl_tmax)) DEALLOCATE (coef%env_prfl_tmax, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%env_prfl_tmin)) DEALLOCATE (coef%env_prfl_tmin, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%env_prfl_gmin)) DEALLOCATE (coef%env_prfl_gmin, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%env_prfl_gmax)) DEALLOCATE (coef%env_prfl_gmax, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%lim_prfl_tmax)) DEALLOCATE (coef%lim_prfl_tmax, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%lim_prfl_tmin)) DEALLOCATE (coef%lim_prfl_tmin, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%lim_prfl_gmin)) DEALLOCATE (coef%lim_prfl_gmin, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%lim_prfl_gmax)) DEALLOCATE (coef%lim_prfl_gmax, STAT = err) + THROW(err.NE.0) + + print*,'coef%fmv_gas: ',coef%fmv_gas + + print*,'dealloc_coef test(5)' +! print*,'coef%thermal: ',coef%thermal + CALL dealloc_fast_coefs(err, coef%thermal) + THROW(err.NE.0) + print*,'dealloc_coef test(5a)' + + CALL dealloc_fast_coefs(err, coef%thermal_corr) + THROW(err.NE.0) + print*,'dealloc_coef test(5b)' + + IF (coef%solarcoef) THEN + print*,'dealloc_coef test(5c)' + CALL dealloc_fast_coefs(err, coef%solar) + THROW(err.NE.0) + + print*,'dealloc_coef test(5d)' + CALL dealloc_fast_coefs(err, coef%solar_corr) + THROW(err.NE.0) + ENDIF + + print*,'dealloc_coef test(6)' + + IF (ASSOCIATED(coef%bounds)) DEALLOCATE (coef%bounds, STAT = err) + THROW(err.NE.0) + + + IF (coef%nltecoef) THEN + IF (ASSOCIATED(coef%nlte_coef%coef)) DEALLOCATE(coef%nlte_coef%coef, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%nlte_coef%sol_zen_angle)) DEALLOCATE(coef%nlte_coef%sol_zen_angle, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%nlte_coef%sat_zen_angle)) DEALLOCATE(coef%nlte_coef%sat_zen_angle, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%nlte_coef%cos_sol)) DEALLOCATE(coef%nlte_coef%cos_sol, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%nlte_coef%sec_sat)) DEALLOCATE(coef%nlte_coef%sec_sat, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%nlte_coef)) DEALLOCATE(coef%nlte_coef, STAT = err) + THROW(err.NE.0) + ENDIF + + print*,'dealloc_coef test(7)' + + IF (coef%pmc_shift) THEN + IF (ASSOCIATED(coef%pmc_ppmc)) DEALLOCATE(coef%pmc_ppmc, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%pmc_coef)) DEALLOCATE(coef%pmc_coef, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%pmc_pnominal)) DEALLOCATE(coef%pmc_pnominal, STAT = err) + THROW(err.NE.0) + ENDIF + + print*,'dealloc_coef test(8)' + + IF (ASSOCIATED(coef%planck1)) DEALLOCATE (coef%planck1, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%planck2)) DEALLOCATE (coef%planck2, STAT = err) + THROW(err.NE.0) + + + IF (ASSOCIATED(coef%frequency_ghz)) DEALLOCATE (coef%frequency_ghz, STAT = err) + THROW(err.NE.0) + + + IF (ASSOCIATED(coef%dp)) DEALLOCATE (coef%dp, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%dpp)) DEALLOCATE (coef%dpp, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%tstar)) & + DEALLOCATE (coef%tstar, coef%tstar_r, coef%tstar_wsum_r, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%tstarmod_wsum_r)) & + DEALLOCATE (coef%tstarmod_wsum_r, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%tstar_uwsum_r)) & + DEALLOCATE (coef%tstar_uwsum_r, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%to3star)) & + DEALLOCATE (coef%to3star, coef%to3star_r, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%wstar)) & + DEALLOCATE (coef%wstar, coef%wstar_r, coef%wstar_wsum_r, coef%wtstar_wsum_r, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%ostar)) & + DEALLOCATE (coef%ostar, coef%ostar_r, coef%ostar_wsum_r, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%co2star)) & + DEALLOCATE (coef%co2star, coef%co2star_r, coef%co2star_wsum_r, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%n2ostar)) & + DEALLOCATE (coef%n2ostar, coef%n2ostar_r, coef%n2ostar_wsum_r, coef%n2otstar_wsum_r, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%costar)) & + DEALLOCATE (coef%costar, coef%costar_r, coef%costar_wsum_r, coef%cotstar_wsum_r, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%ch4star)) & + DEALLOCATE (coef%ch4star, coef%ch4star_r, coef%ch4star_wsum_r, coef%ch4tstar_wsum_r, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%so2star)) & + DEALLOCATE (coef%so2star, coef%so2star_r, coef%so2star_wsum_r, coef%so2tstar_wsum_r, STAT = err) + THROW(err.NE.0) + + print*,'dealloc_coef test(9)' + + IF (ASSOCIATED(coef%tt_val_chn)) DEALLOCATE (coef%tt_val_chn, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%tt_a0)) DEALLOCATE (coef%tt_a0, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%tt_a1)) DEALLOCATE (coef%tt_a1, STAT = err) + THROW(err.NE.0) + + print*,'dealloc_coef test(10)' + + IF (ASSOCIATED(coef%pw_val_chn)) DEALLOCATE (coef%pw_val_chn, STAT = err) + THROW(err.NE.0) + + + IF (ASSOCIATED(coef%ss_val_chn)) DEALLOCATE (coef%ss_val_chn, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%ss_solar_spectrum)) DEALLOCATE (coef%ss_solar_spectrum, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%ss_rayleigh_ext)) DEALLOCATE (coef%ss_rayleigh_ext, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%rayleigh_depol_gamma)) DEALLOCATE (coef%rayleigh_depol_gamma, STAT = err) + THROW(err.NE.0) + + print*,'dealloc_coef test(11)' + + IF (ASSOCIATED(coef%refl_visnir_ow)) DEALLOCATE (coef%refl_visnir_ow, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%refl_visnir_fw)) DEALLOCATE (coef%refl_visnir_fw, STAT = err) + THROW(err.NE.0) + + + IF (ASSOCIATED(coef%woc_waopc_ow)) DEALLOCATE (coef%woc_waopc_ow, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%woc_waopc_fw)) DEALLOCATE (coef%woc_waopc_fw, STAT = err) + THROW(err.NE.0) + + print*,'dealloc_coef test(12)' + + IF (ASSOCIATED(coef%ws_k_omega)) DEALLOCATE (coef%ws_k_omega, STAT = err) + THROW(err.NE.0) + + IF (ASSOCIATED(coef%ws_npoint)) DEALLOCATE (coef%ws_npoint, STAT = err) + THROW(err.NE.0) + + print*,'dealloc_coef test(13)' + + CALL rttov_nullify_coef(coef) + + print*,'dealloc_coef test(14)' + + CATCH + + CONTAINS + + SUBROUTINE dealloc_fast_coefs(err, fast_coefs) + USE rttov_types, ONLY : rttov_fast_coef + INTEGER(jpim), INTENT(OUT) :: err + TYPE(rttov_fast_coef), POINTER, INTENT(INOUT) :: fast_coefs(:) + INTEGER(jpim) :: ichan, igas + TRY + print*,'dealloc_fast_coef test(0)' + IF (ASSOCIATED(fast_coefs)) THEN ! If this part of the coef DDT is allocated + print*,'dealloc_fast_coef test(1)' + print*,'SIZE(fast_coefs): ',SIZE(fast_coefs) + DO ichan = 1, SIZE(fast_coefs) ! Iterate over each instrument channel (2378) +! print*,ichan +! print*,(ichan .eq. 52) + IF (ASSOCIATED(fast_coefs(ichan)%gasarray)) THEN ! If this part of the coef DDT is allocated +! if (ichan .eq. 52) print*,'igas: ',igas +! print*,'coef%fmv_gas: ',coef%fmv_gas +! print*,'SIZE(fast_coefs(ichan)%gasarray): ',SIZE(fast_coefs(ichan)%gasarray) + DO igas = 1, coef%fmv_gas ! Iterate over each gas type + if (ichan .eq. 52) then + print*,'igas: ',igas + print*,'igas, SIZE(fast_coefs(ichan)%gasarray(igas)%coef): ',igas,' ',SIZE(fast_coefs(ichan)%gasarray(igas)%coef) + print*,'ASSOCIATED(fast_coefs(ichan)%gasarray(igas)%coef): ',ASSOCIATED(fast_coefs(ichan)%gasarray(igas)%coef) + endif +! if (ichan .eq. 52) print*,'igas: ',igas +! if (ichan .eq. 52) print*,'SIZE(fast_coefs(ichan)%gasarray(igas)%coef): ',SIZE(fast_coefs(ichan)%gasarray(igas)%coef) + IF (ASSOCIATED(fast_coefs(ichan)%gasarray(igas)%coef)) & + DEALLOCATE(fast_coefs(ichan)%gasarray(igas)%coef, STAT = err) + THROW(err.NE.0) + ENDDO + DEALLOCATE(fast_coefs(ichan)%gasarray, STAT = err) + THROW(err.NE.0) + ENDIF + ENDDO + DEALLOCATE(fast_coefs, STAT = err) + THROW(err.NE.0) + ENDIF + CATCH + END SUBROUTINE dealloc_fast_coefs + + END SUBROUTINE rttov_dealloc_coef2 + + + end module mod_cosp_rttov From 83a54e2e6b4e586b606414353de311b3ad9cb544 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Thu, 4 May 2023 15:58:41 -0600 Subject: [PATCH 048/159] PC-RTTOV specific namelist inputs added --- driver/run/cosp2_pcrttov_nl.txt | 4 ++++ src/simulator/cosp_rttov_interface_v13.F90 | 25 ++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/driver/run/cosp2_pcrttov_nl.txt b/driver/run/cosp2_pcrttov_nl.txt index 2b6de1f74f..5d6c6e1c61 100644 --- a/driver/run/cosp2_pcrttov_nl.txt +++ b/driver/run/cosp2_pcrttov_nl.txt @@ -48,6 +48,10 @@ N2O_mr=4.665e-07, CO_mr=2.098e-07, SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) !-------------- RTTOV Other --------------- ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel rttov_nthreads=16, diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 525e61d7ec..b061e43395 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -131,19 +131,27 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, character(len=256) :: cosp_status integer :: & - i, & + i, & rttov_nthreads - + integer(kind=jpim) :: ipcbnd, ipcreg - ! Read RTTOV namelist fields namelist/RTTOV_INPUT/channel_filepath,rttov_srcDir,rttov_coefDir, & OD_coef_filepath,aer_coef_filepath,cld_coef_filepath, & - PC_coef_filepath, & SO2_mr,N2O_mr,CO_mr,CH4_mr,CO2_mr,rttov_ZenAng, & ! Mixing ratios SO2_data,N2O_data,CO_data,CH4_data,CO2_data,ozone_data, & rttov_nthreads + + ! Only read some namelist fields if PC-RTTOV will run + if (Lrttov_pc) then + namelist/RTTOV_INPUT/PC_coef_filepath,ipcbnd,ipcreg,npcscores + endif + + !! JKS - Hardcode in some options that will eventually be moved to the namelist + ipcbnd = 1 ! This should always be one per the User Guide + ipcreg = 2 ! 300 predictors (channels). See RTTOV user guide Table 31. + npcscores = 100 ! 100 principal component scores !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Read in namelists @@ -285,11 +293,6 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, ! Developer options that may be useful: opts%dev%do_opdep_calc = .true. - - !! JKS - Hardcode in some options that will eventually be moved to the namelist - ipcbnd = 1 ! This should always be one per the User Guide - ipcreg = 2 ! 300 predictors (channels). See RTTOV user guide Table 31. - npcscores = 100 ! 100 principal component scores ! If using PC-RTTOV, some settings must be a certain way. This isn't always true though... if (do_rttov_pcrttov) then @@ -583,6 +586,10 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,lCleanup, ! Deallocate the coefficient files if directed if (lCleanup) then print*,'NOT DEALLOCATING COEFS WHEN RUNNING PC-RTTOV. Unresolved Deallocation Error in "dealloc_fast_coefs" when using AIRS files.' + +! if (ASSOCIATED(coef_rttov)) deallocate (coef_rttov, stat=errorstatus) +! deallocate (coef_rttov, stat=errorstatus) +! call rttov_error('mem dellocation error for "coef_rttov"', lalloc = .true.) ! See error in "dealloc_fast_coefs" when using AIRS files. ! call cpu_time(driver_time(8)) ! call cosp_rttov_deallocate_coefs2() From 2a9046235fc7cbf6a9f74a1f48793e1d89516052 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Thu, 11 May 2023 11:34:27 -0600 Subject: [PATCH 049/159] PC-RTTOV and channel indexing functioning Unclear if the non-PC-RTTOV option can handle -1 and 0 values for nchannels_rec yet. --- driver/run/cosp2_pcrttov_nl.txt | 7 +- driver/run/cosp2_rttov_nl.txt | 2 + driver/src/cosp2_io.f90 | 25 +- driver/src/cosp2_test.F90 | 6 + src/cosp.F90 | 31 +- src/simulator/cosp_rttov_interfaceSTUB.F90 | 5 +- src/simulator/cosp_rttov_interface_v13.F90 | 124 +++--- src/simulator/rttov/cosp_rttov_v13.F90 | 491 +++------------------ 8 files changed, 192 insertions(+), 499 deletions(-) diff --git a/driver/run/cosp2_pcrttov_nl.txt b/driver/run/cosp2_pcrttov_nl.txt index 5d6c6e1c61..5dca3772ba 100644 --- a/driver/run/cosp2_pcrttov_nl.txt +++ b/driver/run/cosp2_pcrttov_nl.txt @@ -25,10 +25,13 @@ ! Namelist that sets up the main COSP options &RTTOV_INPUT + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=0, ! 2300 !-------------- RTTOV Filepaths - channel_filepath='rttov_channel_input_AIRS.csv' + Lchannel_filepath=.false., + channel_filepath='rttov_channel_input_AIRS.csv', rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/' + rttov_coefDir='rtcoef_rttov13/', OD_coef_filepath='rttov9pred101L/rtcoef_eos_2_airs_pcrttov_compat.H5', aer_coef_filepath='cldaer_visir/scaercoef_eos_2_airs_cams.H5', cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_airs.H5', diff --git a/driver/run/cosp2_rttov_nl.txt b/driver/run/cosp2_rttov_nl.txt index 2abd9ac9e1..586a698f49 100644 --- a/driver/run/cosp2_rttov_nl.txt +++ b/driver/run/cosp2_rttov_nl.txt @@ -25,6 +25,8 @@ ! Namelist that sets up the main COSP options &RTTOV_INPUT + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=2378, !-------------- RTTOV Filepaths channel_filepath='rttov_channel_input_AIRS.csv' rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', diff --git a/driver/src/cosp2_io.f90 b/driver/src/cosp2_io.f90 index ddf7879581..8c7d81c4c9 100644 --- a/driver/src/cosp2_io.f90 +++ b/driver/src/cosp2_io.f90 @@ -193,7 +193,14 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, lev, lon, l if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) status = nf90_put_att(fileID,varID(83),"units", "1") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - + + ! RTTOV Channel Indices (rttov_Ichannel) + status = nf90_def_var(fileID,"RTTOV_CHAN", nf90_float, (/dimID(19)/),varID(157)) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(86),"long_name","rttov channel indices") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(86),"units", "1") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) ! CALIPSO simulator output if (associated(cospOUT%calipso_betaperp_tot)) then @@ -1498,21 +1505,21 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, lev, lon, l if (associated(cospOUT%rttov_bt_total_pc)) then status = nf90_def_var(fileID,"rttov_bt_total_pc",nf90_float, (/dimID(1),dimID(19)/),varID(155)) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(154),"long_name","PC-RTTOV All-sky Brightness Temperature") + status = nf90_put_att(fileID,varID(155),"long_name","PC-RTTOV All-sky Brightness Temperature") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(154),"units", "Degrees Kelvin") + status = nf90_put_att(fileID,varID(155),"units", "Degrees Kelvin") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(154),"standard_name", "bleh") + status = nf90_put_att(fileID,varID(155),"standard_name", "bleh") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) endif if (associated(cospOUT%rttov_rad_total_pc)) then status = nf90_def_var(fileID,"rttov_rad_total_pc",nf90_float, (/dimID(1),dimID(19)/),varID(156)) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(154),"long_name","PC-RTTOV All-sky Radiance") + status = nf90_put_att(fileID,varID(156),"long_name","PC-RTTOV All-sky Radiance") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(154),"units", "mW/cm-1/sr/m2") + status = nf90_put_att(fileID,varID(156),"units", "mW/cm-1/sr/m2") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(154),"standard_name", "bleh") + status = nf90_put_att(fileID,varID(156),"standard_name", "bleh") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) endif @@ -1553,6 +1560,10 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, lev, lon, l if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) status = nf90_put_var(fileID,varID(83),loc) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + if (associated(cospOUT%rttov_Ichannel)) then + status = nf90_put_var(fileID,varID(157),cospOUT%rttov_Ichannel) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif ! CALIPSO simulator output if (associated(cospOUT%calipso_betaperp_tot)) then diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 6ac3b49611..046a823540 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -1401,6 +1401,7 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& ! RTTOV - Only add non-total fields if clouds or aerosols are simulated if (Lrttov_pc) then ! Treat PC-RTTOV fields as clear-sky only for now + allocate(x%rttov_Ichannel(Nchan)) if (Lrttov_bt) then ! Brightness temp allocate(x%rttov_bt_total_pc(Npoints,Nchan)) ! if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_bt_clear(Npoints,Nchan)) @@ -1411,6 +1412,7 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& ! if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_rad_cloudy(Npoints,Nchan)) endif else + allocate(x%rttov_Ichannel(Nchan)) if (Lrttov_bt) then ! Brightness temp allocate(x%rttov_bt_total(Npoints,Nchan)) if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_bt_clear(Npoints,Nchan)) @@ -1816,6 +1818,10 @@ subroutine destroy_cosp_outputs(y) endif ! RTTOV + if (associated(y%rttov_Ichannel)) then + deallocate(y%rttov_Ichannel) + nullify(y%rttov_Ichannel) + endif if (associated(y%rttov_bt_total)) then deallocate(y%rttov_bt_total) nullify(y%rttov_bt_total) diff --git a/src/cosp.F90 b/src/cosp.F90 index 733ba73e8e..bd4aa0c747 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -305,6 +305,8 @@ MODULE MOD_COSP rttov_refl_clear(:,:) => null(), & ! Reflectance rttov_bt_total_pc(:,:) => null(), & ! Brightness Temperature (PC-RTTOV) rttov_rad_total_pc(:,:) => null() ! Radiance (PC-RTTOV) + integer,dimension(:),pointer :: & + rttov_Ichannel => null() ! Joint CloudSat+MODIS simulators outputs real(wp),dimension(:,:,:,:),pointer :: & @@ -376,7 +378,8 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ok_lidar_cfad_atlid = .false., & lrttov_cleanUp = .false. real(wp),dimension(10) :: driver_time - + integer, dimension(:),allocatable :: & + rttov_Ichannel integer, dimension(:,:),allocatable :: & modisRetrievedPhase,isccpLEVMATCH real(wp), dimension(:), allocatable :: & @@ -1557,6 +1560,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Allocate memory for the outputs - I won't need all of these in every situation. ! Only allocate clear-sky memory when PC-RTTOV is run. + allocate(rttov_Ichannel(rttovIN%Nchannels)) ! Channel indices if (Lrttov_pc) then ! allocate(rttov_bt_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky brightness temp ! allocate(rttov_rad_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky brightness temp @@ -1575,6 +1579,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) call cpu_time(driver_time(3)) ! Run simulator call cosp_rttov_simulate(rttovIN,Lrttov_cleanUp, & ! Inputs + rttov_Ichannel, & ! Channel Indices rttov_bt_total,rttov_bt_clear, & ! Brightness Temp Outputs rttov_rad_total,rttov_rad_clear,rttov_rad_cloudy, & ! Radiance Outputs rttov_refl_total,rttov_refl_clear, & ! Reflectance Outputs @@ -1583,6 +1588,8 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) print*,'Time to run RTTOV: ',driver_time(4)-driver_time(3) ! Write to cospOUT + if (associated(cospOUT%rttov_Ichannel)) & + cospOUT%rttov_Ichannel(:) = rttov_Ichannel if (Lrttov_pc) then if (associated(cospOUT%rttov_bt_total_pc)) & cospOUT%rttov_bt_total_pc(ij:ik,:) = rttov_bt_total @@ -1606,6 +1613,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) endif ! Free up memory from output (if necessary) + if (allocated(rttov_Ichannel)) deallocate(rttov_Ichannel) if (allocated(rttov_bt_total)) deallocate(rttov_bt_total) if (allocated(rttov_bt_clear)) deallocate(rttov_bt_clear) if (allocated(rttov_rad_total)) deallocate(rttov_rad_total) @@ -1855,8 +1863,7 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La Nlevels, & ! Nvgrid, & ! Number of levels for new L3 grid surface_radar ! -! surface_radar, & ! -! NchanIN ! RTTOV arguments here and below JKS +! integer,pointer,intent(inout) :: & integer,intent(inout) :: & NchanIN real(wp),intent(in) :: & @@ -2677,6 +2684,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, endif if (.not. alloc_status) then Lrttov_column = .false. + if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF @@ -2783,6 +2791,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lcloudsat_tcc = .false. Lcloudsat_tcc2 = .false. Lcloudsat_modis_wr = .false. + if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF @@ -2833,6 +2842,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lisccp_subcolumn = .false. Lisccp_column = .false. Lrttov_column = .false. + if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF @@ -2866,6 +2876,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lrttov_column = .false. Latlid_column = .false. LgrLidar532_column = .false. + if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF @@ -2951,6 +2962,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lisccp_subcolumn = .false. Lisccp_column = .false. Lrttov_column = .false. + if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF @@ -3036,6 +3048,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Latlid_column = .false. LgrLidar532_column = .false. Lcloudsat_modis_wr = .false. + if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF @@ -3079,6 +3092,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lrttov_column = .false. Lcalipso_column = .false. Lparasol_column = .false. + if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF @@ -3110,6 +3124,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lisccp_subcolumn = .false. Lisccp_column = .false. Lrttov_column = .false. + if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF @@ -3137,6 +3152,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%co2 contains values out of range' Lrttov_column = .false. + if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF @@ -3151,6 +3167,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%ch4 contains values out of range' Lrttov_column = .false. + if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF @@ -3165,6 +3182,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%n2o contains values out of range' Lrttov_column = .false. + if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF @@ -3179,6 +3197,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%co contains values out of range' Lrttov_column = .false. + if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF @@ -3193,6 +3212,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%o3 contains values out of range' Lrttov_column = .false. + if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF @@ -3207,6 +3227,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%emis_sfc contains values out of range' Lrttov_column = .false. + if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF @@ -3221,6 +3242,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%refl_sfc contains values out of range' Lrttov_column = .false. + if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF @@ -3235,6 +3257,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospIN%u_sfc contains values out of range' Lrttov_column = .false. + if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF @@ -3249,6 +3272,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospIN%v_sfc contains values out of range' Lrttov_column = .false. + if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF @@ -3263,6 +3287,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospIN%lat contains values out of range' Lrttov_column = .false. + if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF diff --git a/src/simulator/cosp_rttov_interfaceSTUB.F90 b/src/simulator/cosp_rttov_interfaceSTUB.F90 index 4f28c5c47d..fe9ccd25c4 100644 --- a/src/simulator/cosp_rttov_interfaceSTUB.F90 +++ b/src/simulator/cosp_rttov_interfaceSTUB.F90 @@ -75,15 +75,18 @@ END SUBROUTINE COSP_RTTOV_INIT ! SUBROUTINE cosp_rttov_simulate !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, & ! Inputs + iChannel_ret, & ! Channel index outputs bt_total,bt_clear, & ! Brightness Temp Outputs rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs refl_total,refl_clear, & ! Reflectance Outputs - error) + error) type(rttov_in),intent(in) :: & rttovIN logical,intent(in) :: & lCleanup ! Flag to determine whether to deallocate RTTOV types + integer,intent(inout),dimension(rttovIN%nChannels) :: & + iChannel_ret real(wp),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! bt_total, & ! All-sky bt_clear, & ! Clear-sky diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index b061e43395..7f563c78e0 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -32,13 +32,14 @@ ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MODULE MOD_COSP_RTTOV_INTERFACE USE COSP_KINDS, ONLY: wp - use mod_cosp_rttov, only: nChannels,iChannel,emisChannel,reflChannel, & + use mod_cosp_rttov, only: nchannels_rec,iChannel,emisChannel,reflChannel, & coef_rttov,opts,rttov_in, & do_rttov_bt,do_rttov_rad,do_rttov_refl, & do_rttov_cld,do_rttov_aer,do_rttov_pcrttov, & rttov_cld_optparam,rttov_aer_optparam, & rttov_direct_nthreads,rttovDir,PC_coef_filepath, & - so2,ch4,co,co2,n2o,zenang,npcscores,predictindex + so2,ch4,co,co2,n2o,zenang,npcscores,predictindex, & + iChannel_out,Lchannel_filepath ! rttov_const contains useful RTTOV constants @@ -77,13 +78,12 @@ MODULE MOD_COSP_RTTOV_INTERFACE !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_init !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, & + SUBROUTINE COSP_RTTOV_INIT(nchan_out,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, & Lrttov_cld,Lrttov_aer,Lrttov_cldparam,Lrttov_aerparam, & Lrttov_pc,rttov_input_namelist) integer,intent(inout) :: & - NchanIN + nchan_out ! JKS make this out only soon integer,intent(in) :: & -! NchanIN, & nlevels logical,intent(in) :: & Lrttov_bt, & @@ -137,21 +137,26 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, integer(kind=jpim) :: ipcbnd, ipcreg ! Read RTTOV namelist fields - namelist/RTTOV_INPUT/channel_filepath,rttov_srcDir,rttov_coefDir, & + namelist/RTTOV_INPUT/Lchannel_filepath,rttov_srcDir,rttov_coefDir, & OD_coef_filepath,aer_coef_filepath,cld_coef_filepath, & SO2_mr,N2O_mr,CO_mr,CH4_mr,CO2_mr,rttov_ZenAng, & ! Mixing ratios SO2_data,N2O_data,CO_data,CH4_data,CO2_data,ozone_data, & - rttov_nthreads - + rttov_nthreads,nchannels_rec + + ! Only read channel indices and emissivities if prompted + if (Lchannel_filepath) then + namelist/RTTOV_INPUT/channel_filepath + endif + ! Only read some namelist fields if PC-RTTOV will run if (Lrttov_pc) then namelist/RTTOV_INPUT/PC_coef_filepath,ipcbnd,ipcreg,npcscores endif !! JKS - Hardcode in some options that will eventually be moved to the namelist - ipcbnd = 1 ! This should always be one per the User Guide - ipcreg = 2 ! 300 predictors (channels). See RTTOV user guide Table 31. - npcscores = 100 ! 100 principal component scores +! ipcbnd = 1 ! This should always be one per the User Guide +! ipcreg = 2 ! 300 predictors (channels). See RTTOV user guide Table 31. +! npcscores = 100 ! 100 principal component scores !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Read in namelists @@ -159,27 +164,10 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, open(10,file=rttov_input_namelist,status='unknown') read(10,nml=RTTOV_INPUT) close(10) - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Read in channel indices, emissivities, and reflectivities from .csv - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - allocate(iChannel(NchanIN)) - allocate(emisChannel(NchanIN)) - allocate(reflChannel(NchanIN)) - open(18,file=channel_filepath,access='sequential',form="formatted") - do i = 1, NchanIN - read(18,*) iChannel(i), emisChannel(i), reflChannel(i) - end do - close(18) - -! print*,'iChannel: ',iChannel -! print*,'emisChannel: ',emisChannel -! print*,'reflChannel: ',reflChannel ! Initialize fields in module memory (cosp_rttovXX.F90) rttovDir = rttov_srcDir - nChannels = NchanIN ! Set logicals for RTTOV options do_rttov_bt = Lrttov_bt @@ -360,9 +348,10 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, file_scaer=aer_coef_filepath, & file_sccld=cld_coef_filepath) ! Ensure input number of channels is not higher than number stored in coefficient file - if (nchannels > coef_rttov % coef % fmv_chn) then - nchannels = coef_rttov % coef % fmv_chn - endif + if (nchannels_rec > coef_rttov % coef % fmv_chn) then + nchannels_rec = coef_rttov % coef % fmv_chn + print*,'nchannels_rec cap hit' + endif endif ! We aren't checking an allocation steps so this seems more appropriate. @@ -373,13 +362,46 @@ SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, ! We aren't checking an allocation steps so this seems more appropriate. call rttov_error('error in rttov options' , lalloc = .false.) - - if (do_rttov_pcrttov) then - nullify(predictindex) - call rttov_get_pc_predictindex(errorstatus, opts, predictindex, file_pccoef=PC_coef_filepath) - call rttov_error('rttov_get_pc_predictindex fatal error' , lalloc = .false.) - NchanIN = SIZE(predictindex) ! Correct the number of channels + + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Figure out how many channels we actually want to reconstruct + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + ! Handle different radiance reconstruction options + if (nchannels_rec < 0) then + ! If the number of channels is negative, don't reconstruct radiances at all + nchan_out = 0 + else if (nchannels_rec == 0) then + ! If the number of channels is set to 0 then reconstruct all instrument channels + nchan_out = coef_rttov % coef % fmv_chn + else + ! Otherwise read the channel list from the file + nchan_out = nchannels_rec + endif + + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Read in channel indices, emissivities, and reflectivities from .csv if file is passed + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + print*,'nchan_out: ',nchan_out + + if (Lchannel_filepath) then + allocate(iChannel(nchan_out)) + allocate(emisChannel(nchan_out)) + allocate(reflChannel(nchan_out)) + + open(18,file=channel_filepath,access='sequential',form="formatted") + do i = 1, nchan_out + read(18,*) iChannel(i), emisChannel(i), reflChannel(i) + end do + close(18) + else ! If nothing is passed, compute the first "nchan_out" channels. Ignore emissivity and reflectivity for now. + allocate(iChannel(nchan_out)) + iChannel(:) = (/ (i, i = 1, nchan_out) /) endif + ! subsub routines contains @@ -408,6 +430,7 @@ END SUBROUTINE COSP_RTTOV_INIT ! SUBROUTINE cosp_rttov_simulate - Call subroutines in mod_cosp_rttov to run RTTOV !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, & ! Inputs + iChannel_ret, & ! Channel index outputs bt_total,bt_clear, & ! Brightness Temp Outputs rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs refl_total,refl_clear, & ! Reflectance Outputs @@ -417,6 +440,8 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, rttovIN logical,intent(in) :: & lCleanup ! Flag to determine whether to deallocate RTTOV types + integer(kind=jpim),intent(out),dimension(rttovIN%nChannels) :: & ! Channels indices to return for output + iChannel_ret real(wp),intent(inout),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! bt_total, & ! All-sky bt_clear, & ! Clear-sky @@ -432,13 +457,20 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, if (opts % rt_ir % pc % addpc) then call COSP_PC_RTTOV_SIMULATE(rttovIN,lCleanup, & bt_total,rad_total, & - error) + error) +! print*,'SIZE(iChannel_ret): ',SIZE(iChannel_ret) +! print*,'SIZE(iChannel_out): ',SIZE(iChannel_out) + iChannel_ret = iChannel_out else call COSP_REG_RTTOV_SIMULATE(rttovIN,lCleanup, & bt_total,bt_clear, & rad_total,rad_clear,rad_cloudy, & refl_total,refl_clear, & error) +! print*,'SIZE(iChannel_ret): ',SIZE(iChannel_ret) +! print*,'SIZE(iChannel): ',SIZE(iChannel) + iChannel_ret = iChannel + endif END SUBROUTINE COSP_RTTOV_SIMULATE @@ -537,7 +569,6 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,lCleanup, cosp_pc_rttov_call_direct, & cosp_pc_rttov_save_output, & cosp_pc_rttov_deallocate_profiles, & - cosp_rttov_deallocate_coefs2, & ! JKS check cosp_rttov_deallocate_coefs type(rttov_in),intent(in) :: & @@ -585,17 +616,10 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,lCleanup, ! Deallocate the coefficient files if directed if (lCleanup) then - print*,'NOT DEALLOCATING COEFS WHEN RUNNING PC-RTTOV. Unresolved Deallocation Error in "dealloc_fast_coefs" when using AIRS files.' - -! if (ASSOCIATED(coef_rttov)) deallocate (coef_rttov, stat=errorstatus) -! deallocate (coef_rttov, stat=errorstatus) -! call rttov_error('mem dellocation error for "coef_rttov"', lalloc = .true.) - ! See error in "dealloc_fast_coefs" when using AIRS files. -! call cpu_time(driver_time(8)) -! call cosp_rttov_deallocate_coefs2() -! call cosp_rttov_deallocate_coefs() -! call cpu_time(driver_time(9)) -! print*,'Time to run "cosp_rttov_deallocate_coefs": ',driver_time(9)-driver_time(8) + call cpu_time(driver_time(8)) + call cosp_rttov_deallocate_coefs() + call cpu_time(driver_time(9)) + print*,'Time to run "cosp_rttov_deallocate_coefs": ',driver_time(9)-driver_time(8) endif ! print*,'Total RTTOV run time: ',driver_time(8)-driver_time(1) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 89f67e3404..1b8648c283 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -76,11 +76,12 @@ module mod_cosp_rttov #include "rttov_user_options_checkinput.interface" #include "rttov_print_opts.interface" #include "rttov_print_profile.interface" +#include "rttov_get_pc_predictindex.interface" ! checking inputs -#include "rttov_dealloc_coef_scatt.interface" -#include "rttov_dealloc_coef.interface" -#include "rttov_dealloc_coef_pccomp.interface" +!#include "rttov_dealloc_coef_scatt.interface" +!#include "rttov_dealloc_coef.interface" +!#include "rttov_dealloc_coef_pccomp.interface" ! Includes when directly inputting cloud optical parameters @@ -96,14 +97,17 @@ module mod_cosp_rttov real(wp),parameter :: eps = 0.622 ! Initialization parameters - integer(kind=jpim) :: & - nChannels ! Number of channels + + ! Number of channels to reconstruct (-1: None, 1:All, otherwise the actual number) + INTEGER(kind=jpim) :: nchannels_rec + integer(kind=jpim) :: & ! Parallelization is default off rttov_direct_nthreads = 1_jpim integer(kind=jpim),allocatable :: & iChannel(:), & ! RTTOV channel indices emisChannel(:), & ! RTTOV channel emissivity - reflChannel(:) ! RTTOV channel reflectivity + reflChannel(:), & ! RTTOV channel reflectivity + iChannel_out(:) ! Passing out the channel indices ! Scattering coefficients (read in once during initialization) ! JKS - KISS @@ -118,7 +122,8 @@ module mod_cosp_rttov do_rttov_refl, & ! Return reflectances in RTTOV calculations do_rttov_pcrttov, & ! Do computations using PC-RTTOV rttov_cld_optparam, & ! Use user-supplied optical cloud parameters - rttov_aer_optparam ! Use user-supplied optical aerosol parameters + rttov_aer_optparam, & ! Use user-supplied optical aerosol parameters + Lchannel_filepath ! --- Well-mixed trace gas mixing ratios from user via RTTOV namelist real(wp) :: so2 = 0._wp @@ -161,7 +166,7 @@ module mod_cosp_rttov ! JKS additional variables used in PC-RTTOV INTEGER(KIND=jpim), POINTER :: predictindex(:) - INTEGER(KIND=jpim) :: nchannels_rec, nchannels_comp, npcscores + INTEGER(KIND=jpim) :: nchannels_comp, npcscores, npred_pc ! npred to go here INTEGER(KIND=jpim) :: lo, hi ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -174,7 +179,7 @@ module mod_cosp_rttov nPoints, & ! Number of profiles to simulate nLevels, & ! Number of levels nSubCols, & ! Number of subcolumns - nChannels, & ! Number of channels to simulate ! JKS + nChannels, & ! Number of channels to simulate ! JKS, can remove now month ! Month (needed for surface emissivity calculation) real(wp),pointer :: & ! Could change the dimensionality of these in the future co2, & ! Carbon dioxide @@ -257,7 +262,8 @@ subroutine cosp_rttov_allocate(rttovIN & ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Determine the total number of radiances to simulate (nchanprof). - nchanprof = rttovIN%nChannels * rttovIN%nPoints +! nchanprof = rttovIN%nChannels * rttovIN%nPoints + nchanprof = nChannels_rec * rttovIN%nPoints ! RTTOV (non-PC) needs nchan_out? JKS potential bug ! Allocate structures for rttov_direct call rttov_alloc_direct( & @@ -325,24 +331,40 @@ subroutine cosp_pc_rttov_allocate(rttovIN & ! JKS clean this up when done. ! nchannels_rec = rttovIN%nChannels ! Number of channels to reconstruct indicated in namelist. - nchannels_rec = SIZE(predictindex) ! Number of channels to reconstruct indicated in namelist. - nchannels_comp = SIZE(predictindex) ! Number of channels to compute is determined by ipcreg in init. - nchanprof = nchannels_comp * rttovIN%nPoints ! Size of chanprof array is total number of channels over all profiles. +! nchannels_rec = rttovIN%nChannels ! Number of channels to reconstruct indicated in namelist. + + ! nchannels = SIZE(predictindex) + ! nchanprof = nchannels * nprof ! Size of chanprof array is total number of channels over all profiles + ! npred = SIZE(predictindex) + ! nchanprof = npred * nprof ! Size of chanprof array is total number of channels over all profiles + + nullify(predictindex) + call rttov_get_pc_predictindex(errorstatus, opts, predictindex, file_pccoef=PC_coef_filepath) + call rttov_error('rttov_get_pc_predictindex fatal error' , lalloc = .false.) + npred_pc = SIZE(predictindex) + nchanprof = npred_pc * rttovIN%nPoints ! Size of chanprof array is total number of predictors over all profiles + ! Determine the number of reconstructed radiances per profile (nchannels_rec) if (opts % rt_ir % pc % addradrec) then if (nchannels_rec < 0) then ! If the number of channels is negative, don't reconstruct radiances at all + print*,'radrec 1.' opts % rt_ir % pc % addradrec = .FALSE. else if (nchannels_rec == 0) then ! If the number of channels is set to 0 then reconstruct all instrument channels + print*,'radrec 2.' nchannels_rec = coef_rttov % coef % fmv_chn allocate(channels_rec(nchannels_rec)) channels_rec(:) = (/ (j, j = 1, nchannels_rec) /) + iChannel_out = (/ (j, j = 1, nchannels_rec) /) else ! Otherwise read the channel list from the file + print*,'radrec 3.' + print*,'nchannels_rec: ',nchannels_rec allocate(channels_rec(nchannels_rec)) channels_rec(:) = iChannel ! channels_rec is just the index of the desired channels + iChannel_out = iChannel endif endif @@ -369,11 +391,6 @@ subroutine cosp_pc_rttov_allocate(rttovIN & pccomp=pccomp, & init=.TRUE._jplm) call rttov_error('allocation error for rttov_direct structures (PC-RTTOV)' , lalloc = .true.) - -! IF (errorstatus /= errorstatus_success) THEN -! WRITE(*,*) 'allocation error for rttov_direct structures' -! CALL rttov_exit(errorstatus) -! ENDIF ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 4. Build the list of profile/channel indices in chanprof @@ -383,8 +400,8 @@ subroutine cosp_pc_rttov_allocate(rttovIN & ! Populate chanprof using the channel list obtained above in predictindex(:) do j = 1, rttovIN%nPoints - lo = (j - 1) * nchannels_comp + 1 - hi = lo + nchannels - 1 + lo = (j - 1) * npred_pc + 1 + hi = lo + npred_pc - 1 chanprof(lo:hi)%prof = j chanprof(lo:hi)%chan = predictindex(:) end do @@ -718,7 +735,6 @@ subroutine cosp_rttov_save_output(rttovIN, & ! Only save output if appropriate if (do_rttov_bt) then - print*,'trying' bt_total(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & transpose(reshape(radiance%bt(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) endif @@ -746,7 +762,6 @@ subroutine cosp_rttov_save_output(rttovIN, & bt_clear(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & transpose(reshape(radiance%refl_clear(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) endif - print*,'done.' end subroutine cosp_rttov_save_output @@ -771,20 +786,29 @@ subroutine cosp_pc_rttov_save_output(rttovIN, & bt_total, & rad_total + print*,'shape(bt_total): ',shape(bt_total) + print*,'shape(rad_total): ',shape(rad_total) + print*,'rttovIN%nPoints: ',rttovIN%nPoints + print*,'rttovIN%nChannels: ',rttovIN%nChannels + print*,'nchanprof: ',nchanprof + print*,'size(pccomp%bt_pccomp): ',size(pccomp%bt_pccomp) + print*,'size(pccomp%total_pccomp): ',size(pccomp%total_pccomp) + print*,'nchannels_rec * rttovIN%nPoints: ',nchannels_rec * rttovIN%nPoints + + ! JKS why not just pass in rttovIN%nPoints and use nchannels_rec here? TO-DO? ! Documentation for RTTOV radiance structure in RTTOV User Guide pg 166 - print*,'do_rttov_bt: ',do_rttov_bt - print*,'do_rttov_rad: ',do_rttov_rad - ! Only save output if appropriate if (do_rttov_bt) then bt_total(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & - transpose(reshape(pccomp%bt_pccomp(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) + transpose(reshape(pccomp%bt_pccomp(1:(nchannels_rec * rttovIN%nPoints)), (/ rttovIN%nChannels, rttovIN%nPoints/) )) +! transpose(reshape(pccomp%bt_pccomp(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) endif if (do_rttov_rad) then rad_total(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & - transpose(reshape(pccomp%total_pccomp(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) + transpose(reshape(pccomp%total_pccomp(1:(nchannels_rec * rttovIN%nPoints)), (/ rttovIN%nChannels, rttovIN%nPoints/) )) +! transpose(reshape(pccomp%total_pccomp(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) endif end subroutine cosp_pc_rttov_save_output @@ -875,414 +899,9 @@ subroutine cosp_rttov_deallocate_coefs() endif end subroutine cosp_rttov_deallocate_coefs - - -! Other subroutines used for bug chasing - subroutine cosp_rttov_deallocate_coefs2() - -! print*,'dealloc2 test(1)' - CALL rttov_dealloc_coef_scatt(errorstatus, coef_rttov%coef_scatt) -! THROW(err.NE.0) - -! print*,'dealloc2 test(2)' - IF (ASSOCIATED(coef_rttov%coef_pccomp%pcreg)) THEN - print*,'running: "rttov_dealloc_coef_pccomp"' - CALL rttov_dealloc_coef_pccomp(errorstatus, coef_rttov%coef_pccomp) -! THROW(err.NE.0) - ENDIF - -! IF (ASSOCIATED(coefs%coef_mfasis_cld%lut)) THEN -! CALL rttov_dealloc_coef_mfasis(err, coefs%coef_mfasis_cld) -! THROW(err.NE.0) -! ENDIF - -! IF (ASSOCIATED(coefs%coef_mfasis_aer%lut)) THEN -! CALL rttov_dealloc_coef_mfasis(err, coefs%coef_mfasis_aer) -! THROW(err.NE.0) -! ENDIF - -! IF (ASSOCIATED(coefs%coef_mfasis_nn%nn)) THEN -! CALL rttov_dealloc_coef_mfasis_nn(err, coefs%coef_mfasis_nn) -! THROW(err.NE.0) -! ENDIF - -! IF (ASSOCIATED(coefs%coef_htfrtc%p)) THEN -! CALL rttov_dealloc_coef_htfrtc(err, coefs%coef_htfrtc) -! THROW(err.NE.0) -! ENDIF - - print*,'dealloc2 test(3)' - CALL rttov_dealloc_coef2(errorstatus, coef_rttov%coef) -! CALL rttov_dealloc_coef(errorstatus, coef_rttov%coef) -! THROW(err.NE.0) - - print*,'dealloc2 test(4)' - coef_rttov%initialised = .FALSE. - print*,'dealloc2 test(5)' - - end subroutine cosp_rttov_deallocate_coefs2 - - - SUBROUTINE rttov_dealloc_coef2(err, coef) - !INTF_OFF -#include "throw.h" - !INTF_ON - USE rttov_types, ONLY : rttov_coef - USE parkind1, ONLY : jpim - IMPLICIT NONE - - INTEGER(KIND=jpim), INTENT(OUT) :: err - TYPE(rttov_coef), INTENT(INOUT) :: coef - !INTF_END -#include "rttov_nullify_coef.interface" -#include "rttov_errorreport.interface" - !- End of header -------------------------------------------------------- - - TRY - - print*,'dealloc_coef test(0)' - - IF (ASSOCIATED(coef%fmv_gas_id)) DEALLOCATE (coef%fmv_gas_id, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%fmv_gas_pos)) DEALLOCATE (coef%fmv_gas_pos, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%fmv_var)) DEALLOCATE (coef%fmv_var, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%fmv_coe)) DEALLOCATE (coef%fmv_coe, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%fmv_ncorr)) DEALLOCATE (coef%fmv_ncorr, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%fmv_lvl)) DEALLOCATE (coef%fmv_lvl, STAT = err) - THROW(err.NE.0) - - print*,'dealloc_coef test(1)' - - IF (ASSOCIATED(coef%ff_ori_chn)) DEALLOCATE (coef%ff_ori_chn, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%ff_val_chn)) DEALLOCATE (coef%ff_val_chn, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%ff_cwn)) DEALLOCATE (coef%ff_cwn, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%ff_bco)) DEALLOCATE (coef%ff_bco, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%ff_bcs)) DEALLOCATE (coef%ff_bcs, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%ff_gam)) DEALLOCATE (coef%ff_gam, STAT = err) - THROW(err.NE.0) - - print*,'dealloc_coef test(2)' - - IF (ASSOCIATED(coef%fastem_polar)) DEALLOCATE (coef%fastem_polar, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%pol_phi)) DEALLOCATE (coef%pol_phi, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%pol_fac_v)) DEALLOCATE (coef%pol_fac_v, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%pol_fac_h)) DEALLOCATE (coef%pol_fac_h, STAT = err) - THROW(err.NE.0) - - print*,'dealloc_coef test(3)' - - IF (ASSOCIATED(coef%ssirem_a0)) DEALLOCATE (coef%ssirem_a0, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%ssirem_a1)) DEALLOCATE (coef%ssirem_a1, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%ssirem_a2)) DEALLOCATE (coef%ssirem_a2, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%ssirem_xzn1)) DEALLOCATE (coef%ssirem_xzn1, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%ssirem_xzn2)) DEALLOCATE (coef%ssirem_xzn2, STAT = err) - THROW(err.NE.0) - - print*,'dealloc_coef test(4)' - - IF (ASSOCIATED(coef%iremis_coef)) DEALLOCATE (coef%iremis_coef, STAT = err) - THROW(err.NE.0) - - - IF (ASSOCIATED(coef%ref_prfl_p)) DEALLOCATE (coef%ref_prfl_p, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%ref_prfl_t)) DEALLOCATE (coef%ref_prfl_t, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%ref_prfl_mr)) DEALLOCATE (coef%ref_prfl_mr, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%bkg_prfl_mr)) DEALLOCATE (coef%bkg_prfl_mr, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%lim_prfl_p)) DEALLOCATE (coef%lim_prfl_p, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%env_prfl_tmax)) DEALLOCATE (coef%env_prfl_tmax, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%env_prfl_tmin)) DEALLOCATE (coef%env_prfl_tmin, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%env_prfl_gmin)) DEALLOCATE (coef%env_prfl_gmin, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%env_prfl_gmax)) DEALLOCATE (coef%env_prfl_gmax, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%lim_prfl_tmax)) DEALLOCATE (coef%lim_prfl_tmax, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%lim_prfl_tmin)) DEALLOCATE (coef%lim_prfl_tmin, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%lim_prfl_gmin)) DEALLOCATE (coef%lim_prfl_gmin, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%lim_prfl_gmax)) DEALLOCATE (coef%lim_prfl_gmax, STAT = err) - THROW(err.NE.0) - - print*,'coef%fmv_gas: ',coef%fmv_gas - print*,'dealloc_coef test(5)' -! print*,'coef%thermal: ',coef%thermal - CALL dealloc_fast_coefs(err, coef%thermal) - THROW(err.NE.0) - print*,'dealloc_coef test(5a)' - CALL dealloc_fast_coefs(err, coef%thermal_corr) - THROW(err.NE.0) - print*,'dealloc_coef test(5b)' - - IF (coef%solarcoef) THEN - print*,'dealloc_coef test(5c)' - CALL dealloc_fast_coefs(err, coef%solar) - THROW(err.NE.0) - - print*,'dealloc_coef test(5d)' - CALL dealloc_fast_coefs(err, coef%solar_corr) - THROW(err.NE.0) - ENDIF - - print*,'dealloc_coef test(6)' - - IF (ASSOCIATED(coef%bounds)) DEALLOCATE (coef%bounds, STAT = err) - THROW(err.NE.0) - - - IF (coef%nltecoef) THEN - IF (ASSOCIATED(coef%nlte_coef%coef)) DEALLOCATE(coef%nlte_coef%coef, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%nlte_coef%sol_zen_angle)) DEALLOCATE(coef%nlte_coef%sol_zen_angle, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%nlte_coef%sat_zen_angle)) DEALLOCATE(coef%nlte_coef%sat_zen_angle, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%nlte_coef%cos_sol)) DEALLOCATE(coef%nlte_coef%cos_sol, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%nlte_coef%sec_sat)) DEALLOCATE(coef%nlte_coef%sec_sat, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%nlte_coef)) DEALLOCATE(coef%nlte_coef, STAT = err) - THROW(err.NE.0) - ENDIF - - print*,'dealloc_coef test(7)' - - IF (coef%pmc_shift) THEN - IF (ASSOCIATED(coef%pmc_ppmc)) DEALLOCATE(coef%pmc_ppmc, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%pmc_coef)) DEALLOCATE(coef%pmc_coef, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%pmc_pnominal)) DEALLOCATE(coef%pmc_pnominal, STAT = err) - THROW(err.NE.0) - ENDIF - - print*,'dealloc_coef test(8)' - - IF (ASSOCIATED(coef%planck1)) DEALLOCATE (coef%planck1, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%planck2)) DEALLOCATE (coef%planck2, STAT = err) - THROW(err.NE.0) - - - IF (ASSOCIATED(coef%frequency_ghz)) DEALLOCATE (coef%frequency_ghz, STAT = err) - THROW(err.NE.0) - - - IF (ASSOCIATED(coef%dp)) DEALLOCATE (coef%dp, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%dpp)) DEALLOCATE (coef%dpp, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%tstar)) & - DEALLOCATE (coef%tstar, coef%tstar_r, coef%tstar_wsum_r, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%tstarmod_wsum_r)) & - DEALLOCATE (coef%tstarmod_wsum_r, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%tstar_uwsum_r)) & - DEALLOCATE (coef%tstar_uwsum_r, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%to3star)) & - DEALLOCATE (coef%to3star, coef%to3star_r, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%wstar)) & - DEALLOCATE (coef%wstar, coef%wstar_r, coef%wstar_wsum_r, coef%wtstar_wsum_r, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%ostar)) & - DEALLOCATE (coef%ostar, coef%ostar_r, coef%ostar_wsum_r, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%co2star)) & - DEALLOCATE (coef%co2star, coef%co2star_r, coef%co2star_wsum_r, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%n2ostar)) & - DEALLOCATE (coef%n2ostar, coef%n2ostar_r, coef%n2ostar_wsum_r, coef%n2otstar_wsum_r, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%costar)) & - DEALLOCATE (coef%costar, coef%costar_r, coef%costar_wsum_r, coef%cotstar_wsum_r, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%ch4star)) & - DEALLOCATE (coef%ch4star, coef%ch4star_r, coef%ch4star_wsum_r, coef%ch4tstar_wsum_r, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%so2star)) & - DEALLOCATE (coef%so2star, coef%so2star_r, coef%so2star_wsum_r, coef%so2tstar_wsum_r, STAT = err) - THROW(err.NE.0) - - print*,'dealloc_coef test(9)' - - IF (ASSOCIATED(coef%tt_val_chn)) DEALLOCATE (coef%tt_val_chn, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%tt_a0)) DEALLOCATE (coef%tt_a0, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%tt_a1)) DEALLOCATE (coef%tt_a1, STAT = err) - THROW(err.NE.0) - - print*,'dealloc_coef test(10)' - - IF (ASSOCIATED(coef%pw_val_chn)) DEALLOCATE (coef%pw_val_chn, STAT = err) - THROW(err.NE.0) - - - IF (ASSOCIATED(coef%ss_val_chn)) DEALLOCATE (coef%ss_val_chn, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%ss_solar_spectrum)) DEALLOCATE (coef%ss_solar_spectrum, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%ss_rayleigh_ext)) DEALLOCATE (coef%ss_rayleigh_ext, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%rayleigh_depol_gamma)) DEALLOCATE (coef%rayleigh_depol_gamma, STAT = err) - THROW(err.NE.0) - - print*,'dealloc_coef test(11)' - - IF (ASSOCIATED(coef%refl_visnir_ow)) DEALLOCATE (coef%refl_visnir_ow, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%refl_visnir_fw)) DEALLOCATE (coef%refl_visnir_fw, STAT = err) - THROW(err.NE.0) - - - IF (ASSOCIATED(coef%woc_waopc_ow)) DEALLOCATE (coef%woc_waopc_ow, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%woc_waopc_fw)) DEALLOCATE (coef%woc_waopc_fw, STAT = err) - THROW(err.NE.0) - - print*,'dealloc_coef test(12)' - - IF (ASSOCIATED(coef%ws_k_omega)) DEALLOCATE (coef%ws_k_omega, STAT = err) - THROW(err.NE.0) - - IF (ASSOCIATED(coef%ws_npoint)) DEALLOCATE (coef%ws_npoint, STAT = err) - THROW(err.NE.0) - - print*,'dealloc_coef test(13)' - - CALL rttov_nullify_coef(coef) - - print*,'dealloc_coef test(14)' - - CATCH - - CONTAINS - - SUBROUTINE dealloc_fast_coefs(err, fast_coefs) - USE rttov_types, ONLY : rttov_fast_coef - INTEGER(jpim), INTENT(OUT) :: err - TYPE(rttov_fast_coef), POINTER, INTENT(INOUT) :: fast_coefs(:) - INTEGER(jpim) :: ichan, igas - TRY - print*,'dealloc_fast_coef test(0)' - IF (ASSOCIATED(fast_coefs)) THEN ! If this part of the coef DDT is allocated - print*,'dealloc_fast_coef test(1)' - print*,'SIZE(fast_coefs): ',SIZE(fast_coefs) - DO ichan = 1, SIZE(fast_coefs) ! Iterate over each instrument channel (2378) -! print*,ichan -! print*,(ichan .eq. 52) - IF (ASSOCIATED(fast_coefs(ichan)%gasarray)) THEN ! If this part of the coef DDT is allocated -! if (ichan .eq. 52) print*,'igas: ',igas -! print*,'coef%fmv_gas: ',coef%fmv_gas -! print*,'SIZE(fast_coefs(ichan)%gasarray): ',SIZE(fast_coefs(ichan)%gasarray) - DO igas = 1, coef%fmv_gas ! Iterate over each gas type - if (ichan .eq. 52) then - print*,'igas: ',igas - print*,'igas, SIZE(fast_coefs(ichan)%gasarray(igas)%coef): ',igas,' ',SIZE(fast_coefs(ichan)%gasarray(igas)%coef) - print*,'ASSOCIATED(fast_coefs(ichan)%gasarray(igas)%coef): ',ASSOCIATED(fast_coefs(ichan)%gasarray(igas)%coef) - endif -! if (ichan .eq. 52) print*,'igas: ',igas -! if (ichan .eq. 52) print*,'SIZE(fast_coefs(ichan)%gasarray(igas)%coef): ',SIZE(fast_coefs(ichan)%gasarray(igas)%coef) - IF (ASSOCIATED(fast_coefs(ichan)%gasarray(igas)%coef)) & - DEALLOCATE(fast_coefs(ichan)%gasarray(igas)%coef, STAT = err) - THROW(err.NE.0) - ENDDO - DEALLOCATE(fast_coefs(ichan)%gasarray, STAT = err) - THROW(err.NE.0) - ENDIF - ENDDO - DEALLOCATE(fast_coefs, STAT = err) - THROW(err.NE.0) - ENDIF - CATCH - END SUBROUTINE dealloc_fast_coefs - - END SUBROUTINE rttov_dealloc_coef2 - - - -end module mod_cosp_rttov +!########################## +! Module End +!########################## +end module mod_cosp_rttov \ No newline at end of file From 524b08f1696efd3b99e855bc1c19e6d686bf7808 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Thu, 11 May 2023 14:20:09 -0600 Subject: [PATCH 050/159] Clean up and handling of nchannel_rec options in non-PC-RTTOV calls. --- driver/run/cosp2_pcrttov_nl.txt | 2 +- driver/run/cosp2_rttov_nl.txt | 2 +- src/simulator/cosp_rttov_interface_v13.F90 | 6 ++++ src/simulator/rttov/cosp_rttov_v13.F90 | 35 +++++++--------------- 4 files changed, 18 insertions(+), 27 deletions(-) diff --git a/driver/run/cosp2_pcrttov_nl.txt b/driver/run/cosp2_pcrttov_nl.txt index 5dca3772ba..87f5d940d7 100644 --- a/driver/run/cosp2_pcrttov_nl.txt +++ b/driver/run/cosp2_pcrttov_nl.txt @@ -26,7 +26,7 @@ ! Namelist that sets up the main COSP options &RTTOV_INPUT !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=0, ! 2300 + nchannels_rec=1000, ! 2300 !-------------- RTTOV Filepaths Lchannel_filepath=.false., channel_filepath='rttov_channel_input_AIRS.csv', diff --git a/driver/run/cosp2_rttov_nl.txt b/driver/run/cosp2_rttov_nl.txt index 586a698f49..8d2e9a4dc9 100644 --- a/driver/run/cosp2_rttov_nl.txt +++ b/driver/run/cosp2_rttov_nl.txt @@ -26,7 +26,7 @@ ! Namelist that sets up the main COSP options &RTTOV_INPUT !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=2378, + nchannels_rec=-1, !-------------- RTTOV Filepaths channel_filepath='rttov_channel_input_AIRS.csv' rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 7f563c78e0..d85f284b4d 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -369,12 +369,18 @@ SUBROUTINE COSP_RTTOV_INIT(nchan_out,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Handle different radiance reconstruction options +! print*,'nchannels_rec: ',nchannels_rec if (nchannels_rec < 0) then + print*,'The namelist value nchannels_rec is negative, rttov_direct call will fail. Exiting.' + errorstatus = errorstatus_fatal + call rttov_exit(errorstatus) ! If the number of channels is negative, don't reconstruct radiances at all nchan_out = 0 + nchannels_rec = 0 ! Avoid nchanprof set to a negative value else if (nchannels_rec == 0) then ! If the number of channels is set to 0 then reconstruct all instrument channels nchan_out = coef_rttov % coef % fmv_chn + nchannels_rec = coef_rttov % coef % fmv_chn ! Avoid nchanprof set to 0 else ! Otherwise read the channel list from the file nchan_out = nchannels_rec diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 1b8648c283..d142db1a01 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -264,7 +264,8 @@ subroutine cosp_rttov_allocate(rttovIN & ! Determine the total number of radiances to simulate (nchanprof). ! nchanprof = rttovIN%nChannels * rttovIN%nPoints nchanprof = nChannels_rec * rttovIN%nPoints ! RTTOV (non-PC) needs nchan_out? JKS potential bug - +! print*,'nchanprof: ',nchanprof + ! Allocate structures for rttov_direct call rttov_alloc_direct( & errorstatus, & @@ -323,20 +324,6 @@ subroutine cosp_pc_rttov_allocate(rttovIN & ! ------------------------------------------------------ ! Largely from RTTOV documentation. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -! IF (errorstatus /= errorstatus_success) THEN -! WRITE(*,*) 'rttov_get_pc_predictindex fatal error' -! CALL rttov_exit(errorstatus) -! ENDIF - -! JKS clean this up when done. -! nchannels_rec = rttovIN%nChannels ! Number of channels to reconstruct indicated in namelist. -! nchannels_rec = rttovIN%nChannels ! Number of channels to reconstruct indicated in namelist. - - ! nchannels = SIZE(predictindex) - ! nchanprof = nchannels * nprof ! Size of chanprof array is total number of channels over all profiles - ! npred = SIZE(predictindex) - ! nchanprof = npred * nprof ! Size of chanprof array is total number of channels over all profiles nullify(predictindex) call rttov_get_pc_predictindex(errorstatus, opts, predictindex, file_pccoef=PC_coef_filepath) @@ -786,14 +773,14 @@ subroutine cosp_pc_rttov_save_output(rttovIN, & bt_total, & rad_total - print*,'shape(bt_total): ',shape(bt_total) - print*,'shape(rad_total): ',shape(rad_total) - print*,'rttovIN%nPoints: ',rttovIN%nPoints - print*,'rttovIN%nChannels: ',rttovIN%nChannels - print*,'nchanprof: ',nchanprof - print*,'size(pccomp%bt_pccomp): ',size(pccomp%bt_pccomp) - print*,'size(pccomp%total_pccomp): ',size(pccomp%total_pccomp) - print*,'nchannels_rec * rttovIN%nPoints: ',nchannels_rec * rttovIN%nPoints +! print*,'shape(bt_total): ',shape(bt_total) +! print*,'shape(rad_total): ',shape(rad_total) +! print*,'rttovIN%nPoints: ',rttovIN%nPoints +! print*,'rttovIN%nChannels: ',rttovIN%nChannels +! print*,'nchanprof: ',nchanprof ! This is the number of predictors so not the reconstructed channel dimension +! print*,'size(pccomp%bt_pccomp): ',size(pccomp%bt_pccomp) +! print*,'size(pccomp%total_pccomp): ',size(pccomp%total_pccomp) +! print*,'nchannels_rec * rttovIN%nPoints: ',nchannels_rec * rttovIN%nPoints ! JKS why not just pass in rttovIN%nPoints and use nchannels_rec here? TO-DO? ! Documentation for RTTOV radiance structure in RTTOV User Guide pg 166 @@ -802,13 +789,11 @@ subroutine cosp_pc_rttov_save_output(rttovIN, & if (do_rttov_bt) then bt_total(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & transpose(reshape(pccomp%bt_pccomp(1:(nchannels_rec * rttovIN%nPoints)), (/ rttovIN%nChannels, rttovIN%nPoints/) )) -! transpose(reshape(pccomp%bt_pccomp(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) endif if (do_rttov_rad) then rad_total(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & transpose(reshape(pccomp%total_pccomp(1:(nchannels_rec * rttovIN%nPoints)), (/ rttovIN%nChannels, rttovIN%nPoints/) )) -! transpose(reshape(pccomp%total_pccomp(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) endif end subroutine cosp_pc_rttov_save_output From 2508520c7ed0014f6bd719107c6e4ef34bbe1624 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Thu, 11 May 2023 14:58:12 -0600 Subject: [PATCH 051/159] Polishing changes before multi-instrument integration --- driver/src/cosp2_test.F90 | 8 +++++++- src/simulator/cosp_rttov_interface_v13.F90 | 3 +-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 046a823540..63ef583479 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -1467,7 +1467,7 @@ subroutine destroy_cospIN(y) if (allocated(y%betatot_atlid)) deallocate(y%betatot_atlid) if (allocated(y%tau_mol_atlid)) deallocate(y%tau_mol_atlid) if (allocated(y%tautot_atlid)) deallocate(y%tautot_atlid) - if (allocated(y%fracPrecipIce)) deallocate(y%fracPrecipIce) + if (allocated(y%fracPrecipIce)) deallocate(y%fracPrecipIce) end subroutine destroy_cospIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE destroy_cospstateIN @@ -1485,6 +1485,12 @@ subroutine destroy_cospstateIN(y) if (allocated(y%hgt_matrix)) deallocate(y%hgt_matrix) if (allocated(y%hgt_matrix_half)) deallocate(y%hgt_matrix_half) if (allocated(y%surfelev)) deallocate(y%surfelev) +! Must be allocatable, and these are single values. Waiting for GCM integration +! if (allocated(y%month)) deallocate(y%month) +! if (allocated(y%co2)) deallocate(y%co2) +! if (allocated(y%ch4)) deallocate(y%ch4) +! if (allocated(y%n2o)) deallocate(y%n2o) +! if (allocated(y%co)) deallocate(y%co) if (allocated(y%o3)) deallocate(y%o3) if (allocated(y%u_sfc)) deallocate(y%u_sfc) if (allocated(y%v_sfc)) deallocate(y%v_sfc) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index d85f284b4d..b752a08ff1 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -369,9 +369,8 @@ SUBROUTINE COSP_RTTOV_INIT(nchan_out,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Handle different radiance reconstruction options -! print*,'nchannels_rec: ',nchannels_rec if (nchannels_rec < 0) then - print*,'The namelist value nchannels_rec is negative, rttov_direct call will fail. Exiting.' + print*,'The namelist varaible "nchannels_rec" is negative, rttov_direct call will fail. Exiting.' errorstatus = errorstatus_fatal call rttov_exit(errorstatus) ! If the number of channels is negative, don't reconstruct radiances at all From 7134fc31be0599a3f579d3ee7440db58204122f6 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Fri, 12 May 2023 16:54:08 -0600 Subject: [PATCH 052/159] Initial progress on multi-instrument implementaton. Now reading from individual namelists. Soon to populate rttov_config DDT for each instrument. - Not able to read the array of namelists from the main namelist in cosp2_test. --- driver/run/cosp2_input_rttov_nl.txt | 3 + driver/run/cosp2_output_pcrttov_nl.txt | 1 + driver/run/cosp2_output_rttov_nl.txt | 1 + .../run/instrument_nls/cosp2_rttov_inst1.txt | 71 +++++++ .../run/instrument_nls/cosp2_rttov_inst2.txt | 71 +++++++ .../run/instrument_nls/cosp2_rttov_inst3.txt | 71 +++++++ driver/src/cosp2_test.F90 | 91 ++++++++- src/cosp.F90 | 29 ++- src/simulator/cosp_rttov_interfaceSTUB.F90 | 42 ++++- src/simulator/cosp_rttov_interface_v13.F90 | 175 +++++++++++++++++- src/simulator/rttov/cosp_rttov_v13.F90 | 21 +++ 11 files changed, 562 insertions(+), 14 deletions(-) create mode 100644 driver/run/instrument_nls/cosp2_rttov_inst1.txt create mode 100644 driver/run/instrument_nls/cosp2_rttov_inst2.txt create mode 100644 driver/run/instrument_nls/cosp2_rttov_inst3.txt diff --git a/driver/run/cosp2_input_rttov_nl.txt b/driver/run/cosp2_input_rttov_nl.txt index 53a4b644d5..4b7dadba38 100644 --- a/driver/run/cosp2_input_rttov_nl.txt +++ b/driver/run/cosp2_input_rttov_nl.txt @@ -82,6 +82,9 @@ !---------------------------------------------------------------------------------- !-------------- RTTOV inputs !---------------------------------------------------------------------------------- + rttov_Ninstruments=3, +! rttov_instrument_namelists = (/'test1','test2','test3'/), +! rttov_instrument_namelists(1:3) = (/'test1','test2','test3'/), rttov_Nchannels=2300, ! Number of channels to be computed rttov_Nlocaltime=2, rttov_localtime=10.0,13.0, ! To implement local time diff --git a/driver/run/cosp2_output_pcrttov_nl.txt b/driver/run/cosp2_output_pcrttov_nl.txt index 58b7aa30ac..16120d928a 100644 --- a/driver/run/cosp2_output_pcrttov_nl.txt +++ b/driver/run/cosp2_output_pcrttov_nl.txt @@ -133,6 +133,7 @@ Liwpmodis=.true., Lclmodis=.true., !- RTTOV + Lrttov_run=.true., ! Run RTTOV? Lrttov_bt=.true., ! Calculate RTTOV brightness temps Lrttov_rad=.true., ! Calculate RTTOV radiances Lrttov_refl=.false., ! Calculate RTTOV reflectivities diff --git a/driver/run/cosp2_output_rttov_nl.txt b/driver/run/cosp2_output_rttov_nl.txt index 15524d5e67..168091067e 100755 --- a/driver/run/cosp2_output_rttov_nl.txt +++ b/driver/run/cosp2_output_rttov_nl.txt @@ -133,6 +133,7 @@ Liwpmodis=.true., Lclmodis=.true., !- RTTOV + Lrttov_run=.true., Lrttov_bt=.true., ! Calculate RTTOV brightness temps Lrttov_rad=.true., ! Calculate RTTOV radiances Lrttov_refl=.false., ! Calculate RTTOV reflectivities diff --git a/driver/run/instrument_nls/cosp2_rttov_inst1.txt b/driver/run/instrument_nls/cosp2_rttov_inst1.txt new file mode 100644 index 0000000000..d5f6667a4a --- /dev/null +++ b/driver/run/instrument_nls/cosp2_rttov_inst1.txt @@ -0,0 +1,71 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.true., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec2=1000, ! 2300 + !-------------- RTTOV Filepaths + Lchannel_filepath2=.false., + channel_filepath='rttov_channel_input_AIRS.csv', + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='rttov9pred101L/rtcoef_eos_2_airs_pcrttov_compat.H5', + aer_coef_filepath='cldaer_visir/scaercoef_eos_2_airs_cams.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_airs.H5', + PC_coef_filepath='pc/pccoef_eos_2_airs_landsea.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.false., + CO_data=.false., + CO2_data=.true., + CH4_data=.false., + ozone_data=.true., + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=16, + rttov_ZenAng=0.0, ! Satellite Zenith Angle +/ diff --git a/driver/run/instrument_nls/cosp2_rttov_inst2.txt b/driver/run/instrument_nls/cosp2_rttov_inst2.txt new file mode 100644 index 0000000000..d5f6667a4a --- /dev/null +++ b/driver/run/instrument_nls/cosp2_rttov_inst2.txt @@ -0,0 +1,71 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.true., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec2=1000, ! 2300 + !-------------- RTTOV Filepaths + Lchannel_filepath2=.false., + channel_filepath='rttov_channel_input_AIRS.csv', + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='rttov9pred101L/rtcoef_eos_2_airs_pcrttov_compat.H5', + aer_coef_filepath='cldaer_visir/scaercoef_eos_2_airs_cams.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_airs.H5', + PC_coef_filepath='pc/pccoef_eos_2_airs_landsea.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.false., + CO_data=.false., + CO2_data=.true., + CH4_data=.false., + ozone_data=.true., + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=16, + rttov_ZenAng=0.0, ! Satellite Zenith Angle +/ diff --git a/driver/run/instrument_nls/cosp2_rttov_inst3.txt b/driver/run/instrument_nls/cosp2_rttov_inst3.txt new file mode 100644 index 0000000000..d5f6667a4a --- /dev/null +++ b/driver/run/instrument_nls/cosp2_rttov_inst3.txt @@ -0,0 +1,71 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.true., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec2=1000, ! 2300 + !-------------- RTTOV Filepaths + Lchannel_filepath2=.false., + channel_filepath='rttov_channel_input_AIRS.csv', + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='rttov9pred101L/rtcoef_eos_2_airs_pcrttov_compat.H5', + aer_coef_filepath='cldaer_visir/scaercoef_eos_2_airs_cams.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_airs.H5', + PC_coef_filepath='pc/pccoef_eos_2_airs_landsea.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.false., + CO_data=.false., + CO2_data=.true., + CH4_data=.false., + ozone_data=.true., + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=16, + rttov_ZenAng=0.0, ! Satellite Zenith Angle +/ diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 63ef583479..14f9aee547 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -68,6 +68,7 @@ program cosp2_test use cosp_optics, ONLY: cosp_simulator_optics,lidar_optics,modis_optics, & modis_optics_partition use mod_cosp_stats, ONLY: COSP_CHANGE_VERTICAL_GRID + use MOD_COSP_RTTOV_INTERFACE, only: rttov_cfg implicit none @@ -134,8 +135,10 @@ program cosp2_test overlap, & ! Overlap type: 1=max, 2=rand, 3=max/rand isccp_topheight, & ! ISCCP cloud top height isccp_topheight_direction, & ! ISCCP cloud top height direction +! rttov_Ninstruments, & ! RTTOV: Number of instruments to simulate rttov_Nchannels, & ! RTTOV: Number of channels to be computed rttov_Nlocaltime ! RTTOV: Number of local times to be computed + integer :: rttov_Ninstruments = 0 real(wp) :: & ! cloudsat_radar_freq, & ! CloudSat radar frequency (GHz) cloudsat_k2 ! |K|^2, -1=use frequency dependent default @@ -157,11 +160,17 @@ program cosp2_test dinput ! Directory where the input files are located character(len=600) :: & fileIN ! dinput+finput + type(character(len=256)), allocatable, dimension(:) :: & + rttov_instrument_namelists ! Array of paths to RTTOV instrument namelists +! type(integer), allocatable, dimension(:) :: & +! rttov_instrument_Nchannels + namelist/COSP_INPUT/overlap, isccp_topheight, isccp_topheight_direction, npoints, & npoints_it, ncolumns, nlevels, use_vgrid, Nlvgrid, csat_vgrid, dinput, finput, & foutput, cloudsat_radar_freq, surface_radar, cloudsat_use_gas_abs,cloudsat_do_ray,& cloudsat_k2, cloudsat_micro_scheme, lidar_ice_type, use_precipitation_fluxes, & - rttov_Nchannels, rttov_Nlocaltime, rttov_localtime, rttov_localtimewindow + rttov_Nchannels, rttov_Nlocaltime, rttov_localtime, rttov_localtimewindow, & + rttov_Ninstruments,rttov_instrument_namelists ! Output namelist logical :: Lcfaddbze94,Ldbze94,Latb532,LcfadLidarsr532,Lclcalipso,Lclhcalipso, & @@ -186,6 +195,7 @@ program cosp2_test Lptradarflag4,Lptradarflag5,Lptradarflag6,Lptradarflag7,Lptradarflag8, & Lptradarflag9,Lradarpia, & Lwr_occfreq,Lcfodd + logical :: Lrttov_run = .false. logical :: Lrttov_bt = .false. logical :: Lrttov_rad = .false. logical :: Lrttov_refl = .false. @@ -217,6 +227,7 @@ program cosp2_test Lclmmodis,Lcllmodis,Ltautmodis,Ltauwmodis,Ltauimodis, & Ltautlogmodis,Ltauwlogmodis,Ltauilogmodis,Lreffclwmodis, & Lreffclimodis,Lpctmodis,Llwpmodis,Liwpmodis,Lclmodis, & + Lrttov_run, & Lrttov_bt, Lrttov_rad, Lrttov_refl, & ! RTTOV output fields Lrttov_cld, Lrttov_cldparam,Lrttov_aer, Lrttov_aerparam, & ! RTTOV cld/aero Lrttov_localtime,Lrttov_pc, & ! RTTOV other @@ -241,13 +252,15 @@ program cosp2_test sd ! Hydrometeor description type(radar_cfg) :: & rcfg_cloudsat ! Radar configuration + type(rttov_cfg), dimension(:), allocatable :: & + rttov_configs type(cosp_outputs) :: & cospOUT ! COSP simulator outputs type(cosp_optical_inputs) :: & cospIN ! COSP optical (or derived?) fields needed by simulators type(cosp_column_inputs) :: & cospstateIN ! COSP model fields needed by simulators - integer :: iChunk,nChunks,start_idx,end_idx,nPtsPerIt,ij + integer :: iChunk,nChunks,start_idx,end_idx,nPtsPerIt,ij,inst_idx real(wp),dimension(10) :: driver_time character(len=256),dimension(100) :: cosp_status @@ -283,6 +296,17 @@ program cosp2_test gamma_2 = (/-1., -1., 6.0, 6.0, -1., -1., 6.0, 6.0, 6.0/),& gamma_3 = (/-1., -1., 2.0, 2.0, -1., -1., 2.0, 2.0, 2.0/),& gamma_4 = (/-1., -1., 6.0, 6.0, -1., -1., 6.0, 6.0, 6.0/) + +! logical, allocatable, dimension(:) :: & +! Lrttov_inst_bt, & +! Lrttov_inst_rad, & +! Lrttov_inst_refl, & +! Lrttov_inst_cld, & +! Lrttov_inst_aer, & +! Lrttov_inst_pc + +! type(rttov_instrument_config), allocatable :: rttov_instrument_configs ! JKS this won't work. DDTs would have to be in cosp.F90 + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% call cpu_time(driver_time(1)) @@ -309,7 +333,55 @@ program cosp2_test else rttov_input_namelist = 'false' endif - + + ! Jonah namelist checking area + print*,'Lrttov_run: ',Lrttov_run + print*,'rttov_Ninstruments: ',rttov_Ninstruments + allocate(rttov_instrument_namelists(rttov_Ninstruments)) + +! if (Lrttov_run) then +! namelist/COSP_INPUT/rttov_instrument_namelists +! endif + +! open(10,file=cosp_input_namelist,status='unknown') +! read(10,nml=cosp_input) + +! print*,'rttov_instrument_namelists: ',rttov_instrument_namelists + rttov_instrument_namelists(1:3) = (/'instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt'/) + print*,'rttov_instrument_namelists: ',rttov_instrument_namelists + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Read in Logical arguments needed to construct outputs from RTTOV instrument namelists. + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +! allocate(Lrttov_inst_bt(rttov_Ninstruments),Lrttov_inst_rad(rttov_Ninstruments), & +! Lrttov_inst_refl(rttov_Ninstruments),Lrttov_inst_cld(rttov_Ninstruments), & +! Lrttov_inst_aer(rttov_Ninstruments),Lrttov_inst_pc(rttov_Ninstruments)) +! allocate(rttov_instrument_Nchannels(rttov_Ninstruments)) + +! do inst_idx=1,rttov_Ninstruments +! namelist/RTTOV_CONFIG/Lrttov_bt,Lrttov_rad,Lrttov_refl,Lrttov_cld,Lrttov_aer, & +! Lrttov_pc + +! open(10,file=rttov_instrument_namelists(inst_idx),status='unknown') +! read(10,nml=RTTOV_CONFIG) ! I needed to break up the namelist because I can't read a subset of values. This is weird. + +! Lrttov_inst_bt(inst_idx) = Lrttov_bt +! Lrttov_inst_rad(inst_idx) = Lrttov_rad +! Lrttov_inst_refl(inst_idx) = Lrttov_refl +! Lrttov_inst_cld(inst_idx) = Lrttov_cld +! Lrttov_inst_aer(inst_idx) = Lrttov_aer +! Lrttov_inst_pc(inst_idx) = Lrttov_pc +! end do + + +! print*,'Lrttov_inst_bt: ',Lrttov_inst_bt +! print*,'Lrttov_inst_rad: ',Lrttov_inst_rad +! print*,'Lrttov_inst_refl: ',Lrttov_inst_refl +! print*,'Lrttov_inst_cld: ',Lrttov_inst_cld +! print*,'Lrttov_inst_aer: ',Lrttov_inst_aer +! print*,'Lrttov_inst_pc: ',Lrttov_inst_pc + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Read in sample input data. !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -372,6 +444,8 @@ program cosp2_test Lptradarflag6 .or. Lptradarflag7 .or. Lptradarflag8 .or. Lptradarflag9 .or. & Lradarpia) Lcloudsat = .true. if (Lparasolrefl) Lparasol = .true. + + ! JKS - This will need to be revamped. Each instrument needs these flags if ((Lrttov_bt .or. Lrttov_rad .or. Lrttov_refl) .and. (rttov_input_namelist /= 'false')) Lrttov = .true. if ((Lrttov_bt .or. Lrttov_rad .or. Lrttov_refl) .and. (rttov_input_namelist .eq. 'false')) then print*,'An RTTOV output must be true and a RTTOV namelist must be provided to run RTTOV.' @@ -417,7 +491,11 @@ program cosp2_test cloudsat_do_ray, isccp_topheight, isccp_topheight_direction, surface_radar, & rcfg_cloudsat, use_vgrid, csat_vgrid, Nlvgrid, Nlevels, cloudsat_micro_scheme, & rttov_Nchannels, Lrttov_bt, Lrttov_rad, Lrttov_refl, Lrttov_cld, Lrttov_aer, & - Lrttov_cldparam, Lrttov_aerparam,Lrttov_pc,rttov_input_namelist) + Lrttov_cldparam, Lrttov_aerparam,Lrttov_pc,rttov_input_namelist, & + rttov_Ninstruments, rttov_instrument_namelists, rttov_configs)!, rttov_instrument_Nchannels) +! Lrttov_run,rttov_Ninstruments,rttov_instrument_namelists, & ! Input logical, input N instr., instr. nls +! rttov_instrument_configs, & ! Output object is an array of N rttov_config_opts ! JKS can this be a pointer? +! ) call cpu_time(driver_time(3)) !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -574,7 +652,8 @@ program cosp2_test print*,'COSP_SIMULATOR successful' ! jks call cpu_time(driver_time(7)) - enddo + end do + print*,'Time to read in data: ',driver_time(2)-driver_time(1) print*,'Time to initialize: ',driver_time(3)-driver_time(2) print*,'Time to construct types: ',driver_time(4)-driver_time(3) @@ -1396,7 +1475,7 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& ! Combined CALIPSO/CLOUDSAT fields if (Lclcalipso2) allocate(x%lidar_only_freq_cloud(Npoints,Nlvgrid)) if (Lcltlidarradar) allocate(x%radar_lidar_tcc(Npoints)) - if (Lcloudsat_tcc) allocate(x%cloudsat_tcc(Npoints)) + if (Lcloudsat_tcc) allocate(x%cloudsat_tcc(Npoints)) if (Lcloudsat_tcc2) allocate(x%cloudsat_tcc2(Npoints)) ! RTTOV - Only add non-total fields if clouds or aerosols are simulated diff --git a/src/cosp.F90 b/src/cosp.F90 index bd4aa0c747..b633cd9170 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -53,8 +53,10 @@ MODULE MOD_COSP USE MOD_COSP_MODIS_INTERFACE, ONLY: cosp_modis_init, modis_IN USE MOD_COSP_RTTOV_INTERFACE, ONLY: & cosp_rttov_init, & + COSP_RTTOV_INI2, & cosp_rttov_simulate, & - cosp_pc_rttov_simulate + cosp_pc_rttov_simulate, & + rttov_cfg USE MOD_COSP_MISR_INTERFACE, ONLY: cosp_misr_init, misr_IN USE MOD_COSP_ISCCP_INTERFACE, ONLY: cosp_isccp_init, isccp_IN USE MOD_COSP_CALIPSO_INTERFACE, ONLY: cosp_calipso_init, calipso_IN @@ -172,6 +174,8 @@ MODULE MOD_COSP fracPrecipIce ! Fraction of precipitation which is frozen (1). type(radar_cfg) :: & rcfg_cloudsat ! Radar configuration information (CLOUDSAT) + type(rttov_cfg),allocatable,dimension(:) :: & + cfg_rttov ! RTTOV configuration information (multiple instruments) end type cosp_optical_inputs ! ###################################################################################### @@ -1846,7 +1850,8 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La luseCSATvgrid, Nvgrid, Nlevels, cloudsat_micro_scheme, & NchanIN, Lrttov_bt, Lrttov_rad, Lrttov_refl, & Lrttov_cld, Lrttov_aer, Lrttov_cldparam, Lrttov_aerparam, Lrttov_pc, & - rttov_input_namelist) + rttov_input_namelist, & + rttov_Ninstruments, rttov_instrument_namelists,rttov_configs) !, rttov_instrument_Nchannels) ! INPUTS logical,intent(in) :: Lisccp,Lmodis,Lmisr,Lcloudsat,Lcalipso,LgrLidar532,Latlid,Lparasol,Lrttov @@ -1862,7 +1867,8 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La isccp_top_height_direction, & ! Nlevels, & ! Nvgrid, & ! Number of levels for new L3 grid - surface_radar ! + surface_radar, & ! + rttov_Ninstruments ! integer,pointer,intent(inout) :: & integer,intent(inout) :: & NchanIN @@ -1879,8 +1885,16 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La character(len=256),intent(in) :: rttov_input_namelist + type(character(len=256)), dimension(rttov_Ninstruments) :: & + rttov_instrument_namelists ! Array of paths to RTTOV instrument namelists + ! OUTPUTS type(radar_cfg) :: rcfg +! type(rttov_cfg), :: rttov_configs + type(rttov_cfg), dimension(:), allocatable :: rttov_configs +! type(rttov_cfg), dimension(rttov_Ninstruments) :: rttov_configs +! type(rttov_cfg), allocatable :: rttov_configs(:) +! integer,intent(out),dimension(rttov_Ninstruments) :: rttov_instrument_Nchannels ! Local variables integer :: i @@ -1925,14 +1939,21 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La if (Lmodis) call cosp_modis_init() if (Lmisr) call cosp_misr_init() + ! I think that I will try to store an object of rttov_init_objects here, + ! Could print diagnostic on timing here. +! rttov_instrument_Nchannels(:) = 0 ! initialize at 0 ! JKS clean up if (Lrttov) then call cpu_time(driver_time(1)) + call cosp_rttov_ini2(Nlevels,rttov_Ninstruments, & + rttov_instrument_namelists, & + rttov_configs) call cosp_rttov_init(NchanIN, Nlevels, & Lrttov_bt,Lrttov_rad,Lrttov_refl, & Lrttov_cld,Lrttov_aer, & Lrttov_cldparam,Lrttov_aerparam, & - Lrttov_pc,rttov_input_namelist) + Lrttov_pc,rttov_input_namelist) + call cpu_time(driver_time(2)) print*,'Time to run cosp_rttov_init: ',driver_time(2)-driver_time(1) endif diff --git a/src/simulator/cosp_rttov_interfaceSTUB.F90 b/src/simulator/cosp_rttov_interfaceSTUB.F90 index fe9ccd25c4..6ea698c5ff 100644 --- a/src/simulator/cosp_rttov_interfaceSTUB.F90 +++ b/src/simulator/cosp_rttov_interfaceSTUB.F90 @@ -35,9 +35,49 @@ MODULE MOD_COSP_RTTOV_INTERFACE ! USE MOD_COSP_CONFIG, ONLY: RTTOV_MAX_CHANNELS,rttovDir USE MOD_COSP_RTTOV, ONLY: rttov_IN IMPLICIT NONE - + + + ! DDT for each instrument being simulated. Values to be assigned during the cosp_rttov_init subroutine + type rttov_cfg + logical :: & + Lrttov_bt, & + Lrttov_rad, & + Lrttov_refl, & + Lrttov_cld, & + Lrttov_aer, & + Lrttov_cldparam, & + Lrttov_aerparam, & + Lrttov_pc + character(len=256) :: & + rttov_srcDir, & + rttov_coefDir, & + OD_coef_filepath, & + aer_coef_filepath, & + cld_coef_filepath, & + PC_coef_filepath + end type rttov_cfg + CONTAINS + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE cosp_rttov_ini2 + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE COSP_RTTOV_INI2(Nlevels,Ninstruments,instrument_namelists, & + rttov_config) + + integer,intent(in) :: & + Nlevels, & + Ninstruments + type(character(len=256)), dimension(Ninstruments) :: & + instrument_namelists ! Array of paths to RTTOV instrument namelists + type(rttov_cfg), dimension(Ninstruments) :: & ! intent(out)? + rttov_config + + + END SUBROUTINE COSP_RTTOV_INI2 + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_init !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index b752a08ff1..3645c9a41c 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -72,9 +72,180 @@ MODULE MOD_COSP_RTTOV_INTERFACE INTEGER(KIND=jpim) :: alloc_status(60) + + ! DDT for each instrument being simulated. Values to be assigned during the cosp_rttov_init subroutine + type rttov_cfg + logical(KIND=jplm) :: & + Lrttov_bt, & + Lrttov_rad, & + Lrttov_refl, & + Lrttov_cld, & + Lrttov_aer, & + Lrttov_cldparam, & + Lrttov_aerparam, & + Lrttov_pc + character(len=256) :: & + rttov_srcDir, & + rttov_coefDir, & + OD_coef_filepath, & + aer_coef_filepath, & + cld_coef_filepath, & + PC_coef_filepath + integer :: & + nchan_out + end type rttov_cfg + CONTAINS + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE cosp_rttov_ini2 + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE COSP_RTTOV_INI2(Nlevels,Ninstruments,instrument_namelists, & + rttov_configs) + + integer,intent(in) :: & + Nlevels, & + Ninstruments + type(character(len=256)), dimension(Ninstruments) :: & + instrument_namelists ! Array of paths to RTTOV instrument namelists + type(rttov_cfg), dimension(:), allocatable :: & ! intent(out)? + rttov_configs + ! Local variables + integer :: & + inst_idx ! iterator + + allocate(rttov_configs(Ninstruments)) + + ! Create config objects for each instrument to be simulated by RTTOV. Return to the main subroutine. + do inst_idx=1,Ninstruments + print*,'inst_idx: ',inst_idx + print*,'Nlevels: ',Nlevels + print*,'instrument_namelists(inst_idx): ',instrument_namelists(inst_idx) +! print*,'kind(rttov_configs(inst_idx)): ',kind(rttov_configs(inst_idx)) +! print*,'rttov_configs(inst_idx): ',rttov_configs(inst_idx) + call cosp_rttov_init_s(Nlevels,instrument_namelists(inst_idx),rttov_configs(inst_idx)) + end do + + + END SUBROUTINE COSP_RTTOV_INI2 + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE cosp_rttov_init + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & + rttov_config) + + integer,intent(in) :: & + Nlevels + character(len=256),intent(in) :: & + namelist_filepath ! Array of paths to RTTOV instrument namelists + type(rttov_cfg),intent(out) :: & ! intent(out)? + rttov_config + + ! Local variables + character(len=256) :: & + channel_filepath, & + rttov_srcDir, & + rttov_coefDir, & + OD_coef_filepath, & + aer_coef_filepath, & + cld_coef_filepath, & + PC_coef_filepath + + real(wp) :: & + CO2_mr, & + CH4_mr, & + CO_mr, & + N2O_mr, & + SO2_mr, & + rttov_ZenAng + + ! Declare RTTOV namelist fields + logical :: Lrttov_bt = .false. + logical :: Lrttov_rad = .false. + logical :: Lrttov_refl = .false. + logical :: Lrttov_cld = .false. + logical :: Lrttov_aer = .false. + logical :: Lrttov_cldparam = .false. + logical :: Lrttov_aerparam = .false. + logical :: Lrttov_pc = .false. + + logical :: Lchannel_filepath2 = .false. + + logical :: SO2_data = .false. + logical :: N2O_data = .false. + logical :: CO_data = .false. + logical :: CO2_data = .false. + logical :: CH4_data = .false. + logical :: ozone_data = .false. + + character(len=256) :: cosp_status + integer :: & + i, & + rttov_nthreads, & + nchannels_rec2 + + integer(kind=jpim) :: & + ipcbnd, & + ipcreg, & + npcscores + + print*,'t1.' + rttov_config%Lrttov_bt = .false. ! Set something in the rttov_config DDT, anything... + + ! Read RTTOV namelist fields + namelist/RTTOV_INPUT/Lrttov_bt,Lrttov_rad,Lrttov_refl,Lrttov_cld, & ! Logicals for RTTOV configuration + Lrttov_aer,Lrttov_cldparam,Lrttov_aerparam, & ! + Lrttov_pc,nchannels_rec2,Lchannel_filepath2, & + channel_filepath,rttov_srcDir,rttov_coefDir, & + OD_coef_filepath,aer_coef_filepath,cld_coef_filepath, & + PC_coef_filepath, & + CO2_data,CH4_data,CO_data,N2O_data,SO2_data,ozone_data, & ! User-supplied trace gas concentrations + CO2_mr,CH4_mr,CO_mr,N2O_mr,SO2_mr, & ! Mixing ratios + ipcbnd,ipcreg,npcscores, & ! PC-RTTOV config values + rttov_nthreads,rttov_ZenAng + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Read in namelists + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + print*,'t2.' + open(10,file=namelist_filepath,status='unknown') + read(10,nml=RTTOV_INPUT) + close(10) + + + print*,'t3.' + ! Initialize fields in module memory (cosp_rttovXX.F90) + rttovDir = rttov_srcDir + + !! JKS stopping here. + + ! subsub routines + contains + ! Wrapper function for exiting RTTOV and reporting the error + subroutine rttov_error(msg, lalloc) + character(*) :: msg + logical :: lalloc + + if(lalloc) then + if (any(alloc_status /= 0)) then + write(*,*) msg + errorstatus = 1 + call rttov_exit(errorstatus) + endif + else + if (errorstatus /= errorstatus_success) then + write(*,*) msg + call rttov_exit(errorstatus) + endif + endif + end subroutine rttov_error + + END SUBROUTINE COSP_RTTOV_INIT_S + + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_init !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -101,8 +272,6 @@ SUBROUTINE COSP_RTTOV_INIT(nchan_out,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, ! Local variables character(len=256) :: & - coef_file, & - scat_file, & rttov_srcDir, & rttov_coefDir, & OD_coef_file, & @@ -370,7 +539,7 @@ SUBROUTINE COSP_RTTOV_INIT(nchan_out,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, ! Handle different radiance reconstruction options if (nchannels_rec < 0) then - print*,'The namelist varaible "nchannels_rec" is negative, rttov_direct call will fail. Exiting.' + print*,'The namelist variable "nchannels_rec" is negative, rttov_direct call will fail. Exiting.' errorstatus = errorstatus_fatal call rttov_exit(errorstatus) ! If the number of channels is negative, don't reconstruct radiances at all diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index d142db1a01..4660835834 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -217,6 +217,27 @@ module mod_cosp_rttov fl_rain, & ! Precipitation flux (startiform+convective rain) (kg/m2/s) fl_snow ! Precipitation flux (stratiform+convective snow) end type rttov_IN + + ! DDT for each instrument being simulated. Values to be assigned during the cosp_rttov_init subroutine + type rttov_instrument_config + logical(KIND=jplm) :: & + Lrttov_bt, & + Lrttov_rad, & + Lrttov_refl, & + Lrttov_cld, & + Lrttov_aer, & + Lrttov_cldparam, & + Lrttov_aerparam, & + Lrttov_pc + character(len=256) :: & + rttov_srcDir, & + rttov_coefDir, & + OD_coef_filepath, & + aer_coef_filepath, & + cld_coef_filepath, & + PC_coef_filepath + end type rttov_instrument_config + contains From 71c47b09e083969e201df7763aa39cd9a946876c Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Fri, 19 May 2023 18:16:16 -0600 Subject: [PATCH 053/159] Progress towards multi-instrument RTTOV implementation. RTTOV config DDTs are created during init. RTTOV output DDTs are now a part of the cosp_output DDT. To-do: - Add multi-instrument support for rttov_simulate (PC and non-PC) - Add multi-instrument support for writing RTTOV outputs. --- .../run/instrument_nls/cosp2_rttov_inst1.txt | 1 + .../run/instrument_nls/cosp2_rttov_inst2.txt | 7 +- .../run/instrument_nls/cosp2_rttov_inst3.txt | 9 +- driver/src/cosp2_test.F90 | 148 +++++++- src/cosp.F90 | 19 +- src/simulator/cosp_rttov_interface_v13.F90 | 346 +++++++++++++++--- src/simulator/rttov/cosp_rttov_v13.F90 | 9 +- 7 files changed, 467 insertions(+), 72 deletions(-) diff --git a/driver/run/instrument_nls/cosp2_rttov_inst1.txt b/driver/run/instrument_nls/cosp2_rttov_inst1.txt index d5f6667a4a..a0e69018ab 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst1.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst1.txt @@ -52,6 +52,7 @@ CO2_data=.true., CH4_data=.false., ozone_data=.true., + clw_data=.false., ! Only used for MW calculations ! -------------- RTTOV Trace Gas Concentrations ! -------------- Specify units in RTTOV options set-up ! ---------------Standard units are kg/kg over moist air diff --git a/driver/run/instrument_nls/cosp2_rttov_inst2.txt b/driver/run/instrument_nls/cosp2_rttov_inst2.txt index d5f6667a4a..e12705a79b 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst2.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst2.txt @@ -29,13 +29,13 @@ Lrttov_bt=.true., ! Calculate RTTOV brightness temps Lrttov_rad=.true., ! Calculate RTTOV radiances Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cld=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values Lrttov_cldparam=.false., ! Use user input cloud optical parameters Lrttov_aerparam=.false., ! Use user input aerosol optical parameters Lrttov_pc=.false., ! Run with PC-RTTOV !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec2=1000, ! 2300 + nchannels_rec2=500, ! 2300 !-------------- RTTOV Filepaths Lchannel_filepath2=.false., channel_filepath='rttov_channel_input_AIRS.csv', @@ -52,6 +52,7 @@ CO2_data=.true., CH4_data=.false., ozone_data=.true., + clw_data=.false., ! Only used for MW calculations ! -------------- RTTOV Trace Gas Concentrations ! -------------- Specify units in RTTOV options set-up ! ---------------Standard units are kg/kg over moist air diff --git a/driver/run/instrument_nls/cosp2_rttov_inst3.txt b/driver/run/instrument_nls/cosp2_rttov_inst3.txt index d5f6667a4a..58c34cfdc0 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst3.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst3.txt @@ -29,13 +29,13 @@ Lrttov_bt=.true., ! Calculate RTTOV brightness temps Lrttov_rad=.true., ! Calculate RTTOV radiances Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cld=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values Lrttov_cldparam=.false., ! Use user input cloud optical parameters Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_pc=.false., ! Run with PC-RTTOV + Lrttov_pc=.true., ! Run with PC-RTTOV !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec2=1000, ! 2300 + nchannels_rec2=250, ! 2300 !-------------- RTTOV Filepaths Lchannel_filepath2=.false., channel_filepath='rttov_channel_input_AIRS.csv', @@ -52,6 +52,7 @@ CO2_data=.true., CH4_data=.false., ozone_data=.true., + clw_data=.false., ! Only used for MW calculations ! -------------- RTTOV Trace Gas Concentrations ! -------------- Specify units in RTTOV options set-up ! ---------------Standard units are kg/kg over moist air diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 14f9aee547..ebdbb4a845 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -497,7 +497,7 @@ program cosp2_test ! rttov_instrument_configs, & ! Output object is an array of N rttov_config_opts ! JKS can this be a pointer? ! ) call cpu_time(driver_time(3)) - + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Construct output derived type. ! *NOTE* The "construct/destroy" subroutines are local to this module and should be @@ -525,6 +525,7 @@ program cosp2_test Lptradarflag0,Lptradarflag1,Lptradarflag2,Lptradarflag3,Lptradarflag4, & Lptradarflag5,Lptradarflag6,Lptradarflag7,Lptradarflag8,Lptradarflag9,Lradarpia, & Lwr_occfreq, Lcfodd, & + rttov_Ninstruments,rttov_configs, & Lrttov_bt, Lrttov_rad, Lrttov_refl, & Npoints, Ncolumns, Nlevels, Nlvgrid_local, rttov_Nchannels, cospOUT) @@ -1204,8 +1205,9 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& Lptradarflag3,Lptradarflag4,Lptradarflag5, & Lptradarflag6,Lptradarflag7,Lptradarflag8, & Lptradarflag9,Lradarpia,Lwr_occfreq,Lcfodd, & - Lrttov_bt,Lrttov_rad,Lrttov_refl, & - Npoints,Ncolumns,Nlevels,Nlvgrid,Nchan,x) + N_rttov_instruments,rttov_configs, & + Lrttov_bt,Lrttov_rad,Lrttov_refl, & ! JKS remove when going multi-instrument + Npoints,Ncolumns,Nlevels,Nlvgrid,Nchan,x) ! JKS remove Nchan when going multi-instrument ! Inputs logical,intent(in) :: & Lpctisccp, & ! ISCCP mean cloud top pressure @@ -1324,11 +1326,21 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& Ncolumns, & ! Number of subgrid columns Nlevels, & ! Number of model levels Nlvgrid, & ! Number of levels in L3 stats computation - Nchan ! Number of RTTOV channels + Nchan, & ! Number of RTTOV channels + N_rttov_instruments +! integer,dimension(N_rttov_instruments),intent(in) :: & +! rttov_instrument_nchannels + + type(rttov_cfg), dimension(N_rttov_instruments),intent(in) :: & + rttov_configs + ! Outputs type(cosp_outputs),intent(out) :: & x ! COSP output structure + + integer :: & + i ! ISCCP simulator outputs if (Lboxtauisccp) allocate(x%isccp_boxtau(Npoints,Ncolumns)) @@ -1478,6 +1490,11 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& if (Lcloudsat_tcc) allocate(x%cloudsat_tcc(Npoints)) if (Lcloudsat_tcc2) allocate(x%cloudsat_tcc2(Npoints)) + ! 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)) + + ! JKS remove when going multi-instrument ! RTTOV - Only add non-total fields if clouds or aerosols are simulated if (Lrttov_pc) then ! Treat PC-RTTOV fields as clear-sky only for now allocate(x%rttov_Ichannel(Nchan)) @@ -1506,11 +1523,63 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_refl_clear(Npoints,Nchan)) endif endif - - - ! 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)) + + ! RTTOV - Allocate output for multiple instruments + ! Do I not need to allocate the number of instruments? Because each rttov output DDT will be a pointer? + x % N_rttov_instruments = N_rttov_instruments + allocate(x % rttov_outputs(N_rttov_instruments)) ! Need to allocate a pointer? + do i=1,N_rttov_instruments + print*,'i: ',i + print*,'rttov_configs(i) % nchan_out: ',rttov_configs(i) % nchan_out + print*,'rttov_configs(i) % Lrttov_bt: ',rttov_configs(i) % Lrttov_bt + print*,'rttov_configs(i) % Lrttov_rad: ',rttov_configs(i) % Lrttov_rad + print*,'rttov_configs(i) % Lrttov_refl: ',rttov_configs(i) % Lrttov_refl + print*,'rttov_configs(i) % opts % rt_ir % addaerosl: ',rttov_configs(i) % opts % rt_ir % addaerosl + print*,'rttov_configs(i) % opts % rt_ir % addclouds: ',rttov_configs(i) % opts % rt_ir % addclouds + print*,'rttov_configs(i) % opts % rt_ir % user_aer_opt_param: ',rttov_configs(i) % opts % rt_ir % user_aer_opt_param + print*,'rttov_configs(i) % opts % rt_ir % user_cld_opt_param: ',rttov_configs(i) % opts % rt_ir % user_cld_opt_param + print*,'rttov_configs(i) % Lrttov_pc: ',rttov_configs(i) % Lrttov_pc + + print*,'1.' + if (rttov_configs(i) % Lrttov_pc) then ! Treat PC-RTTOV fields as clear-sky only for now + print*,'2a.' + allocate(x % rttov_outputs(i) % channel_indices(rttov_configs(i) % nchan_out)) + if (rttov_configs(i) % Lrttov_bt) then ! Brightness temp + allocate(x % rttov_outputs(i) % bt_total_pc(Npoints,rttov_configs(i) % nchan_out)) + ! if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_bt_clear(Npoints,Nchan)) + endif + if (rttov_configs(i) % Lrttov_rad) then ! Radiance + allocate(x % rttov_outputs(i) % rad_total_pc(Npoints,rttov_configs(i) % nchan_out)) + ! if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_rad_clear(Npoints,Nchan)) + ! if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_rad_cloudy(Npoints,Nchan)) + endif + else + print*,'3a.' + allocate(x % rttov_outputs(i) % channel_indices(rttov_configs(i) % nchan_out)) + if (rttov_configs(i) % Lrttov_bt) then ! Brightness temp + allocate(x % rttov_outputs(i) % bt_total(Npoints,rttov_configs(i) % nchan_out)) + if ((rttov_configs(i) % opts % rt_ir % addclouds) .or. (rttov_configs(i) % opts % rt_ir % addaerosl)) then + allocate(x % rttov_outputs(i) % bt_clear(Npoints,rttov_configs(i) % nchan_out)) + end if + endif + if (rttov_configs(i) % Lrttov_rad) then ! Radiance + allocate(x % rttov_outputs(i) % rad_total(Npoints,rttov_configs(i) % nchan_out)) + if ((rttov_configs(i) % opts % rt_ir % addclouds) .or. (rttov_configs(i) % opts % rt_ir % addaerosl)) then + allocate(x % rttov_outputs(i) % rad_clear(Npoints,rttov_configs(i) % nchan_out)) + end if + if ((rttov_configs(i) % opts % rt_ir % addclouds) .or. (rttov_configs(i) % opts % rt_ir % addaerosl)) then + allocate(x % rttov_outputs(i) % rad_cloudy(Npoints,rttov_configs(i) % nchan_out)) + end if + endif + if (rttov_configs(i) % Lrttov_refl) then ! Reflectance + allocate(x % rttov_outputs(i) % refl_total(Npoints,rttov_configs(i) % nchan_out)) + if ((rttov_configs(i) % opts % rt_ir % addclouds) .or. (rttov_configs(i) % opts % rt_ir % addaerosl)) then + allocate(x % rttov_outputs(i) % refl_clear(Npoints,rttov_configs(i) % nchan_out)) + end if + endif + endif + + end do end subroutine construct_cosp_outputs @@ -1591,6 +1660,7 @@ end subroutine destroy_cospstateIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine destroy_cosp_outputs(y) type(cosp_outputs),intent(inout) :: y + integer :: i ! Local iterator for RTTOV instruments ! Deallocate and nullify if (associated(y%calipso_beta_mol)) then @@ -1934,7 +2004,65 @@ subroutine destroy_cosp_outputs(y) if (associated(y%rttov_refl_clear)) then deallocate(y%rttov_refl_clear) nullify(y%rttov_refl_clear) - endif + endif + if (associated(y%rttov_bt_total_pc)) then + deallocate(y%rttov_bt_total_pc) + nullify(y%rttov_bt_total_pc) + endif + if (associated(y%rttov_rad_total_pc)) then + deallocate(y%rttov_rad_total_pc) + nullify(y%rttov_rad_total_pc) + endif + + ! JKS - Add deallocate multi-inst rttov_output + if (associated(y%rttov_outputs)) then + do i=1,y % N_rttov_instruments ! Iterate over each instrument + if (associated(y%rttov_outputs(i)%channel_indices)) then + deallocate(y%rttov_outputs(i)%channel_indices) + nullify(y%rttov_outputs(i)%channel_indices) + endif + if (associated(y%rttov_outputs(i)%bt_total)) then + deallocate(y%rttov_outputs(i)%bt_total) + nullify(y%rttov_outputs(i)%bt_total) + endif + if (associated(y%rttov_outputs(i)%bt_clear)) then + deallocate(y%rttov_outputs(i)%bt_clear) + nullify(y%rttov_outputs(i)%bt_clear) + endif + if (associated(y%rttov_outputs(i)%rad_total)) then + deallocate(y%rttov_outputs(i)%rad_total) + nullify(y%rttov_outputs(i)%rad_total) + endif + if (associated(y%rttov_outputs(i)%rad_clear)) then + deallocate(y%rttov_outputs(i)%rad_clear) + nullify(y%rttov_outputs(i)%rad_clear) + endif + if (associated(y%rttov_outputs(i)%rad_cloudy)) then + deallocate(y%rttov_outputs(i)%rad_cloudy) + nullify(y%rttov_outputs(i)%rad_cloudy) + endif + if (associated(y%rttov_outputs(i)%refl_total)) then + deallocate(y%rttov_outputs(i)%refl_total) + nullify(y%rttov_outputs(i)%refl_total) + endif + if (associated(y%rttov_outputs(i)%refl_clear)) then + deallocate(y%rttov_outputs(i)%refl_clear) + nullify(y%rttov_outputs(i)%refl_clear) + endif + if (associated(y%rttov_outputs(i)%bt_total_pc)) then + deallocate(y%rttov_outputs(i)%bt_total_pc) + nullify(y%rttov_outputs(i)%bt_total_pc) + endif + if (associated(y%rttov_outputs(i)%rad_total_pc)) then + deallocate(y%rttov_outputs(i)%rad_total_pc) + nullify(y%rttov_outputs(i)%rad_total_pc) + endif + end do + deallocate(y%rttov_outputs) + nullify(y%rttov_outputs) + end if + + end subroutine destroy_cosp_outputs end program cosp2_test diff --git a/src/cosp.F90 b/src/cosp.F90 index b633cd9170..f3028721b8 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -56,7 +56,8 @@ MODULE MOD_COSP COSP_RTTOV_INI2, & cosp_rttov_simulate, & cosp_pc_rttov_simulate, & - rttov_cfg + rttov_cfg, & + rttov_output USE MOD_COSP_MISR_INTERFACE, ONLY: cosp_misr_init, misr_IN USE MOD_COSP_ISCCP_INTERFACE, ONLY: cosp_isccp_init, isccp_IN USE MOD_COSP_CALIPSO_INTERFACE, ONLY: cosp_calipso_init, calipso_IN @@ -298,6 +299,12 @@ MODULE MOD_COSP modis_Optical_Thickness_vs_ReffICE => null(), & ! Tau/ReffICE joint histogram modis_Optical_Thickness_vs_ReffLIQ => null() ! Tau/ReffLIQ joint histogram + ! Joint CloudSat+MODIS simulators outputs + real(wp),dimension(:,:,:,:),pointer :: & + cfodd_ntotal => null() ! # of CFODD (Npoints,CFODD_NDBZE,CFODD_NICOD,CFODD_NCLASS) + real(wp),dimension(:,:), pointer :: & + wr_occfreq_ntotal => null() ! # of nonprecip/drizzle/precip (Npoints,WR_NREGIME) + ! RTTOV outputs - JKS consider clear-sky and cloudy-sky values here real(wp),pointer :: & rttov_bt_total(:,:) => null(), & ! Brightness Temperature @@ -311,12 +318,10 @@ MODULE MOD_COSP rttov_rad_total_pc(:,:) => null() ! Radiance (PC-RTTOV) integer,dimension(:),pointer :: & rttov_Ichannel => null() - - ! Joint CloudSat+MODIS simulators outputs - real(wp),dimension(:,:,:,:),pointer :: & - cfodd_ntotal => null() ! # of CFODD (Npoints,CFODD_NDBZE,CFODD_NICOD,CFODD_NCLASS) - real(wp),dimension(:,:), pointer :: & - wr_occfreq_ntotal => null() ! # of nonprecip/drizzle/precip (Npoints,WR_NREGIME) + integer :: N_rttov_instruments + + type(rttov_output),pointer :: & + rttov_outputs(:) end type cosp_outputs diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 3645c9a41c..41b8fcb1d3 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -75,25 +75,61 @@ MODULE MOD_COSP_RTTOV_INTERFACE ! DDT for each instrument being simulated. Values to be assigned during the cosp_rttov_init subroutine type rttov_cfg - logical(KIND=jplm) :: & + logical(KIND=jplm) :: & Lrttov_bt, & Lrttov_rad, & Lrttov_refl, & - Lrttov_cld, & - Lrttov_aer, & - Lrttov_cldparam, & - Lrttov_aerparam, & +! Lrttov_cld, & +! Lrttov_aer, & +! Lrttov_cldparam, & +! Lrttov_aerparam, & Lrttov_pc - character(len=256) :: & + character(len=256) :: & rttov_srcDir, & rttov_coefDir, & OD_coef_filepath, & aer_coef_filepath, & cld_coef_filepath, & PC_coef_filepath - integer :: & - nchan_out + integer(KIND=jpim) :: & + rttov_direct_nthreads + integer(KIND=jpim) :: & + nchan_out, & + nchannels_rec + real(wp) :: & + CO2_mr, & + CH4_mr, & + CO_mr, & + N2O_mr, & + SO2_mr, & + rttov_ZenAng + integer(kind=jpim), allocatable :: & + iChannel(:), & + iChannel_out(:) ! Passing out the channel indices + real(kind=jplm),allocatable :: & + emisChannel(:), & ! RTTOV channel emissivity + reflChannel(:) ! RTTOV channel reflectivity + type(rttov_options) :: & + opts ! RTTOV options structure + type(rttov_coefs) :: & + coefs end type rttov_cfg + + + type rttov_output + integer,pointer :: & + channel_indices(:) + real(wp),pointer :: & + bt_total(:,:), & + bt_clear(:,:), & + rad_total(:,:), & + rad_clear(:,:), & + rad_cloudy(:,:), & + refl_total(:,:), & + refl_clear(:,:), & + bt_total_pc(:,:), & + rad_total_pc(:,:) + end type rttov_output CONTAINS @@ -144,7 +180,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & rttov_config ! Local variables - character(len=256) :: & + character(len=256),target :: & channel_filepath, & rttov_srcDir, & rttov_coefDir, & @@ -153,7 +189,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & cld_coef_filepath, & PC_coef_filepath - real(wp) :: & + real(wp), target :: & CO2_mr, & CH4_mr, & CO_mr, & @@ -162,38 +198,42 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & rttov_ZenAng ! Declare RTTOV namelist fields - logical :: Lrttov_bt = .false. - logical :: Lrttov_rad = .false. - logical :: Lrttov_refl = .false. - logical :: Lrttov_cld = .false. - logical :: Lrttov_aer = .false. - logical :: Lrttov_cldparam = .false. - logical :: Lrttov_aerparam = .false. - logical :: Lrttov_pc = .false. + logical :: Lrttov_bt = .false. + logical :: Lrttov_rad = .false. + logical :: Lrttov_refl = .false. +! logical, target :: Lrttov_cld = .false. +! logical, target :: Lrttov_aer = .false. +! logical, target :: Lrttov_cldparam = .false. +! logical, target :: Lrttov_aerparam = .false. + logical :: Lrttov_cld = .false. + logical :: Lrttov_aer = .false. + logical :: Lrttov_cldparam = .false. + logical :: Lrttov_aerparam = .false. + logical :: Lrttov_pc = .false. - logical :: Lchannel_filepath2 = .false. + logical :: Lchannel_filepath2 = .false. - logical :: SO2_data = .false. - logical :: N2O_data = .false. - logical :: CO_data = .false. - logical :: CO2_data = .false. - logical :: CH4_data = .false. - logical :: ozone_data = .false. + logical :: SO2_data = .false. + logical :: N2O_data = .false. + logical :: CO_data = .false. + logical :: CO2_data = .false. + logical :: CH4_data = .false. + logical :: ozone_data = .false. + logical :: clw_data = .false. character(len=256) :: cosp_status integer :: & i, & - rttov_nthreads, & nchannels_rec2 + + integer, target :: & + rttov_nthreads - integer(kind=jpim) :: & + integer(kind=jpim) :: & ipcbnd, & ipcreg, & npcscores - - print*,'t1.' - rttov_config%Lrttov_bt = .false. ! Set something in the rttov_config DDT, anything... - + ! Read RTTOV namelist fields namelist/RTTOV_INPUT/Lrttov_bt,Lrttov_rad,Lrttov_refl,Lrttov_cld, & ! Logicals for RTTOV configuration Lrttov_aer,Lrttov_cldparam,Lrttov_aerparam, & ! @@ -202,6 +242,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & OD_coef_filepath,aer_coef_filepath,cld_coef_filepath, & PC_coef_filepath, & CO2_data,CH4_data,CO_data,N2O_data,SO2_data,ozone_data, & ! User-supplied trace gas concentrations + clw_data, & ! MW option CO2_mr,CH4_mr,CO_mr,N2O_mr,SO2_mr, & ! Mixing ratios ipcbnd,ipcreg,npcscores, & ! PC-RTTOV config values rttov_nthreads,rttov_ZenAng @@ -209,17 +250,241 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Read in namelists !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - print*,'t2.' open(10,file=namelist_filepath,status='unknown') read(10,nml=RTTOV_INPUT) close(10) + print*,'Lrttov_pc: ',Lrttov_pc - print*,'t3.' - ! Initialize fields in module memory (cosp_rttovXX.F90) - rttovDir = rttov_srcDir + ! Set logicals for RTTOV config + rttov_config%Lrttov_bt = Lrttov_bt + rttov_config%Lrttov_rad = Lrttov_rad + rttov_config%Lrttov_refl = Lrttov_refl +! rttov_config%Lrttov_cld = Lrttov_cld +! rttov_config%Lrttov_aer = Lrttov_aer +! rttov_config%Lrttov_cldparam = Lrttov_cldparam +! rttov_config%Lrttov_aerparam = Lrttov_aerparam + rttov_config%Lrttov_pc = Lrttov_pc + + ! Set paths for RTTOV config + rttov_config%rttov_srcDir = rttov_srcDir + rttov_config%rttov_coefDir = rttov_coefDir + rttov_config%OD_coef_filepath = OD_coef_filepath + rttov_config%aer_coef_filepath = aer_coef_filepath + rttov_config%cld_coef_filepath = cld_coef_filepath + rttov_config%PC_coef_filepath = PC_coef_filepath + + ! Set other RTTOV config variables + rttov_config%rttov_direct_nthreads = rttov_nthreads + + rttov_config%SO2_mr = SO2_mr + rttov_config%N2O_mr = N2O_mr + rttov_config%CO_mr = CO_mr + rttov_config%CO2_mr = CO2_mr + rttov_config%CH4_mr = CH4_mr + rttov_config%rttov_ZenAng = rttov_ZenAng + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 1. Initialise RTTOV options structure + ! ------------------------------------------------------ + ! See page 157 of RTTOV v13 user guide for documentation + ! Initializing all options to defaults for consistency + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + ! General configuration options + rttov_config % opts % config % do_checkinput = .true. + rttov_config % opts % config % apply_reg_limits = .false. ! True in v11 + rttov_config % opts % config % verbose = .false. ! JKS suppress for now + rttov_config % opts % config % opdep13_gas_clip = .true. + + ! Declare RTTOV namelist fields + rttov_config % opts % rt_all % SO2_data = SO2_data + rttov_config % opts % rt_all % N2O_data = N2O_data + rttov_config % opts % rt_all % CO_data = CO_data + rttov_config % opts % rt_all % CO2_data = CO2_data + rttov_config % opts % rt_all % CH4_data = CH4_data + rttov_config % opts % rt_all % ozone_data = ozone_data + rttov_config % opts % rt_mw % clw_data = clw_data + + ! Other general RT options (initializing to defaults for completeness) + rttov_config % opts % rt_all % do_lambertian = .false. + rttov_config % opts % rt_all % switchrad = .false. + rttov_config % opts % rt_all % rad_down_lin_tau = .true. + rttov_config % opts % rt_all % use_t2m_opdep = .true. + rttov_config % opts % rt_all % use_q2m = .true. + rttov_config % opts % rt_all % use_tskin_eff = .false. + rttov_config % opts % rt_all % addrefrac = .true. + rttov_config % opts % rt_all % plane_parallel = .false. + rttov_config % opts % rt_all % transmittances_only = .false. + + ! MW-only radiative transfer options: + ! JKS make this optional? + rttov_config % opts % rt_mw % clw_data = .false. + rttov_config % opts % rt_mw % clw_scheme = 2 ! Default = 2/Rosenkranz + rttov_config % opts % rt_mw % clw_cloud_top = 322 ! Default is 322 hPa + rttov_config % opts % rt_mw % fastem_version = 6 ! Default FASTEM-6 + rttov_config % opts % rt_mw % supply_foam_fraction = .false. + + ! UV/visible/IR-only radiative transfer options + rttov_config % opts % rt_ir % addsolar = .false. + rttov_config % opts % rt_ir % rayleigh_max_wavelength = 2._wp ! 2um + rttov_config % opts % rt_ir % rayleigh_min_pressure = 0._wp ! 0 hPa + rttov_config % opts % rt_ir % rayleigh_single_scatt = .true. + rttov_config % opts % rt_ir % rayleigh_depol = .true. ! Default false, recommended true + rttov_config % opts % rt_ir % do_nlte_correction = .false. + rttov_config % opts % rt_ir % solar_sea_brdf_model = 2 + rttov_config % opts % rt_ir % ir_sea_emis_model = 2 + + ! User options - JKS + rttov_config % opts % rt_ir % addaerosl = Lrttov_aer + rttov_config % opts % rt_ir % addclouds = Lrttov_cld + rttov_config % opts % rt_ir % user_aer_opt_param = Lrttov_aerparam ! User specifies the aerosol scattering optical parameters + rttov_config % opts % rt_ir % user_cld_opt_param = Lrttov_cldparam ! User specifies the cloud scattering optical parameters + + rttov_config % opts % rt_ir % grid_box_avg_cloud = .true. + rttov_config % opts % rt_ir % cldcol_threshold = -1._wp + rttov_config % opts % rt_ir % cloud_overlap = 1 ! Maximum-random overlap + rttov_config % opts % rt_ir % cc_low_cloud_top = 750_wp ! 750 hPa. Only applies when cloud_overlap=2. + rttov_config % opts % rt_ir % ir_scatt_model = 2 + rttov_config % opts % rt_ir % vis_scatt_model = 1 + rttov_config % opts % rt_ir % dom_nstreams = 8 + rttov_config % opts % rt_ir % dom_accuracy = 0._wp ! only applies when addclouds or addaerosl is true and DOM is selected as a scattering solver. + rttov_config % opts % rt_ir % dom_opdep_threshold = 0._wp + rttov_config % opts % rt_ir % dom_rayleigh = .false. + + ! Principal Components-only radiative transfer options: + ! Default off + rttov_config % opts % rt_ir % pc % addpc = .false. + rttov_config % opts % rt_ir % pc % npcscores = -1 + rttov_config % opts % rt_ir % pc % addradrec = .false. + rttov_config % opts % rt_ir % pc % ipcbnd = 1 + rttov_config % opts % rt_ir % pc % ipcreg = 1 ! The index of the required set of PC predictors + + ! Options related to interpolation and the vertical grid: + rttov_config % opts % interpolation % addinterp = .true. + rttov_config % opts % interpolation % interp_mode = 1 +! rttov_config % opts % interpolation % reg_limit_extrap = .true. ! Depreciated + rttov_config % opts % interpolation % lgradp = .false. +! rttov_config % opts % interpolation % spacetop = .true. ! Depreciated + + ! Options related to HTFRTC: + rttov_config % opts % htfrtc_opts % htfrtc = .false. + rttov_config % opts % htfrtc_opts % n_pc_in = -1 + rttov_config % opts % htfrtc_opts % reconstruct = .false. + rttov_config % opts % htfrtc_opts % simple_cloud = .false. + rttov_config % opts % htfrtc_opts % overcast = .false. + + ! Developer options that may be useful: + rttov_config % opts % dev % do_opdep_calc = .true. + + ! If using PC-RTTOV, some settings must be a certain way. This isn't always true though... + if (do_rttov_pcrttov) then + rttov_config % opts % rt_ir % pc % addpc = .true. + rttov_config % opts % rt_ir % pc % ipcbnd = ipcbnd + rttov_config % opts % rt_ir % pc % ipcreg = ipcreg + rttov_config % opts % rt_ir % pc % npcscores = npcscores + + rttov_config % opts % rt_ir % pc % addradrec = .true. ! Alway reconstruct radiances + + rttov_config % opts % interpolation % addinterp = .true. ! Allow interpolation of input profile + rttov_config % opts % interpolation % interp_mode = 1 ! Set interpolation method + rttov_config % opts % rt_all % addrefrac = .true. ! Include refraction in path calc (always for PC) + rttov_config % opts % rt_ir % addclouds = .false. ! Don't include cloud effects (always for PC?) + rttov_config % opts % rt_ir % addaerosl = .false. ! Don't include aerosol effects (not always for PC) + rttov_config % opts % rt_ir % addsolar = .false. ! Do not include solar radiation (always for PC?) + + endif + + ! JKS To-do: include opts_scatt settings (user guide pg 161) + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 2. Read coefficients (from RTTOV example files) + ! ------------------------------------------------------ + ! Using the GUI to figure out files that work together could be helpful here. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + ! Construct optical depth and cloud coefficient files + OD_coef_filepath = trim(rttov_srcDir)//trim(rttov_coefDir)//trim(OD_coef_filepath) + aer_coef_filepath = trim(rttov_srcDir)//trim(rttov_coefDir)//trim(aer_coef_filepath) + cld_coef_filepath = trim(rttov_srcDir)//trim(rttov_coefDir)//trim(cld_coef_filepath) + + print*,'OD_coef_filepath: ',OD_coef_filepath + print*,'aer_coef_filepath: ',aer_coef_filepath + print*,'cld_coef_filepath: ',cld_coef_filepath + + ! Do I need logicals here to direct how to read the coefficients? + if (rttov_config % Lrttov_pc) then ! PC-RTTOV cannot handle cloud, some aerosols + PC_coef_filepath = trim(rttov_srcDir)//trim(rttov_coefDir)//trim(PC_coef_filepath) + call rttov_read_coefs(errorstatus, rttov_config % coefs, & + rttov_config % opts, & + file_coef=OD_coef_filepath, & +! file_scaer=aer_coef_filepath, & ! Needs to be PC-RTTOV compatible + file_pccoef=PC_coef_filepath) + else ! Read optical depth and cloud coefficient files together + call rttov_read_coefs(errorstatus, rttov_config % coefs, & + rttov_config % opts, & + file_coef=OD_coef_filepath, & + file_scaer=aer_coef_filepath, & + file_sccld=cld_coef_filepath) + ! Ensure input number of channels is not higher than number stored in coefficient file + if (nchannels_rec2 > rttov_config % coefs % coef % fmv_chn) then + nchannels_rec2 = rttov_config % coefs % coef % fmv_chn + print*,'nchannels_rec2 cap hit' + endif + endif + + ! We aren't checking an allocation steps so this seems more appropriate. + call rttov_error('fatal error reading coefficients' , lalloc = .false.) + + ! Ensure the options and coefficients are consistent + call rttov_user_options_checkinput(errorstatus, rttov_config % opts, rttov_config % coefs) + + ! We aren't checking an allocation steps so this seems more appropriate. + call rttov_error('error in rttov options' , lalloc = .false.) + + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Figure out how many channels we actually want to reconstruct + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + ! Handle different radiance reconstruction options + ! JKS - I need to set these two separate variables here? Can one be set later? + if (nchannels_rec2 < 0) then + print*,'The namelist variable "nchannels_rec2" is negative, rttov_direct call will fail. Exiting.' + errorstatus = errorstatus_fatal + call rttov_exit(errorstatus) + ! If the number of channels is negative, don't reconstruct radiances at all + rttov_config % nchan_out = 0 + rttov_config % nchannels_rec = 0 ! Avoid nchanprof set to a negative value + else if (nchannels_rec2 == 0) then + ! If the number of channels is set to 0 then reconstruct all instrument channels + rttov_config % nchan_out = rttov_config % coefs % coef % fmv_chn + rttov_config % nchannels_rec = rttov_config % coefs % coef % fmv_chn ! Avoid nchanprof set to 0 + else + ! Otherwise read the channel list from the file + rttov_config % nchan_out = nchannels_rec2 + rttov_config % nchannels_rec = nchannels_rec2 + endif + + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Read in channel indices, emissivities, and reflectivities from .csv if file is passed + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + if (Lchannel_filepath2) then + allocate(rttov_config % iChannel(rttov_config % nchan_out)) + allocate(rttov_config % emisChannel(rttov_config % nchan_out)) + allocate(rttov_config % reflChannel(rttov_config % nchan_out)) - !! JKS stopping here. + open(18,file=channel_filepath,access='sequential',form="formatted") + do i = 1, rttov_config % nchan_out + read(18,*) rttov_config % iChannel(i), rttov_config % emisChannel(i), rttov_config % reflChannel(i) + end do + close(18) + else ! If nothing is passed, compute the first "nchan_out" channels. Ignore emissivity and reflectivity for now. + allocate(rttov_config % iChannel(rttov_config % nchan_out)) + rttov_config % iChannel(:) = (/ (i, i = 1, rttov_config % nchan_out) /) + endif ! subsub routines contains @@ -470,15 +735,6 @@ SUBROUTINE COSP_RTTOV_INIT(nchan_out,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, opts % rt_ir % addaerosl = .false. ! Don't include aerosol effects (not always for PC) opts % rt_ir % addsolar = .false. ! Do not include solar radiation (always for PC?) - ! These options will depend on the coefficients used and should be left up to the user -! opts % rt_all % ozone_data = .TRUE. ! We have an ozone profile -! opts % rt_all % co2_data = .FALSE. ! We do not have profiles -! opts % rt_all % n2o_data = .FALSE. ! for any other constituents -! opts % rt_all % ch4_data = .FALSE. ! -! opts % rt_all % co_data = .FALSE. ! -! opts % rt_all % so2_data = .FALSE. ! -! opts % rt_mw % clw_data = .FALSE. ! - endif ! JKS To-do: include opts_scatt settings (user guide pg 161) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 4660835834..b5d3846b1a 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -105,10 +105,13 @@ module mod_cosp_rttov rttov_direct_nthreads = 1_jpim integer(kind=jpim),allocatable :: & iChannel(:), & ! RTTOV channel indices - emisChannel(:), & ! RTTOV channel emissivity - reflChannel(:), & ! RTTOV channel reflectivity +! emisChannel(:), & ! RTTOV channel emissivity +! reflChannel(:), & ! RTTOV channel reflectivity iChannel_out(:) ! Passing out the channel indices - + real(kind=jplm),allocatable :: & + emisChannel(:), & ! RTTOV channel emissivity + reflChannel(:) ! RTTOV channel reflectivity + ! Scattering coefficients (read in once during initialization) ! JKS - KISS ! type(rttov_scatt_coef) :: & From 731739bc52f7efdd5d9cc56f83c623db877d8ae9 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Sun, 21 May 2023 15:18:44 -0600 Subject: [PATCH 054/159] progress on multi-instrument RTTOV with multi-instrument output DDT included (to be immediately removed) --- driver/src/cosp2_test.F90 | 131 ++++++++++---------- src/cosp.F90 | 132 ++++++++++++++++++++- src/simulator/cosp_rttov_interface_v13.F90 | 12 -- src/simulator/rttov/cosp_rttov_v13.F90 | 37 +++--- 4 files changed, 214 insertions(+), 98 deletions(-) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index ebdbb4a845..2fbcb35631 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -252,7 +252,7 @@ program cosp2_test sd ! Hydrometeor description type(radar_cfg) :: & rcfg_cloudsat ! Radar configuration - type(rttov_cfg), dimension(:), allocatable :: & + type(rttov_cfg), dimension(:), allocatable, target :: & ! JKS check rttov_configs type(cosp_outputs) :: & cospOUT ! COSP simulator outputs @@ -554,13 +554,13 @@ program cosp2_test ! Construct COSP input types !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if (iChunk .eq. 1) then - call construct_cospIN(Nptsperit,nColumns,nLevels,cospIN) + call construct_cospIN(Nptsperit,nColumns,nLevels,rttov_Ninstruments,cospIN) call construct_cospstateIN(Nptsperit,nLevels,rttov_Nchannels,cospstateIN) endif if (iChunk .eq. nChunks) then call destroy_cospIN(cospIN) call destroy_cospstateIN(cospstateIN) - call construct_cospIN(Nptsperit,nColumns,nLevels,cospIN) + call construct_cospIN(Nptsperit,nColumns,nLevels,rttov_Ninstruments,cospIN) call construct_cospstateIN(Nptsperit,nLevels,rttov_Nchannels,cospstateIN) endif call cpu_time(driver_time(4)) @@ -573,6 +573,7 @@ program cosp2_test !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% cospIN%emsfc_lw = emsfc_lw cospIN%rcfg_cloudsat = rcfg_cloudsat + cospIN%cfg_rttov => rttov_configs ! JKS - Not sure why the cloudsat isn't a pointer. The config files for RTTOV are large and I don't want them duplicated in memory cospstateIN%hgt_matrix = zlev(start_idx:end_idx,Nlevels:1:-1) ! km cospstateIN%sunlit = sunlit(start_idx:end_idx) ! 0-1 cospstateIN%skt = skt(start_idx:end_idx) ! K @@ -1081,21 +1082,23 @@ end subroutine subsample_and_optics !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE construct_cospIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine construct_cospIN(npoints,ncolumns,nlevels,y) + subroutine construct_cospIN(npoints,ncolumns,nlevels,ninst_rttov,y) ! Inputs integer,intent(in) :: & npoints, & ! Number of horizontal gridpoints ncolumns, & ! Number of subcolumns - nlevels ! Number of vertical levels + nlevels, & ! Number of vertical levels + ninst_rttov ! Number of RTTOV instruments ! Outputs type(cosp_optical_inputs),intent(out) :: y ! Dimensions - y%Npoints = Npoints - y%Ncolumns = Ncolumns - y%Nlevels = Nlevels - y%Npart = 4 - y%Nrefl = PARASOL_NREFL + y%Npoints = Npoints + y%Ncolumns = Ncolumns + y%Nlevels = Nlevels + y%Ninst_rttov = Ninst_rttov + y%Npart = 4 + y%Nrefl = PARASOL_NREFL allocate(y%frac_out(npoints, ncolumns,nlevels)) if (Lrttov) then y%nChannels_rttov = rttov_Nchannels ! RTTOV dimension @@ -1143,6 +1146,10 @@ subroutine construct_cospIN(npoints,ncolumns,nlevels,y) y%asym(npoints, ncolumns,nlevels),& y%ss_alb(npoints, ncolumns,nlevels)) endif + + if (Lrttov) then + allocate(y%cfg_rttov(ninst_rttov)) + endif end subroutine construct_cospIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1526,60 +1533,61 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& ! RTTOV - Allocate output for multiple instruments ! Do I not need to allocate the number of instruments? Because each rttov output DDT will be a pointer? - x % N_rttov_instruments = N_rttov_instruments - allocate(x % rttov_outputs(N_rttov_instruments)) ! Need to allocate a pointer? - do i=1,N_rttov_instruments - print*,'i: ',i - print*,'rttov_configs(i) % nchan_out: ',rttov_configs(i) % nchan_out - print*,'rttov_configs(i) % Lrttov_bt: ',rttov_configs(i) % Lrttov_bt - print*,'rttov_configs(i) % Lrttov_rad: ',rttov_configs(i) % Lrttov_rad - print*,'rttov_configs(i) % Lrttov_refl: ',rttov_configs(i) % Lrttov_refl - print*,'rttov_configs(i) % opts % rt_ir % addaerosl: ',rttov_configs(i) % opts % rt_ir % addaerosl - print*,'rttov_configs(i) % opts % rt_ir % addclouds: ',rttov_configs(i) % opts % rt_ir % addclouds - print*,'rttov_configs(i) % opts % rt_ir % user_aer_opt_param: ',rttov_configs(i) % opts % rt_ir % user_aer_opt_param - print*,'rttov_configs(i) % opts % rt_ir % user_cld_opt_param: ',rttov_configs(i) % opts % rt_ir % user_cld_opt_param - print*,'rttov_configs(i) % Lrttov_pc: ',rttov_configs(i) % Lrttov_pc - - print*,'1.' - if (rttov_configs(i) % Lrttov_pc) then ! Treat PC-RTTOV fields as clear-sky only for now - print*,'2a.' - allocate(x % rttov_outputs(i) % channel_indices(rttov_configs(i) % nchan_out)) - if (rttov_configs(i) % Lrttov_bt) then ! Brightness temp - allocate(x % rttov_outputs(i) % bt_total_pc(Npoints,rttov_configs(i) % nchan_out)) - ! if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_bt_clear(Npoints,Nchan)) - endif - if (rttov_configs(i) % Lrttov_rad) then ! Radiance - allocate(x % rttov_outputs(i) % rad_total_pc(Npoints,rttov_configs(i) % nchan_out)) - ! if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_rad_clear(Npoints,Nchan)) - ! if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_rad_cloudy(Npoints,Nchan)) - endif - else - print*,'3a.' - allocate(x % rttov_outputs(i) % channel_indices(rttov_configs(i) % nchan_out)) - if (rttov_configs(i) % Lrttov_bt) then ! Brightness temp - allocate(x % rttov_outputs(i) % bt_total(Npoints,rttov_configs(i) % nchan_out)) - if ((rttov_configs(i) % opts % rt_ir % addclouds) .or. (rttov_configs(i) % opts % rt_ir % addaerosl)) then - allocate(x % rttov_outputs(i) % bt_clear(Npoints,rttov_configs(i) % nchan_out)) - end if - endif - if (rttov_configs(i) % Lrttov_rad) then ! Radiance - allocate(x % rttov_outputs(i) % rad_total(Npoints,rttov_configs(i) % nchan_out)) - if ((rttov_configs(i) % opts % rt_ir % addclouds) .or. (rttov_configs(i) % opts % rt_ir % addaerosl)) then - allocate(x % rttov_outputs(i) % rad_clear(Npoints,rttov_configs(i) % nchan_out)) + if (N_rttov_instruments .gt. 0) then + x % N_rttov_instruments = N_rttov_instruments + allocate(x % rttov_outputs(N_rttov_instruments)) ! Need to allocate a pointer? + do i=1,N_rttov_instruments + print*,'i: ',i + print*,'rttov_configs(i) % nchan_out: ',rttov_configs(i) % nchan_out + print*,'rttov_configs(i) % Lrttov_bt: ',rttov_configs(i) % Lrttov_bt + print*,'rttov_configs(i) % Lrttov_rad: ',rttov_configs(i) % Lrttov_rad + print*,'rttov_configs(i) % Lrttov_refl: ',rttov_configs(i) % Lrttov_refl + print*,'rttov_configs(i) % opts % rt_ir % addaerosl: ',rttov_configs(i) % opts % rt_ir % addaerosl + print*,'rttov_configs(i) % opts % rt_ir % addclouds: ',rttov_configs(i) % opts % rt_ir % addclouds + print*,'rttov_configs(i) % opts % rt_ir % user_aer_opt_param: ',rttov_configs(i) % opts % rt_ir % user_aer_opt_param + print*,'rttov_configs(i) % opts % rt_ir % user_cld_opt_param: ',rttov_configs(i) % opts % rt_ir % user_cld_opt_param + print*,'rttov_configs(i) % Lrttov_pc: ',rttov_configs(i) % Lrttov_pc + + print*,'1.' + if (rttov_configs(i) % Lrttov_pc) then ! Treat PC-RTTOV fields as clear-sky only for now + print*,'2a.' + allocate(x % rttov_outputs(i) % channel_indices(rttov_configs(i) % nchan_out)) + if (rttov_configs(i) % Lrttov_bt) then ! Brightness temp + allocate(x % rttov_outputs(i) % bt_total_pc(Npoints,rttov_configs(i) % nchan_out)) + ! if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_bt_clear(Npoints,Nchan)) end if - if ((rttov_configs(i) % opts % rt_ir % addclouds) .or. (rttov_configs(i) % opts % rt_ir % addaerosl)) then - allocate(x % rttov_outputs(i) % rad_cloudy(Npoints,rttov_configs(i) % nchan_out)) + if (rttov_configs(i) % Lrttov_rad) then ! Radiance + allocate(x % rttov_outputs(i) % rad_total_pc(Npoints,rttov_configs(i) % nchan_out)) + ! if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_rad_clear(Npoints,Nchan)) + ! if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_rad_cloudy(Npoints,Nchan)) + end if + else + print*,'3a.' + allocate(x % rttov_outputs(i) % channel_indices(rttov_configs(i) % nchan_out)) + if (rttov_configs(i) % Lrttov_bt) then ! Brightness temp + allocate(x % rttov_outputs(i) % bt_total(Npoints,rttov_configs(i) % nchan_out)) + if ((rttov_configs(i) % opts % rt_ir % addclouds) .or. (rttov_configs(i) % opts % rt_ir % addaerosl)) then + allocate(x % rttov_outputs(i) % bt_clear(Npoints,rttov_configs(i) % nchan_out)) + end if end if - endif - if (rttov_configs(i) % Lrttov_refl) then ! Reflectance - allocate(x % rttov_outputs(i) % refl_total(Npoints,rttov_configs(i) % nchan_out)) - if ((rttov_configs(i) % opts % rt_ir % addclouds) .or. (rttov_configs(i) % opts % rt_ir % addaerosl)) then - allocate(x % rttov_outputs(i) % refl_clear(Npoints,rttov_configs(i) % nchan_out)) + if (rttov_configs(i) % Lrttov_rad) then ! Radiance + allocate(x % rttov_outputs(i) % rad_total(Npoints,rttov_configs(i) % nchan_out)) + if ((rttov_configs(i) % opts % rt_ir % addclouds) .or. (rttov_configs(i) % opts % rt_ir % addaerosl)) then + allocate(x % rttov_outputs(i) % rad_clear(Npoints,rttov_configs(i) % nchan_out)) + end if + if ((rttov_configs(i) % opts % rt_ir % addclouds) .or. (rttov_configs(i) % opts % rt_ir % addaerosl)) then + allocate(x % rttov_outputs(i) % rad_cloudy(Npoints,rttov_configs(i) % nchan_out)) + end if end if - endif - endif - - end do + if (rttov_configs(i) % Lrttov_refl) then ! Reflectance + allocate(x % rttov_outputs(i) % refl_total(Npoints,rttov_configs(i) % nchan_out)) + if ((rttov_configs(i) % opts % rt_ir % addclouds) .or. (rttov_configs(i) % opts % rt_ir % addaerosl)) then + allocate(x % rttov_outputs(i) % refl_clear(Npoints,rttov_configs(i) % nchan_out)) + end if + end if + end if + end do + end if end subroutine construct_cosp_outputs @@ -2062,7 +2070,6 @@ subroutine destroy_cosp_outputs(y) nullify(y%rttov_outputs) end if - end subroutine destroy_cosp_outputs end program cosp2_test diff --git a/src/cosp.F90 b/src/cosp.F90 index f3028721b8..0ecda16bc9 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -71,7 +71,7 @@ MODULE MOD_COSP USE MOD_LIDAR_SIMULATOR, ONLY: lidar_subcolumn, lidar_column USE MOD_MODIS_SIM, ONLY: modis_subcolumn, modis_column USE MOD_PARASOL, ONLY: parasol_subcolumn, parasol_column - USE MOD_COSP_RTTOV, ONLY: rttov_IN + USE MOD_COSP_RTTOV, ONLY: rttov_IN !, rttov_instrument_OUT ! JKS - clean USE MOD_COSP_STATS, ONLY: COSP_LIDAR_ONLY_CLOUD,COSP_CHANGE_VERTICAL_GRID, & COSP_DIAG_WARMRAIN @@ -140,7 +140,8 @@ MODULE MOD_COSP Nlevels, & ! Number of levels. Npart, & ! Number of cloud meteors for LIDAR simulators. Nrefl, & ! Number of reflectances for PARASOL simulator - nChannels_rttov ! Number of RTTOV channels + nChannels_rttov, & ! Number of RTTOV channels + Ninst_rttov ! Number of RTTOV instruments real(wp) :: & emsfc_lw ! Surface emissivity @ 11micron real(wp),allocatable,dimension(:,:,:) :: & @@ -175,7 +176,7 @@ MODULE MOD_COSP fracPrecipIce ! Fraction of precipitation which is frozen (1). type(radar_cfg) :: & rcfg_cloudsat ! Radar configuration information (CLOUDSAT) - type(rttov_cfg),allocatable,dimension(:) :: & + type(rttov_cfg),dimension(:),pointer :: & cfg_rttov ! RTTOV configuration information (multiple instruments) end type cosp_optical_inputs @@ -421,6 +422,8 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) zlev (:,:), & ! altitude (used only when use_vgrid=.true.) cfodd_ntotal (:,:,:,:), & ! # of total samples for CFODD (Npoints,CFODD_NDBZE,CFODD_NICOD,CFODD_NCLASS) wr_occfreq_ntotal(:,:) ! # of warm-rain (nonprecip/drizzle/precip) (Npoints,WR_NREGIME) +! type(rttov_instrument_OUT),dimension(:),allocatable :: & ! JKS where RTTOV outputs are actually stored, not a pointer +! cosp_inst_OUTS ! Initialize error reporting for output cosp_simulator(:)='' @@ -541,6 +544,11 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (associated(cospOUT%rttov_bt_total_pc) .or. & associated(cospOUT%rttov_rad_total_pc)) & Lrttov_pc = .true. + + if (associated(cospOUT%rttov_outputs)) then + Lrttov_column = .true. + print*,'multi-inst. RTTOV called' + endif ! Set flag to deallocate rttov types (only done on final call to simulator) if (size(cospOUT%isccp_meantb) .eq. stop_idx) lrttov_cleanUp = .true. @@ -1338,7 +1346,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! MODIS if (Lmodis_column) then - if(modisiN%nSunlit > 0) then + if(modisIN%nSunlit > 0) then ! Allocate space for local variables allocate(modisCftotal(modisIN%nSunlit), modisCfLiquid(modisIN%nSunlit), & modisCfIce(modisIN%nSunlit),modisCfHigh(modisIN%nSunlit), & @@ -1633,6 +1641,122 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) endif print*,'Lrttov_column successful' ! jks + + + print*,'Lrttov_column multi-inst. start' + + ! RTTOV multi-instrument + if (Lrttov_column) then + print*,'0.' + ! 0. Load the column inputs. These are constant across instruments. + +! allocate(cosp_inst_OUTS(cospIN%Ninst_rttov)) ! Allocate output fields (I actually don't need this type because I run the instruments one-at-a-time + + ! 1. Allocate output for each requested instrument + ! 2. Run RTTOV for each instrument, passing the config files along. + ! 3. Write to COSPout if output is requested + ! 4. Free up memory from output + do i=1,cospIN%Ninst_rttov + print*,i + print*,'1' + + ! Allocate memory for the outputs - I won't need all of these in every situation. + ! Only allocate clear-sky memory when PC-RTTOV is run. + print*,'cospIN % cfg_rttov(i) % nchan_out: ',cospIN % cfg_rttov(i) % nchan_out ! issue here + allocate(rttov_Ichannel(cospIN % cfg_rttov(i) % nchan_out)) ! Channel indices +! allocate(cosp_inst_OUTS(i) % channel_indices(cospIN % cfg_rttov(i) % nchan_out)) ! Channel indices + print*,'2' + if (cospIN % cfg_rttov(i) % Lrttov_pc) then + print*,'3a' + allocate(rttov_bt_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp + allocate(rttov_rad_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky radiance +! allocate(cosp_inst_OUTS(i) % bt_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp +! allocate(cosp_inst_OUTS(i) % rad_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky radiance + + ! allocate(rttov_bt_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky brightness temp + ! allocate(rttov_rad_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky radiance + else + print*,'3b' + allocate(rttov_bt_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp + allocate(rttov_bt_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! clear-sky brightness temp + allocate(rttov_rad_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp + allocate(rttov_rad_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! clear-sky brightness temp + allocate(rttov_rad_cloudy(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! cloudy-sky brightness temp + allocate(rttov_refl_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky Bi-directional reflectance factor + allocate(rttov_refl_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! clear-sky Bi-directional reflectance factor + +! allocate(cosp_inst_OUTS(i) % bt_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp +! allocate(cosp_inst_OUTS(i) % bt_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! clear-sky brightness temp +! allocate(cosp_inst_OUTS(i) % rad_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp +! allocate(cosp_inst_OUTS(i) % rad_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! clear-sky brightness temp +! allocate(cosp_inst_OUTS(i) % rad_cloudy(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! cloudy-sky brightness temp +! allocate(cosp_inst_OUTS(i) % refl_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky Bi-directional reflectance factor +! allocate(cosp_inst_OUTS(i) % refl_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! clear-sky Bi-directional reflectance factor + endif + + ! JKS new RTTOV subroutine for v13 called from the RTTOV interface. + call cpu_time(driver_time(3)) + ! Run simulator +! call cosp_rttov_simulate(rttovIN,Lrttov_cleanUp, & ! Inputs +! cosp_inst_OUTS(i), & ! RTTOV output fields DDT +! cosp_simulator(nError+1)) + call cpu_time(driver_time(4)) + print*,'Time to run RTTOV: ',driver_time(4)-driver_time(3) + + ! Write to cospOUT + if (associated(cospOUT % rttov_outputs(i) % channel_indices)) & +! cospOUT % rttov_outputs(i) % channel_indices(:) = cosp_inst_OUTS(i) % channel_indices + cospOUT % rttov_outputs(i) % channel_indices(:) = rttov_Ichannel + if (cospIN % cfg_rttov(i) % Lrttov_pc) then + if (associated(cospOUT % rttov_outputs(i) % bt_total_pc)) & +! cospOUT % rttov_outputs(i) % bt_total_pc(ij:ik,:) = cosp_inst_OUTS(i) % bt_total + cospOUT % rttov_outputs(i) % bt_total_pc(ij:ik,:) = rttov_bt_total + if (associated(cospOUT % rttov_outputs(i) % rad_total_pc)) & + cospOUT % rttov_outputs(i) % rad_total_pc(ij:ik,:) = rttov_rad_total + else + if (associated(cospOUT % rttov_outputs(i) % bt_total)) & + cospOUT % rttov_outputs(i) % bt_total(ij:ik,:) = rttov_bt_total + if (associated(cospOUT % rttov_outputs(i) % bt_clear)) & + cospOUT % rttov_outputs(i) % bt_clear(ij:ik,:) = rttov_bt_clear + if (associated(cospOUT % rttov_outputs(i) % rad_total)) & + cospOUT % rttov_outputs(i) % rad_total(ij:ik,:) = rttov_rad_total + if (associated(cospOUT % rttov_outputs(i) % rad_clear)) & + cospOUT % rttov_outputs(i) % rad_clear(ij:ik,:) = rttov_rad_clear + if (associated(cospOUT % rttov_outputs(i) % rad_cloudy)) & + cospOUT % rttov_outputs(i) % rad_cloudy(ij:ik,:) = rttov_rad_cloudy + if (associated(cospOUT % rttov_outputs(i) % refl_total)) & + cospOUT % rttov_outputs(i) % refl_total(ij:ik,:) = rttov_refl_total + if (associated(cospOUT % rttov_outputs(i) % refl_clear)) & + cospOUT % rttov_outputs(i) % refl_clear(ij:ik,:) = rttov_refl_clear + endif + + ! Free up memory from output (if necessary) + if (allocated(rttov_Ichannel)) deallocate(rttov_Ichannel) + if (allocated(rttov_bt_total)) deallocate(rttov_bt_total) + if (allocated(rttov_bt_clear)) deallocate(rttov_bt_clear) + if (allocated(rttov_rad_total)) deallocate(rttov_rad_total) + if (allocated(rttov_rad_clear)) deallocate(rttov_rad_clear) + if (allocated(rttov_rad_cloudy)) deallocate(rttov_rad_cloudy) + if (allocated(rttov_refl_total)) deallocate(rttov_refl_total) + if (allocated(rttov_refl_clear)) deallocate(rttov_refl_clear) + + ! Free up memory from output (if necessary) +! if (allocated(cosp_inst_OUTS(i) % channel_indices)) deallocate(cosp_inst_OUTS(i) % channel_indices) +! if (allocated(cosp_inst_OUTS(i) % bt_total)) deallocate(cosp_inst_OUTS(i) % bt_total) +! if (allocated(cosp_inst_OUTS(i) % bt_clear)) deallocate(cosp_inst_OUTS(i) % bt_clear) +! if (allocated(cosp_inst_OUTS(i) % rad_total)) deallocate(cosp_inst_OUTS(i) % rad_total) +! if (allocated(cosp_inst_OUTS(i) % rad_clear)) deallocate(cosp_inst_OUTS(i) % rad_clear) +! if (allocated(cosp_inst_OUTS(i) % rad_cloudy)) deallocate(cosp_inst_OUTS(i) % rad_cloudy) +! if (allocated(cosp_inst_OUTS(i) % refl_total)) deallocate(cosp_inst_OUTS(i) % refl_total) +! if (allocated(cosp_inst_OUTS(i) % refl_clear)) deallocate(cosp_inst_OUTS(i) % refl_clear) + + + end do + + endif + + print*,'Lrttov_column multi-inst. successful' + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 6) Compute multi-instrument products diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 41b8fcb1d3..f190d80efd 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -79,10 +79,6 @@ MODULE MOD_COSP_RTTOV_INTERFACE Lrttov_bt, & Lrttov_rad, & Lrttov_refl, & -! Lrttov_cld, & -! Lrttov_aer, & -! Lrttov_cldparam, & -! Lrttov_aerparam, & Lrttov_pc character(len=256) :: & rttov_srcDir, & @@ -201,10 +197,6 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & logical :: Lrttov_bt = .false. logical :: Lrttov_rad = .false. logical :: Lrttov_refl = .false. -! logical, target :: Lrttov_cld = .false. -! logical, target :: Lrttov_aer = .false. -! logical, target :: Lrttov_cldparam = .false. -! logical, target :: Lrttov_aerparam = .false. logical :: Lrttov_cld = .false. logical :: Lrttov_aer = .false. logical :: Lrttov_cldparam = .false. @@ -260,10 +252,6 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & rttov_config%Lrttov_bt = Lrttov_bt rttov_config%Lrttov_rad = Lrttov_rad rttov_config%Lrttov_refl = Lrttov_refl -! rttov_config%Lrttov_cld = Lrttov_cld -! rttov_config%Lrttov_aer = Lrttov_aer -! rttov_config%Lrttov_cldparam = Lrttov_cldparam -! rttov_config%Lrttov_aerparam = Lrttov_aerparam rttov_config%Lrttov_pc = Lrttov_pc ! Set paths for RTTOV config diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index b5d3846b1a..22ffd8c29b 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -221,26 +221,23 @@ module mod_cosp_rttov fl_snow ! Precipitation flux (stratiform+convective snow) end type rttov_IN - ! DDT for each instrument being simulated. Values to be assigned during the cosp_rttov_init subroutine - type rttov_instrument_config - logical(KIND=jplm) :: & - Lrttov_bt, & - Lrttov_rad, & - Lrttov_refl, & - Lrttov_cld, & - Lrttov_aer, & - Lrttov_cldparam, & - Lrttov_aerparam, & - Lrttov_pc - character(len=256) :: & - rttov_srcDir, & - rttov_coefDir, & - OD_coef_filepath, & - aer_coef_filepath, & - cld_coef_filepath, & - PC_coef_filepath - end type rttov_instrument_config - + ! RTTOV output fields for an individual instrument +! type rttov_instrument_OUT +! integer(kind=jpim),pointer :: & +! nChannels +! real(wp), dimension(:),allocatable :: & +! channel_indices +! real(wp), dimension(:,:),allocatable :: & +! bt_total, & ! Brightness Temperature +! bt_clear, & ! Brightness Temperature +! rad_total, & ! Radiance +! rad_clear, & ! Radiance +! rad_cloudy, & ! Radiance +! refl_total, & ! Reflectance +! refl_clear, & ! Reflectance +! bt_total_pc, & ! Brightness Temperature (PC-RTTOV) +! rad_total_pc ! Radiance (PC-RTTOV) +! end type rttov_instrument_OUT contains From 33e5d3e85f2eef69cd8b0b1979b42fae3059384d Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 23 May 2023 16:52:44 -0600 Subject: [PATCH 055/159] initial functioning code for multi-instrument implementation. Still getting errors when deallocating coeficients though. --- driver/src/cosp2_io.f90 | 256 +++++++- driver/src/cosp2_test.F90 | 8 +- src/cosp.F90 | 57 +- src/simulator/cosp_rttov_interface_v13.F90 | 301 +++++++-- src/simulator/rttov/cosp_rttov_v13.F90 | 681 ++++++++++++++++++++- 5 files changed, 1189 insertions(+), 114 deletions(-) diff --git a/driver/src/cosp2_io.f90 b/driver/src/cosp2_io.f90 index 8c7d81c4c9..4aa6779b86 100644 --- a/driver/src/cosp2_io.f90 +++ b/driver/src/cosp2_io.f90 @@ -17,22 +17,27 @@ module mod_cosp_io !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE write_cosp2_output !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, lev, lon, lat, cospOUT, outFileName) - integer,intent(in) :: Npoints, Ncolumns, Nlevels, Nchannels + subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, Ninst_rttov, lev, lon, lat, cospOUT, outFileName) + integer,intent(in) :: Npoints, Ncolumns, Nlevels, Nchannels, Ninst_rttov real(wp),dimension(Npoints),intent(in) :: lon,lat real(wp),dimension(Nlevels),intent(in) :: lev type(cosp_outputs),intent(in) :: cospOUT character(len=256),intent(in) :: outFileName - integer :: fileID,status,ij - integer,dimension(20) :: dimID - integer,dimension(150) :: varID + integer :: fileID,status,ij,i,ii + integer,dimension(50) :: dimID + integer,dimension(250) :: varID integer,dimension(Npoints) :: loc integer,dimension(Ncolumns) :: cosp_scol integer,dimension(2) :: bnds + character(len=8) :: & + fmt, & ! format descriptor for flexible RTTOV output + i_str + loc=(/(ij,ij=1,Npoints)/) cosp_scol=(/(ij,ij=1,Ncolumns)/) bnds=(/(ij,ij=1,2)/) + fmt = '(I3.3)' ! an integer of width 3 with zeros at the left ! --------------------------------------------------------------------------------------- ! Create output file. @@ -81,6 +86,17 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, lev, lon, l if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) status = nf90_def_dim(fileID,"RTTOV_CHAN",Nchannels,dimID(19)) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + + ! Define instrument channel indices for multiple RTTOV instruments + if (associated(cospOUT%rttov_outputs)) then + do i=1,Ninst_rttov + write (i_str,fmt) i ! converting integer to string i_str using a 'internal file' + print*,'"RTTOV_CHAN_INST"//trim(i_str): ',"RTTOV_CHAN_INST"//trim(i_str) + status = nf90_def_dim(fileID,"RTTOV_CHAN_INST"//trim(i_str),cospOUT % rttov_outputs(i) % nchan_out,dimID(20+i)) ! Start at 100 for RTTOV output channel dimensions + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + end do + end if + ! --------------------------------------------------------------------------------------- ! Define variables ! --------------------------------------------------------------------------------------- @@ -197,9 +213,9 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, lev, lon, l ! RTTOV Channel Indices (rttov_Ichannel) status = nf90_def_var(fileID,"RTTOV_CHAN", nf90_float, (/dimID(19)/),varID(157)) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(86),"long_name","rttov channel indices") + status = nf90_put_att(fileID,varID(157),"long_name","rttov channel indices") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(86),"units", "1") + status = nf90_put_att(fileID,varID(157),"units", "1") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) ! CALIPSO simulator output @@ -1432,6 +1448,17 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, lev, lon, l ! --------------------------------------------------------------------------------------- ! Brightness Temperature + if (associated(cospOUT%rttov_Ichannel)) then + status = nf90_def_var(fileID,"rttov_ichannel",nf90_float, (/dimID(19)/),varID(157)) +! status = nf90_def_var(fileID,"rttov_ichannel",nf90_float, (/dimID(1),dimID(19)/),varID(157)) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(156),"long_name","RTTOV Channel Indices") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(156),"units", "1") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(156),"standard_name", " ") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif if (associated(cospOUT%rttov_bt_total)) then status = nf90_def_var(fileID,"rttov_bt_total",nf90_float, (/dimID(1),dimID(19)/),varID(148)) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) @@ -1521,7 +1548,150 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, lev, lon, l if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) status = nf90_put_att(fileID,varID(156),"standard_name", "bleh") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - endif + endif + + ! Define instrument channel indices for multiple RTTOV instruments + ii = 165 ! RTTOV variable indices start at 165 + if (associated(cospOUT%rttov_outputs)) then + do i=1,Ninst_rttov + write (i_str,fmt) i ! converting integer to string i_str using a 'internal file' +! print*,'"RTTOV_CHAN_INST"//trim(i_str): ',"RTTOV_CHAN_INST"//trim(i_str) +! status = nf90_def_var(fileID,"RTTOV_CHAN_INST"//trim(i_str), nf90_float, (/dimID(100+i)/),varID(200+i)) ! Start at 200 for RTTOV output dimensions +! if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) +! status = nf90_put_att(fileID,varID(200+i),"long_name","rttov channel indices for instrument "//trim(i_str)) +! if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) +! status = nf90_put_att(fileID,varID(200+i),"units", "1") +! if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) then + ii = ii + 1 + print*,'channel_indices' + print*,'ii: ',ii +! status = nf90_def_var(fileID,"rttov_ichannel_inst"//trim(i_str),nf90_float, (/dimID(1),dimID(20+i)/),varID(ii)) + status = nf90_def_var(fileID,"rttov_ichannel_inst"//trim(i_str),nf90_float, (/dimID(20+i)/),varID(ii)) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"long_name","RTTOV Channel Indices") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"units", "1") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"standard_name", " ") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_outputs(i)%bt_total)) then + ii = ii + 1 + print*,'bt_total' + print*,'ii: ',ii + status = nf90_def_var(fileID,"rttov_bt_total_inst"//trim(i_str),nf90_float, (/dimID(1),dimID(20+i)/),varID(ii)) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"long_name","RTTOV All-sky Brightness Temperature") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"units", "Degrees Kelvin") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"standard_name", "bleh") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) then + ii = ii + 1 + print*,'bt_clear' + print*,'ii: ',ii + status = nf90_def_var(fileID,"rttov_bt_clear_inst"//trim(i_str),nf90_float, (/dimID(1),dimID(20+i)/),varID(ii)) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"long_name","RTTOV Clear-sky Brightness Temperature") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"units", "Degrees Kelvin") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"standard_name", "bleh") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_outputs(i)%rad_total)) then + ii = ii + 1 + status = nf90_def_var(fileID,"rttov_rad_total_inst"//trim(i_str),nf90_float, (/dimID(1),dimID(20+i)/),varID(ii)) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"long_name","RTTOV All-sky Radiance") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"units", "mW/cm-1/sr/m2") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"standard_name", "bleh") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) then + ii = ii + 1 + status = nf90_def_var(fileID,"rttov_rad_clear_inst"//trim(i_str),nf90_float, (/dimID(1),dimID(20+i)/),varID(ii)) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"long_name","RTTOV Clear-sky Radiance") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"units", "mW/cm-1/sr/m2") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"standard_name", "bleh") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) then + ii = ii + 1 + status = nf90_def_var(fileID,"rttov_rad_cloudy_inst"//trim(i_str),nf90_float, (/dimID(1),dimID(20+i)/),varID(ii)) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"long_name","RTTOV Cloudy-sky Radiance") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"units", "mW/cm-1/sr/m2") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"standard_name", "bleh") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_outputs(i)%refl_total)) then + ii = ii + 1 + status = nf90_def_var(fileID,"rttov_refl_total_inst"//trim(i_str),nf90_float, (/dimID(1),dimID(20+i)/),varID(ii)) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"long_name","RTTOV All-sky Reflectance") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"units", "unitless") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"standard_name", "bleh") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) then + ii = ii + 1 + status = nf90_def_var(fileID,"rttov_refl_clear_inst"//trim(i_str),nf90_float, (/dimID(1),dimID(20+i)/),varID(ii)) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"long_name","RTTOV Clear-sky Reflectance") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"units", "unitless") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"standard_name", "bleh") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) then + ii = ii + 1 + print*,'bt_total_pc' + print*,'ii: ',ii + +! print*,shape(bt_total) + print*,'20+i: ',20+i + status = nf90_def_var(fileID,"rttov_bt_total_pc_inst"//trim(i_str),nf90_float, (/dimID(1),dimID(20+i)/),varID(ii)) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"long_name","PC-RTTOV All-sky Brightness Temperature") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"units", "Degrees Kelvin") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"standard_name", "bleh") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) then + ii = ii + 1 + print*,'rad_total_pc' + print*,'ii: ',ii + print*,'20+i: ',20+i + status = nf90_def_var(fileID,"rttov_rad_total_pc_inst"//trim(i_str),nf90_float, (/dimID(1),dimID(20+i)/),varID(ii)) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"long_name","PC-RTTOV All-sky Radiance") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"units", "mW/cm-1/sr/m2") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + status = nf90_put_att(fileID,varID(ii),"standard_name", "bleh") + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + print*,'end print check' + endif + + end do + end if ! --------------------------------------------------------------------------------------- ! Exit define mode @@ -2042,6 +2212,76 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, lev, lon, l if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) endif + ! Define instrument channel indices for multiple RTTOV instruments + ii = 165 ! RTTOV variable indices start at 166 + if (associated(cospOUT%rttov_outputs)) then + do i=1,Ninst_rttov + write (i_str,fmt) i ! converting integer to string i_str using a 'internal file' + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) then + ii = ii + 1 + print*,'channel_indices' + print*,'ii: ',ii + status = nf90_put_var(fileID,varID(ii),cospOUT%rttov_outputs(i)%channel_indices) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_outputs(i)%bt_total)) then + ii = ii + 1 + print*,'bt_total' + print*,'ii: ',ii + status = nf90_put_var(fileID,varID(ii),cospOUT%rttov_outputs(i)%bt_total) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) then + ii = ii + 1 + print*,'bt_clear' + print*,'ii: ',ii + status = nf90_put_var(fileID,varID(ii),cospOUT%rttov_outputs(i)%bt_clear) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_outputs(i)%rad_total)) then + ii = ii + 1 + status = nf90_put_var(fileID,varID(ii),cospOUT%rttov_outputs(i)%rad_total) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) then + ii = ii + 1 + status = nf90_put_var(fileID,varID(ii),cospOUT%rttov_outputs(i)%rad_clear) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) then + ii = ii + 1 + status = nf90_put_var(fileID,varID(ii),cospOUT%rttov_outputs(i)%rad_cloudy) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_outputs(i)%refl_total)) then + ii = ii + 1 + status = nf90_put_var(fileID,varID(ii),cospOUT%rttov_outputs(i)%refl_total) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) then + ii = ii + 1 + status = nf90_put_var(fileID,varID(ii),cospOUT%rttov_outputs(i)%refl_clear) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) then + ii = ii + 1 + print*,'bt_total_pc' +! print*,'shape(cospOUT%rttov_outputs(i)%bt_total_pc): ',shape(cospOUT%rttov_outputs(i)%bt_total_pc) + print*,'ii: ',ii + status = nf90_put_var(fileID,varID(ii),cospOUT%rttov_outputs(i)%bt_total_pc) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) then + ii = ii + 1 + print*,'rad_total_pc' +! print*,'shape(cospOUT%rttov_outputs(i)%rad_total_pc): ',shape(cospOUT%rttov_outputs(i)%rad_total_pc) + print*,'ii: ',ii + status = nf90_put_var(fileID,varID(ii),cospOUT%rttov_outputs(i)%rad_total_pc) + if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) + endif + end do + end if + ! Close file status = nf90_close(fileID) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 2fbcb35631..e8e10d637e 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -666,7 +666,7 @@ program cosp2_test !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Output !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - call write_cosp2_output(Npoints, Ncolumns, Nlevels, rttov_Nchannels, zlev(1,Nlevels:1:-1), lon, lat, cospOUT, foutput) + call write_cosp2_output(Npoints, Ncolumns, Nlevels, rttov_Nchannels, rttov_Ninstruments, zlev(1,Nlevels:1:-1), lon, lat, cospOUT, foutput) call cpu_time(driver_time(8)) print*,'Time to write to output: ',driver_time(8)-driver_time(7) @@ -674,10 +674,15 @@ program cosp2_test !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Free up memory !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + print*,'destroy_cosp_outputs' call destroy_cosp_outputs(cospOUT) + print*,'destroy_cospIN' call destroy_cospIN(cospIN) + print*,'destroy_cospstateIN' call destroy_cospstateIN(cospstateIN) + print*,'cosp_cleanUp' call cosp_cleanUp() + print*,'done.' ! Getting a segmentation fault here? Why? JKS contains @@ -1549,6 +1554,7 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& print*,'rttov_configs(i) % Lrttov_pc: ',rttov_configs(i) % Lrttov_pc print*,'1.' + x % rttov_outputs(i) % nchan_out = rttov_configs(i) % nchan_out if (rttov_configs(i) % Lrttov_pc) then ! Treat PC-RTTOV fields as clear-sky only for now print*,'2a.' allocate(x % rttov_outputs(i) % channel_indices(rttov_configs(i) % nchan_out)) diff --git a/src/cosp.F90 b/src/cosp.F90 index 0ecda16bc9..5e30295a5e 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -55,7 +55,7 @@ MODULE MOD_COSP cosp_rttov_init, & COSP_RTTOV_INI2, & cosp_rttov_simulate, & - cosp_pc_rttov_simulate, & + cosp_rttov_simulate_mi, & rttov_cfg, & rttov_output USE MOD_COSP_MISR_INTERFACE, ONLY: cosp_misr_init, misr_IN @@ -71,7 +71,7 @@ MODULE MOD_COSP USE MOD_LIDAR_SIMULATOR, ONLY: lidar_subcolumn, lidar_column USE MOD_MODIS_SIM, ONLY: modis_subcolumn, modis_column USE MOD_PARASOL, ONLY: parasol_subcolumn, parasol_column - USE MOD_COSP_RTTOV, ONLY: rttov_IN !, rttov_instrument_OUT ! JKS - clean + USE MOD_COSP_RTTOV, ONLY: rttov_IN, cosp_rttov_construct_profiles USE MOD_COSP_STATS, ONLY: COSP_LIDAR_ONLY_CLOUD,COSP_CHANGE_VERTICAL_GRID, & COSP_DIAG_WARMRAIN @@ -422,8 +422,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) zlev (:,:), & ! altitude (used only when use_vgrid=.true.) cfodd_ntotal (:,:,:,:), & ! # of total samples for CFODD (Npoints,CFODD_NDBZE,CFODD_NICOD,CFODD_NCLASS) wr_occfreq_ntotal(:,:) ! # of warm-rain (nonprecip/drizzle/precip) (Npoints,WR_NREGIME) -! type(rttov_instrument_OUT),dimension(:),allocatable :: & ! JKS where RTTOV outputs are actually stored, not a pointer -! cosp_inst_OUTS ! Initialize error reporting for output cosp_simulator(:)='' @@ -1648,9 +1646,9 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! RTTOV multi-instrument if (Lrttov_column) then print*,'0.' - ! 0. Load the column inputs. These are constant across instruments. - -! allocate(cosp_inst_OUTS(cospIN%Ninst_rttov)) ! Allocate output fields (I actually don't need this type because I run the instruments one-at-a-time + ! 0. Load the column inputs into the . These are constant across instruments. +! call cosp_rttov_construct_profiles(rttovIN) ! Profile information is stored at the simulator level +! For now, the "profiles" object is complicated and different for each instrument/setting (depends on clouds, trace gases, PC-RTTOV, etc) ! 1. Allocate output for each requested instrument ! 2. Run RTTOV for each instrument, passing the config files along. @@ -1664,39 +1662,33 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Only allocate clear-sky memory when PC-RTTOV is run. print*,'cospIN % cfg_rttov(i) % nchan_out: ',cospIN % cfg_rttov(i) % nchan_out ! issue here allocate(rttov_Ichannel(cospIN % cfg_rttov(i) % nchan_out)) ! Channel indices -! allocate(cosp_inst_OUTS(i) % channel_indices(cospIN % cfg_rttov(i) % nchan_out)) ! Channel indices print*,'2' if (cospIN % cfg_rttov(i) % Lrttov_pc) then print*,'3a' - allocate(rttov_bt_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp + allocate(rttov_bt_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp allocate(rttov_rad_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky radiance -! allocate(cosp_inst_OUTS(i) % bt_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp -! allocate(cosp_inst_OUTS(i) % rad_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky radiance - ! allocate(rttov_bt_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky brightness temp ! allocate(rttov_rad_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky radiance else print*,'3b' - allocate(rttov_bt_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp - allocate(rttov_bt_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! clear-sky brightness temp - allocate(rttov_rad_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp - allocate(rttov_rad_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! clear-sky brightness temp + allocate(rttov_bt_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp + allocate(rttov_bt_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! clear-sky brightness temp + allocate(rttov_rad_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp + allocate(rttov_rad_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! clear-sky brightness temp allocate(rttov_rad_cloudy(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! cloudy-sky brightness temp allocate(rttov_refl_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky Bi-directional reflectance factor - allocate(rttov_refl_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! clear-sky Bi-directional reflectance factor - -! allocate(cosp_inst_OUTS(i) % bt_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp -! allocate(cosp_inst_OUTS(i) % bt_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! clear-sky brightness temp -! allocate(cosp_inst_OUTS(i) % rad_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp -! allocate(cosp_inst_OUTS(i) % rad_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! clear-sky brightness temp -! allocate(cosp_inst_OUTS(i) % rad_cloudy(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! cloudy-sky brightness temp -! allocate(cosp_inst_OUTS(i) % refl_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky Bi-directional reflectance factor -! allocate(cosp_inst_OUTS(i) % refl_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! clear-sky Bi-directional reflectance factor + allocate(rttov_refl_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! clear-sky Bi-directional reflectance factor endif - ! JKS new RTTOV subroutine for v13 called from the RTTOV interface. call cpu_time(driver_time(3)) + print*,'4.' ! Run simulator + call cosp_rttov_simulate_mi(rttovIN,cospIN%cfg_rttov(i),Lrttov_cleanUp, & ! Inputs + rttov_Ichannel, & ! Channel Indices + rttov_bt_total,rttov_bt_clear, & ! Brightness Temp Outputs + rttov_rad_total,rttov_rad_clear,rttov_rad_cloudy, & ! Radiance Outputs + rttov_refl_total,rttov_refl_clear, & ! Reflectance Outputs + cosp_simulator(nError+1)) ! call cosp_rttov_simulate(rttovIN,Lrttov_cleanUp, & ! Inputs ! cosp_inst_OUTS(i), & ! RTTOV output fields DDT ! cosp_simulator(nError+1)) @@ -1705,11 +1697,9 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Write to cospOUT if (associated(cospOUT % rttov_outputs(i) % channel_indices)) & -! cospOUT % rttov_outputs(i) % channel_indices(:) = cosp_inst_OUTS(i) % channel_indices cospOUT % rttov_outputs(i) % channel_indices(:) = rttov_Ichannel if (cospIN % cfg_rttov(i) % Lrttov_pc) then if (associated(cospOUT % rttov_outputs(i) % bt_total_pc)) & -! cospOUT % rttov_outputs(i) % bt_total_pc(ij:ik,:) = cosp_inst_OUTS(i) % bt_total cospOUT % rttov_outputs(i) % bt_total_pc(ij:ik,:) = rttov_bt_total if (associated(cospOUT % rttov_outputs(i) % rad_total_pc)) & cospOUT % rttov_outputs(i) % rad_total_pc(ij:ik,:) = rttov_rad_total @@ -1739,17 +1729,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (allocated(rttov_rad_cloudy)) deallocate(rttov_rad_cloudy) if (allocated(rttov_refl_total)) deallocate(rttov_refl_total) if (allocated(rttov_refl_clear)) deallocate(rttov_refl_clear) - - ! Free up memory from output (if necessary) -! if (allocated(cosp_inst_OUTS(i) % channel_indices)) deallocate(cosp_inst_OUTS(i) % channel_indices) -! if (allocated(cosp_inst_OUTS(i) % bt_total)) deallocate(cosp_inst_OUTS(i) % bt_total) -! if (allocated(cosp_inst_OUTS(i) % bt_clear)) deallocate(cosp_inst_OUTS(i) % bt_clear) -! if (allocated(cosp_inst_OUTS(i) % rad_total)) deallocate(cosp_inst_OUTS(i) % rad_total) -! if (allocated(cosp_inst_OUTS(i) % rad_clear)) deallocate(cosp_inst_OUTS(i) % rad_clear) -! if (allocated(cosp_inst_OUTS(i) % rad_cloudy)) deallocate(cosp_inst_OUTS(i) % rad_cloudy) -! if (allocated(cosp_inst_OUTS(i) % refl_total)) deallocate(cosp_inst_OUTS(i) % refl_total) -! if (allocated(cosp_inst_OUTS(i) % refl_clear)) deallocate(cosp_inst_OUTS(i) % refl_clear) - end do diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index f190d80efd..72151ad2d6 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -100,8 +100,8 @@ MODULE MOD_COSP_RTTOV_INTERFACE SO2_mr, & rttov_ZenAng integer(kind=jpim), allocatable :: & - iChannel(:), & - iChannel_out(:) ! Passing out the channel indices + iChannel(:), & ! Requested channel indices + iChannel_out(:) ! Passing out the channel indices (actual output channels) real(kind=jplm),allocatable :: & emisChannel(:), & ! RTTOV channel emissivity reflChannel(:) ! RTTOV channel reflectivity @@ -113,6 +113,8 @@ MODULE MOD_COSP_RTTOV_INTERFACE type rttov_output + integer :: & + nchan_out integer,pointer :: & channel_indices(:) real(wp),pointer :: & @@ -257,11 +259,13 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & ! Set paths for RTTOV config rttov_config%rttov_srcDir = rttov_srcDir rttov_config%rttov_coefDir = rttov_coefDir - rttov_config%OD_coef_filepath = OD_coef_filepath - rttov_config%aer_coef_filepath = aer_coef_filepath - rttov_config%cld_coef_filepath = cld_coef_filepath - rttov_config%PC_coef_filepath = PC_coef_filepath - + + ! Construct optical depth and cloud coefficient files + rttov_config%OD_coef_filepath = trim(rttov_config%rttov_srcDir)//trim(rttov_config%rttov_coefDir)//trim(OD_coef_filepath) + rttov_config%aer_coef_filepath = trim(rttov_config%rttov_srcDir)//trim(rttov_config%rttov_coefDir)//trim(aer_coef_filepath) + rttov_config%cld_coef_filepath = trim(rttov_config%rttov_srcDir)//trim(rttov_config%rttov_coefDir)//trim(cld_coef_filepath) + rttov_config%PC_coef_filepath = trim(rttov_config%rttov_srcDir)//trim(rttov_config%rttov_coefDir)//trim(PC_coef_filepath) + ! Set other RTTOV config variables rttov_config%rttov_direct_nthreads = rttov_nthreads @@ -366,7 +370,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & rttov_config % opts % dev % do_opdep_calc = .true. ! If using PC-RTTOV, some settings must be a certain way. This isn't always true though... - if (do_rttov_pcrttov) then + if (Lrttov_pc) then rttov_config % opts % rt_ir % pc % addpc = .true. rttov_config % opts % rt_ir % pc % ipcbnd = ipcbnd rttov_config % opts % rt_ir % pc % ipcreg = ipcreg @@ -390,30 +394,21 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & ! ------------------------------------------------------ ! Using the GUI to figure out files that work together could be helpful here. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - ! Construct optical depth and cloud coefficient files - OD_coef_filepath = trim(rttov_srcDir)//trim(rttov_coefDir)//trim(OD_coef_filepath) - aer_coef_filepath = trim(rttov_srcDir)//trim(rttov_coefDir)//trim(aer_coef_filepath) - cld_coef_filepath = trim(rttov_srcDir)//trim(rttov_coefDir)//trim(cld_coef_filepath) - - print*,'OD_coef_filepath: ',OD_coef_filepath - print*,'aer_coef_filepath: ',aer_coef_filepath - print*,'cld_coef_filepath: ',cld_coef_filepath - + ! Do I need logicals here to direct how to read the coefficients? if (rttov_config % Lrttov_pc) then ! PC-RTTOV cannot handle cloud, some aerosols - PC_coef_filepath = trim(rttov_srcDir)//trim(rttov_coefDir)//trim(PC_coef_filepath) call rttov_read_coefs(errorstatus, rttov_config % coefs, & rttov_config % opts, & - file_coef=OD_coef_filepath, & -! file_scaer=aer_coef_filepath, & ! Needs to be PC-RTTOV compatible - file_pccoef=PC_coef_filepath) + file_coef=rttov_config % OD_coef_filepath, & +! file_scaer=rttov_config % aer_coef_filepath, & ! Needs to be PC-RTTOV compatible + file_pccoef=rttov_config % PC_coef_filepath) else ! Read optical depth and cloud coefficient files together call rttov_read_coefs(errorstatus, rttov_config % coefs, & rttov_config % opts, & - file_coef=OD_coef_filepath, & - file_scaer=aer_coef_filepath, & - file_sccld=cld_coef_filepath) + file_coef=rttov_config % OD_coef_filepath, & + file_scaer=rttov_config % aer_coef_filepath, & + file_sccld=rttov_config % cld_coef_filepath) + ! Ensure input number of channels is not higher than number stored in coefficient file if (nchannels_rec2 > rttov_config % coefs % coef % fmv_chn) then nchannels_rec2 = rttov_config % coefs % coef % fmv_chn @@ -734,17 +729,10 @@ SUBROUTINE COSP_RTTOV_INIT(nchan_out,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Construct optical depth and cloud coefficient files -! PC_coef_filepath = 'test' - - ! rttovDir should be "/glade/u/home/jonahshaw/w/RTTOV/" and is defined in cosp_config.F90 OD_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(OD_coef_filepath) aer_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(aer_coef_filepath) cld_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(cld_coef_filepath) - -! print*,'OD_coef_filepath: ',OD_coef_filepath -! print*,'aer_coef_filepath: ',aer_coef_filepath -! print*,'cld_coef_filepath: ',cld_coef_filepath - + ! Do I need logicals here to direct how to read the coefficients? @@ -892,11 +880,67 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, endif END SUBROUTINE COSP_RTTOV_SIMULATE + + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE cosp_rttov_simulate - Call subroutines in mod_cosp_rttov to run RTTOV + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE COSP_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, & ! Inputs + iChannel_ret, & ! Channel index outputs + bt_total,bt_clear, & ! Brightness Temp Outputs + rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs + refl_total,refl_clear, & ! Reflectance Outputs + error) + + type(rttov_in),intent(in) :: & + rttovIN + type(rttov_cfg),intent(inout) :: & + rttovConfig + logical,intent(in) :: & + lCleanup ! Flag to determine whether to deallocate RTTOV types + integer(kind=jpim),intent(out),dimension(rttovIN%nChannels) :: & ! Channels indices to return for output + iChannel_ret + real(wp),intent(inout),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! + bt_total, & ! All-sky + bt_clear, & ! Clear-sky + rad_total, & ! All-sky + rad_clear, & ! Clear-sky + rad_cloudy, & ! Cloudy-sky + refl_total, & ! All-sky + refl_clear ! Clear-sky + character(len=128) :: & + error ! Error messages (only populated if error encountered) + + ! Check options to determine if the principal component approach should be run + if (rttovConfig % opts % rt_ir % pc % addpc) then + print*,'Running COSP_PC_RTTOV_SIMULATE in multi-inst. set-up' + call COSP_PC_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, & + bt_total,rad_total, & + error) + +! print*,'SIZE(iChannel_ret): ',SIZE(iChannel_ret) +! print*,'SIZE(iChannel_out): ',SIZE(iChannel_out) + iChannel_ret = iChannel_out ! JKS need to fix this + else + print*,'Running COSP_REG_RTTOV_SIMULATE in multi-inst. set-up' + call COSP_REG_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, & + bt_total,bt_clear, & + rad_total,rad_clear,rad_cloudy, & + refl_total,refl_clear, & + error) + +! print*,'SIZE(iChannel_ret): ',SIZE(iChannel_ret) +! print*,'SIZE(iChannel): ',SIZE(iChannel) + iChannel_ret = iChannel ! JKS need to fix this, better define these variables + + endif + + END SUBROUTINE COSP_RTTOV_SIMULATE_MI !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_simulate - Call regular subroutines in mod_cosp_rttov to run RTTOV !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,lCleanup, & ! Inputs + SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,lCleanup, & ! Inputs bt_total,bt_clear, & ! Brightness Temp Outputs rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs refl_total,refl_clear, & ! Reflectance Outputs @@ -914,7 +958,7 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,lCleanup, type(rttov_in),intent(in) :: & rttovIN logical,intent(in) :: & - lCleanup ! Flag to determine whether to deallocate RTTOV types + lCleanup ! Flag to determine whether to deallocate RTTOV types real(wp),intent(inout),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! bt_total, & ! All-sky bt_clear, & ! Clear-sky @@ -972,6 +1016,104 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,lCleanup, END SUBROUTINE COSP_REG_RTTOV_SIMULATE + SUBROUTINE COSP_REG_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, & ! Inputs + bt_total,bt_clear, & ! Brightness Temp Outputs + rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs + refl_total,refl_clear, & ! Reflectance Outputs + error) + + use mod_cosp_rttov, only: & + cosp_rttov_allocate_mi, & + cosp_rttov_construct_profiles_mi, & + cosp_rttov_setup_emissivity_reflectance, & + cosp_rttov_call_direct_mi, & + cosp_rttov_save_output_mi, & + cosp_rttov_deallocate_profiles_mi, & + cosp_rttov_deallocate_coefs_mi + + type(rttov_in),intent(in) :: & + rttovIN + type(rttov_cfg),intent(inout) :: & + rttovConfig + logical,intent(in) :: & + lCleanup ! Flag to determine whether to deallocate RTTOV types + real(wp),intent(inout),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! + bt_total, & ! All-sky + bt_clear, & ! Clear-sky + rad_total, & ! All-sky + rad_clear, & ! Clear-sky + rad_cloudy, & ! Cloudy-sky + refl_total, & ! All-sky + refl_clear ! Clear-sky + character(len=128) :: & + error ! Error messages (only populated if error encountered) + + real(wp),dimension(10) :: driver_time + + ! Run each step for running RTTOV from mod_cosp_rttov (and time them) + print*,'cosp_rttov_allocate begin' ! jks + call cpu_time(driver_time(1)) + call cosp_rttov_allocate_mi(rttovIN, & + rttovConfig % nChannels_rec, & + rttovConfig % opts, & + rttovConfig % coefs, & + rttovConfig % iChannel) + + print*,'cosp_rttov_allocate successful' ! jks + call cpu_time(driver_time(2)) + call cosp_rttov_construct_profiles_mi(rttovIN, & + rttovConfig % opts % rt_ir % addclouds, & + rttovConfig % opts % rt_ir % addaerosl) + print*,'cosp_rttov_construct_profiles_mi successful' ! jks + call cpu_time(driver_time(3)) + call cosp_rttov_setup_emissivity_reflectance() ! Config agnostic after allocate step. + print*,'cosp_rttov_setup_emissivity_reflectance successful' ! jks + call cpu_time(driver_time(4)) + call cosp_rttov_call_direct_mi(rttovConfig % rttov_direct_nthreads, & + rttovConfig % opts, & + rttovConfig % coefs) + + print*,'cosp_rttov_call_direct successful' ! jks + call cpu_time(driver_time(5)) + + call cosp_rttov_save_output_mi(rttovIN, & + rttovConfig % nchan_out, & + rttovConfig % Lrttov_bt, & + rttovConfig % Lrttov_rad, & + rttovConfig % Lrttov_refl, & + rttovConfig % opts % rt_ir % addclouds, & + rttovConfig % opts % rt_ir % addaerosl, & + bt_total,bt_clear, & + rad_total,rad_clear,rad_cloudy, & + refl_total,refl_clear) + + print*,'cosp_rttov_save_output successful' ! jks + call cpu_time(driver_time(6)) + call cosp_rttov_deallocate_profiles_mi(rttovIN, & + rttovConfig % nChannels_rec, & + rttovConfig % opts, & + rttovConfig % coefs) + call cpu_time(driver_time(7)) + + print*,'Time to run "cosp_rttov_allocate": ', driver_time(2)-driver_time(1) + print*,'Time to run "cosp_rttov_construct_profiles": ', driver_time(3)-driver_time(2) + print*,'Time to run "cosp_rttov_setup_emissivity_reflectance": ',driver_time(4)-driver_time(3) + print*,'Time to run "cosp_rttov_call_direct": ', driver_time(5)-driver_time(4) + print*,'Time to run "cosp_rttov_save_output": ', driver_time(6)-driver_time(5) + print*,'Time to run "cosp_rttov_deallocate_profiles": ', driver_time(7)-driver_time(6) + + ! Deallocate the coefficient files if directed + if (lCleanup) then + call cpu_time(driver_time(8)) + call cosp_rttov_deallocate_coefs_mi(rttovConfig % coefs) + call cpu_time(driver_time(9)) + print*,'Time to run "cosp_rttov_deallocate_coefs": ',driver_time(9)-driver_time(8) + endif + +! print*,'Total RTTOV run time: ',driver_time(8)-driver_time(1) + + END SUBROUTINE COSP_REG_RTTOV_SIMULATE_MI + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_pc_rttov_simulate - Call subroutines in mod_cosp_rttov to run RTTOV @@ -990,7 +1132,7 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,lCleanup, cosp_rttov_deallocate_coefs type(rttov_in),intent(in) :: & - rttovIN + rttovIN logical,intent(in) :: & lCleanup ! Flag to determine whether to deallocate RTTOV types real(wp),intent(inout),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! @@ -1045,6 +1187,93 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,lCleanup, END SUBROUTINE COSP_PC_RTTOV_SIMULATE + SUBROUTINE COSP_PC_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, & ! Inputs + bt_total,rad_total, & ! Outputs + error) + + use mod_cosp_rttov, only: & + cosp_pc_rttov_allocate_mi, & + cosp_rttov_construct_profiles_mi, & + cosp_pc_rttov_setup_emissivity, & + cosp_pc_rttov_call_direct_mi, & + cosp_pc_rttov_save_output_mi, & + cosp_pc_rttov_deallocate_profiles_mi, & + cosp_rttov_deallocate_coefs_mi + + type(rttov_in),intent(in) :: & + rttovIN + type(rttov_cfg),intent(inout) :: & + rttovConfig + logical,intent(in) :: & + lCleanup ! Flag to determine whether to deallocate RTTOV types + real(wp),intent(inout),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! + bt_total, & ! All-sky + rad_total ! All-sky + character(len=128) :: & + error ! Error messages (only populated if error encountered) + + real(wp),dimension(10) :: driver_time + + ! Run each step for running RTTOV from mod_cosp_rttov (and time them) +! print*,'cosp_rttov_allocate begin' ! jks + call cpu_time(driver_time(1)) + call cosp_pc_rttov_allocate_mi(rttovIN, & + rttovConfig%PC_coef_filepath, & + rttovConfig%coefs, & + rttovConfig%opts, & + rttovConfig%nchannels_rec, & + rttovConfig%iChannel, & + rttovConfig%iChannel_out) + print*,'cosp_pc_rttov_allocate_mi successful' ! jks + call cpu_time(driver_time(2)) + call cosp_rttov_construct_profiles_mi(rttovIN, & + rttovConfig % opts % rt_ir % addclouds, & + rttovConfig % opts % rt_ir % addaerosl) + print*,'cosp_rttov_construct_profiles_mi successful' ! jks + call cpu_time(driver_time(3)) + call cosp_pc_rttov_setup_emissivity() + print*,'cosp_pc_rttov_setup_emissivity successful' ! jks + call cpu_time(driver_time(4)) + call cosp_pc_rttov_call_direct_mi(rttovConfig % rttov_direct_nthreads, & + rttovConfig % opts, & + rttovConfig % coefs, & + rttovConfig % nchannels_rec, & + rttovConfig % iChannel_out) ! iChannel_out should have been updated + + print*,'cosp_pc_rttov_call_direct successful' ! jks + call cpu_time(driver_time(5)) + call cosp_pc_rttov_save_output_mi(rttovIN%nPoints, & + rttovConfig%nchannels_rec, & + rttovConfig%Lrttov_bt, & + rttovConfig%Lrttov_rad, & + bt_total, & + rad_total) + + print*,'cosp_pc_rttov_save_output successful' ! jks + call cpu_time(driver_time(6)) + call cosp_pc_rttov_deallocate_profiles_mi(rttovIN, & + rttovConfig % nChannels_rec, & + rttovConfig % opts, & + rttovConfig % coefs) + call cpu_time(driver_time(7)) + + print*,'Time to run "cosp_pc_rttov_allocate": ', driver_time(2)-driver_time(1) + print*,'Time to run "cosp_rttov_construct_profiles": ', driver_time(3)-driver_time(2) + print*,'Time to run "cosp_pc_rttov_setup_emissivity": ', driver_time(4)-driver_time(3) + print*,'Time to run "cosp_pc_rttov_call_direct": ', driver_time(5)-driver_time(4) + print*,'Time to run "cosp_pc_rttov_save_output": ', driver_time(6)-driver_time(5) + print*,'Time to run "cosp_pc_rttov_deallocate_profiles": ', driver_time(7)-driver_time(6) + + ! Deallocate the coefficient files if directed + if (lCleanup) then + call cpu_time(driver_time(8)) +! call cosp_rttov_deallocate_coefs_mi(rttovConfig % coefs) ! JKS this again with PC-RTTOV... + call cpu_time(driver_time(9)) + print*,'Time to run "cosp_rttov_deallocate_coefs": ',driver_time(9)-driver_time(8) + endif + + END SUBROUTINE COSP_PC_RTTOV_SIMULATE_MI + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! END MODULE ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 22ffd8c29b..991dfe5b39 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -170,7 +170,7 @@ module mod_cosp_rttov ! JKS additional variables used in PC-RTTOV INTEGER(KIND=jpim), POINTER :: predictindex(:) INTEGER(KIND=jpim) :: nchannels_comp, npcscores, npred_pc ! npred to go here - INTEGER(KIND=jpim) :: lo, hi +! INTEGER(KIND=jpim) :: lo, hi ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! TYPE rttov_in @@ -220,24 +220,6 @@ module mod_cosp_rttov fl_rain, & ! Precipitation flux (startiform+convective rain) (kg/m2/s) fl_snow ! Precipitation flux (stratiform+convective snow) end type rttov_IN - - ! RTTOV output fields for an individual instrument -! type rttov_instrument_OUT -! integer(kind=jpim),pointer :: & -! nChannels -! real(wp), dimension(:),allocatable :: & -! channel_indices -! real(wp), dimension(:,:),allocatable :: & -! bt_total, & ! Brightness Temperature -! bt_clear, & ! Brightness Temperature -! rad_total, & ! Radiance -! rad_clear, & ! Radiance -! rad_cloudy, & ! Radiance -! refl_total, & ! Reflectance -! refl_clear, & ! Reflectance -! bt_total_pc, & ! Brightness Temperature (PC-RTTOV) -! rad_total_pc ! Radiance (PC-RTTOV) -! end type rttov_instrument_OUT contains @@ -323,7 +305,77 @@ subroutine cosp_rttov_allocate(rttovIN & end do end subroutine cosp_rttov_allocate - + + subroutine cosp_rttov_allocate_mi(rttovIN,inst_nChannels_rec,inst_opts, & + inst_coefs,inst_iChannel) + + type(rttov_in),intent(in) :: & + rttovIN + integer(kind=jpim),intent(in) :: & + inst_nChannels_rec + type(rttov_options),intent(in) :: & + inst_opts + type(rttov_coefs),intent(in) :: & + inst_coefs + integer(kind=jpim),dimension(inst_nChannels_rec),intent(in) :: & + inst_iChannel + + ! Loop variables + integer(kind=jpim) :: j, jch, nch + + ! Other local variables +! integer(kind=jpim) :: inst_nchanprof ! JKS to-do. Then add inst_chanprof as an intent(out) variable + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 3. Allocate RTTOV input and output structures + ! ------------------------------------------------------ + ! Largely from RTTOV documentation. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + ! Determine the total number of radiances to simulate (nchanprof). +! nchanprof = rttovIN%nChannels * rttovIN%nPoints + nchanprof = inst_nChannels_rec * rttovIN%nPoints ! RTTOV (non-PC) needs nchan_out? JKS potential bug +! print*,'nchanprof: ',nchanprof + + ! Allocate structures for rttov_direct + call rttov_alloc_direct( & + errorstatus, & + 1_jpim, & ! 1 => allocate + rttovIN%nPoints, & + nchanprof, & + rttovIN%nLevels, & + chanprof, & +! rttovConfig%opts, & + inst_opts, & + profiles, & +! rttovConfig%coefs, & + inst_coefs, & + transmission, & + radiance, & + calcemis=calcemis, & + emissivity=emissivity, & + calcrefl=calcrefl, & + reflectance=reflectance, & + init=.TRUE._jplm) + call rttov_error('allocation error for rttov_direct structures' , lalloc = .false.) + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 4. Build the list of profile/channel indices in chanprof + ! ------------------------------------------------------ + ! Largely from RTTOV documentation. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + nch = 0_jpim + do j = 1, rttovIN%nPoints + do jch = 1, inst_nChannels_rec ! nChannels +! do jch = 1, rttovIN%nChannels ! nChannels + nch = nch + 1_jpim + chanprof(nch)%prof = j + chanprof(nch)%chan = inst_iChannel(jch) ! Example code used channel_list + end do + end do + + end subroutine cosp_rttov_allocate_mi ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE pc_rttov_allocate - Subroutine for running PC-RTTOV @@ -339,6 +391,7 @@ subroutine cosp_pc_rttov_allocate(rttovIN & ! Loop variables integer(kind=jpim) :: j, jch, nch + integer(kind=jpim) :: lo, hi ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 3. Allocate RTTOV input and output structures @@ -415,7 +468,120 @@ subroutine cosp_pc_rttov_allocate(rttovIN & end do end subroutine cosp_pc_rttov_allocate - + + + subroutine cosp_pc_rttov_allocate_mi(rttovIN,inst_PC_coef_filepath, & !inst_npcscores, & + inst_coefs,inst_opts, & + inst_nchannels_rec,inst_iChannel_in, & + inst_iChannel_out) !,inst_predictindex) + + type(rttov_in),intent(in) :: & + rttovIN + character(256),intent(in) :: & + inst_PC_coef_filepath +! integer(kind=jpim),intent(in) :: & +! inst_npcscores + type(rttov_coefs),intent(in) :: & + inst_coefs + type(rttov_options),intent(inout) :: & + inst_opts + integer(kind=jpim),intent(inout) :: & + inst_nchannels_rec + integer(kind=jpim),intent(in),dimension(inst_nchannels_rec) :: & + inst_iChannel_in ! Channel indices the user initially requests. + integer(kind=jpim),intent(inout),allocatable :: & + inst_iChannel_out(:) ! Passing out the channel indices +! integer(KIND=jpim),intent(out),POINTER :: & +! inst_predictindex(:) + + + + ! Loop variables + integer(kind=jpim) :: j, jch, nch + integer(kind=jpim) :: lo, hi + + ! Local variables + integer(kind=jpim) :: inst_npred_pc + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 3. Allocate RTTOV input and output structures + ! ------------------------------------------------------ + ! Largely from RTTOV documentation. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + nullify(predictindex) + call rttov_get_pc_predictindex(errorstatus, inst_opts, predictindex, file_pccoef=inst_PC_coef_filepath) + call rttov_error('rttov_get_pc_predictindex fatal error' , lalloc = .false.) + + ! npred_pc is only used in the pc_rttov_allocate step so I can remove the global definition later + inst_npred_pc = SIZE(predictindex) + nchanprof = inst_npred_pc * rttovIN%nPoints ! Size of chanprof array is total number of predictors over all profiles + + ! Determine the number of reconstructed radiances per profile (nchannels_rec) + if (inst_opts % rt_ir % pc % addradrec) then + if (inst_nchannels_rec < 0) then + ! If the number of channels is negative, don't reconstruct radiances at all + print*,'radrec 1.' + inst_opts % rt_ir % pc % addradrec = .FALSE. + else if (inst_nchannels_rec == 0) then + ! If the number of channels is set to 0 then reconstruct all instrument channels + print*,'radrec 2.' + inst_nchannels_rec = inst_coefs % coef % fmv_chn +! allocate(channels_rec(inst_nchannels_rec)) +! channels_rec(:) = (/ (j, j = 1, inst_nchannels_rec) /) + allocate(inst_iChannel_out(inst_nchannels_rec)) + inst_iChannel_out = (/ (j, j = 1, inst_nchannels_rec) /) + else + ! Otherwise read the channel list from the file + print*,'radrec 3.' + print*,'inst_nchannels_rec: ',inst_nchannels_rec +! allocate(channels_rec(nchannels_rec)) +! channels_rec(:) = iChannel ! channels_rec is just the index of the desired channels + allocate(inst_iChannel_out(inst_nchannels_rec)) + inst_iChannel_out = inst_iChannel_in + endif + endif + + ! Ensure we don't have unassociated pointers below when addradrec is FALSE + if (inst_nchannels_rec <= 0) allocate(inst_iChannel_out(0)) + + ! Allocate structures for rttov_direct + CALL rttov_alloc_direct( & + errorstatus, & + 1_jpim, & ! 1 => allocate + rttovIN%nPoints, & + nchanprof, & + rttovIN%nLevels, & + chanprof, & ! Make this instrument-specific? The rttov_config DDT would then be assigned to this value. Allocation difficulties? + inst_opts, & + profiles, & + inst_coefs, & + transmission, & + radiance, & + calcemis=calcemis, & + emissivity=emissivity, & + npcscores=inst_opts%rt_ir%pc%npcscores * rttovIN%nPoints, & + nchannels_rec=inst_nchannels_rec * rttovIN%nPoints, & + pccomp=pccomp, & + init=.TRUE._jplm) + call rttov_error('allocation error for rttov_direct structures (PC-RTTOV)' , lalloc = .true.) + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 4. Build the list of profile/channel indices in chanprof + ! ------------------------------------------------------ + ! Largely from RTTOV documentation. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + ! Populate chanprof using the channel list obtained above in predictindex(:) + do j = 1, rttovIN%nPoints + lo = (j - 1) * inst_npred_pc + 1 + hi = lo + inst_npred_pc - 1 + chanprof(lo:hi)%prof = j + chanprof(lo:hi)%chan = predictindex(:) + end do + + end subroutine cosp_pc_rttov_allocate_mi + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 5. rttov_construct_profiles: 5. Read profile data @@ -440,13 +606,6 @@ subroutine cosp_rttov_construct_profiles(rttovIN & ! ozone_data, co2_data and so on in the options structure should be ! set to false." -! print*,'co2: ',co2 -! print*,'n2o: ',n2o -! print*,'co: ',co -! print*,'ch4: ',ch4 -! print*,'so2: ',so2 -! print*,'zenang: ',zenang - profiles(:)%gas_units = 1 ! kg/kg over moist air (default) do i = 1, rttovIN%nPoints @@ -594,7 +753,175 @@ subroutine cosp_rttov_construct_profiles(rttovIN & ! JKS To-do: set up scattering profiles (MW only) (rttov_profile_cloud) end subroutine cosp_rttov_construct_profiles - + + subroutine cosp_rttov_construct_profiles_mi(rttovIN,Lrttov_cld,Lrttov_aer & + ) + + type(rttov_in),intent(in) :: & ! What is the best way to do this? Should rttovIN be a module-wide DDT? Yes. + rttovIN + logical,intent(in) :: & + Lrttov_cld, & + Lrttov_aer + + ! Loop variables + integer(kind=jpim) :: i, j ! Use i to iterate over profile, j for levels. + + ! Store profile data from rttovIN in profile type. + ! See RTTOV user guide pg 163 for description of "profiles" type + + ! "The rttov_profile structure is composed of the atmospheric part + ! and two other structures for 2 meter air and skin surface. + ! If you are not able to provide ozone, CO2, etc profiles the flags + ! ozone_data, co2_data and so on in the options structure should be + ! set to false." + + profiles(:)%gas_units = 1 ! kg/kg over moist air (default) + + do i = 1, rttovIN%nPoints + + ! Initialize trace gas concentrations from user input + ! These gases are not in COSP input files but might be in the futre + profiles(i)%co2(:) = co2 + profiles(i)%n2o(:) = n2o + profiles(i)%co(:) = co + profiles(i)%ch4(:) = ch4 + profiles(i)%so2 = so2 + +! profiles(i)%co2(:) = rttovIN%co2 +! profiles(i)%n2o(:) = rttovIN%n2o +! profiles(i)%co(:) = rttovIN%co +! profiles(i)%ch4(:) = rttovIN%ch4 + + ! Initialize column pressure, temperature, and humidity + profiles(i)%p(:) = rttovIN%p(i, :) * 1e-2 ! convert Pa to hPa + profiles(i)%t(:) = rttovIN%t(i, :) + profiles(i)%q(:) = rttovIN%q(i, :) + + ! q coefficient limit is 0.1e-10 + where(profiles(i)%q(:) < 0.1e-10) + profiles(i)%q(:) = 0.11e-10 + end where + + ! Gas profiles + profiles(i)%o3 = rttovIN%o3(i, :) + + ! 2m parameters + profiles(i)%s2m%p = rttovIN%p_surf(i) * 1e-2 ! convert Pa to hPa + profiles(i)%s2m%t = rttovIN%t2m(i) ! JKS or rttovIN%t_skin + profiles(i)%s2m%q = rttovIN%q2m(i) ! Should be the same as gas units (kg/kg) + profiles(i)%s2m%u = rttovIN%u_surf(i) + profiles(i)%s2m%v = rttovIN%v_surf(i) + profiles(i)%s2m%wfetc = 10000. ! only used by sea surface solar BRDF model. + + ! skin variables for emissivity calculations + profiles(i)%skin%t = rttovIN%t_skin(i) + + ! fastem coefficients - for mw calculations + profiles(i)%skin%fastem(1) = 3.0 + profiles(i)%skin%fastem(2) = 5.0 + profiles(i)%skin%fastem(3) = 15.0 + profiles(i)%skin%fastem(4) = 0.1 + profiles(i)%skin%fastem(5) = 0.3 + + ! Viewing angles + profiles(i)%zenangle = zenang ! pass in from cosp + profiles(i)%azangle = 0. ! hard-coded in rttov9 int JKS-? + + profiles(i)%latitude = rttovIN%latitude(i) + profiles(i)%longitude = rttovIN%longitude(i) + profiles(i)%elevation = rttovIN%h_surf(i) * 1e-3 ! Convert m to km + + ! Solar angles. JKS - get this from COSP/CESM? Doesn't seem to be passed in. + profiles(i)%sunzenangle = 0. ! hard-coded in rttov9 int + profiles(i)%sunazangle = 0. ! hard-coded in rttov9 int + + ! surface type + ! land-sea mask (lsmask) indicates proportion of land in grid + if (rttovIN%lsmask(i) < 0.5) then + profiles(i)%skin%surftype = surftype_sea + else + profiles(i)%skin%surftype = surftype_land + endif + ! sea-ice fraction + if (rttovIN%seaice(i) >= 0.5) then + profiles(i)%skin%surftype = surftype_seaice + endif + + ! dar: hard-coded to 1 (=ocean water) in rttov 9 int + profiles(i)%skin%watertype = 1 + !profiles(i) %idg = 0. ! Depreciated? + !profiles(i) %ish = 0. ! Depreciated? + end do + + ! JKS - nothing to check here, this will never trigger. + call rttov_error('error in profile initialization' , lalloc = .false.) + +! print*,'profiles(1)%p(:): ',profiles(1)%p(:) +! print*,'profiles(1)%q(:): ',profiles(1)%q(:) +! print*,'profiles(1)%t(:): ',profiles(1)%t(:) + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Only add the cloud fields if simulating cloud. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + if (Lrttov_cld) then + + ! Set cloud mass mixing ratio units + profiles(:)%mmr_cldaer = .true. ! kg/kg for cloud and aerosol (default) + + profiles(:)%clw_scheme = 2 ! Deff scheme avoids cloud types + ! profiles%clwde_scheme = 1. ! Not implemented? + profiles(:)%ice_scheme = 1 !1:Baum 2:Baran(2014) 3:Baran(2018) + profiles(:)%icede_param = 2 ! 2:Wyser(recommended). Only used if ice effective diameter not input + + do i = 1, rttovIN%nPoints + ! Cloud scheme stuff + profiles(i)%cfrac(:) = rttovIN%tca(i,:) ! Cloud fraction for each layer + profiles(i)%cloud(1,:) = rttovIN%cldLiq(i,:) ! Cloud water mixing ratio (all in the first type for Deff) + profiles(i)%cloud(6,:) = rttovIN%cldIce(i,:) ! Cloud ice mixing ratio (1 type). See pg 74. + + ! Example UKMO input has effective radii for multiple cloud types, making identification of a single + ! liquid droplet or ice crystal effective diameter difficult. + ! I opt to let RTTOV decide on the effective radius values, but more complex implementation + ! could do a more thorough conversion between UKMO output and RTTOV input + ! profiles(i)%clwde = ! Cloud water effective diameter + ! profiles(i)%icede = ! Cloud ice effective diameter + + ! Old code for simple cloud schemes only + ! profiles(i)%cfraction = 0. + ! profiles(i)%ctp = 500. + + ! Other options not implemented +! profiles(i)%clw = ! Cloud liquid water (kg/kg) – MW only, + end do + endif + + ! JKS - nothing to check here, this will never trigger. + call rttov_error('error in cloud profile initialization' , lalloc = .false.) + + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Only add the aerosol fields if simulating aerosol. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + if (Lrttov_aer) then + + ! Set aerosol mass mixing ratio units + profiles%mmr_cldaer = .true. ! kg/kg for cloud and aerosol (default) + + ! Read in aerosol profiles +! do i = 1, rttovIN%nPoints +! profiles(i)%aerosols(naertyp,nlayers) = ! Aerosols in different modes (see User Guide pg 80) +! +! end do + endif + + ! JKS - nothing to check here, this will never trigger. + call rttov_error('error in aerosol profile initialization' , lalloc = .true.) + + ! JKS To-do: set up scattering profiles (MW only) (rttov_profile_cloud) + + end subroutine cosp_rttov_construct_profiles_mi ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 6. rttov_setup_emissivity_reflectance - Specify surface emissivity and reflectance @@ -676,6 +1003,50 @@ subroutine cosp_rttov_call_direct() end subroutine cosp_rttov_call_direct + + subroutine cosp_rttov_call_direct_mi(inst_nthreads,inst_opts,inst_coefs) + + integer(KIND=jpim),intent(in) :: & + inst_nthreads + type(rttov_options),intent(in) :: & + inst_opts + type(rttov_coefs),intent(in) :: & + inst_coefs + + if (inst_nthreads <= 1) then + print*,'Calling rttov_direct' + call rttov_direct( & + errorstatus, &! out error flag + chanprof, &! in channel and profile index structure + inst_opts, &! in options structure + profiles, &! in profile array + inst_coefs, &! in coefficients structure + transmission, &! inout computed transmittances + radiance, &! inout computed radiances + calcemis = calcemis, &! in flag for internal emissivity calcs + emissivity = emissivity, &! inout input/output emissivities per channel + calcrefl = calcrefl, &! in flag for internal BRDF calcs + reflectance = reflectance) ! inout input/output BRDFs per channel + else + print*,'Calling rttov_parallel_direct' + call rttov_parallel_direct( & + errorstatus, &! out error flag + chanprof, &! in channel and profile index structure + inst_opts, &! in options structure + profiles, &! in profile array + inst_coefs, &! in coefficients structure + transmission, &! inout computed transmittances + radiance, &! inout computed radiances + calcemis = calcemis, &! in flag for internal emissivity calcs + emissivity = emissivity, &! inout input/output emissivities per channel + calcrefl = calcrefl, &! in flag for internal BRDF calcs + reflectance = reflectance,&! inout input/output BRDFs per channel + nthreads = inst_nthreads) ! in number of threads to use + endif + call rttov_error('rttov_direct error', lalloc = .true.) + + end subroutine cosp_rttov_call_direct_mi + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 7. rttov_call_direct - Call PC-RTTOV forward model (Woohoo!) @@ -718,6 +1089,56 @@ subroutine cosp_pc_rttov_call_direct() end subroutine cosp_pc_rttov_call_direct + subroutine cosp_pc_rttov_call_direct_mi( & + inst_nthreads,inst_opts, & + inst_coefs, & + inst_nchannels_rec, & + inst_channels_rec) + + integer(KIND=jpim),intent(in) :: & + inst_nthreads + type(rttov_options),intent(in) :: & + inst_opts + type(rttov_coefs),intent(in) :: & + inst_coefs + integer(jpim),intent(in) :: & + inst_nchannels_rec + integer(jpim),dimension(inst_nchannels_rec),intent(in) :: & + inst_channels_rec + + if (inst_nthreads <= 1) then + print*,'Calling rttov_direct (PC-RTTOV)' + call rttov_direct( & + errorstatus, &! out error flag + chanprof, &! in channel and profile index structure + inst_opts, &! in options structure + profiles, &! in profile array + inst_coefs, &! in coefficients structure + transmission, &! inout computed transmittances + radiance, &! inout computed radiances + calcemis = calcemis, &! in flag for internal emissivity calcs + emissivity = emissivity, &! inout input/output emissivities per channel + pccomp = pccomp, &! inout computed PC scores + channels_rec = inst_channels_rec) ! in reconstructed channel list + else + print*,'Calling rttov_parallel_direct (PC-RTTOV)' + call rttov_parallel_direct( & + errorstatus, &! out error flag + chanprof, &! in channel and profile index structure + inst_opts, &! in options structure + profiles, &! in profile array + inst_coefs, &! in coefficients structure + transmission, &! inout computed transmittances + radiance, &! inout computed radiances + calcemis = calcemis, &! in flag for internal emissivity calcs + emissivity = emissivity, &! inout input/output emissivities per channel + pccomp = pccomp, &! inout computed PC scores + channels_rec = inst_channels_rec,&! in reconstructed channel list + nthreads = inst_nthreads) ! in number of threads to use + endif + call rttov_error('rttov_direct error (PC-RTTOV)', lalloc = .true.) + + end subroutine cosp_pc_rttov_call_direct_mi ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 8. Save output data @@ -773,6 +1194,67 @@ subroutine cosp_rttov_save_output(rttovIN, & end subroutine cosp_rttov_save_output + + subroutine cosp_rttov_save_output_mi(rttovIN,inst_nchan_out, & ! Inputs + Lrttov_bt,Lrttov_rad,Lrttov_refl, & + Lrttov_cld,Lrttov_aer, & + bt_total,bt_clear, & + rad_total,rad_clear,rad_cloudy, & + refl_total,refl_clear) + type(rttov_in),intent(in) :: & + rttovIN + integer,intent(in) :: & + inst_nchan_out + logical,intent(in) :: & + Lrttov_bt, & + Lrttov_rad, & + Lrttov_refl, & + Lrttov_cld, & + Lrttov_aer + + real(wp),dimension(rttovIN%nPoints,inst_nchan_out),intent(inout) :: & ! Can I do this? I guess so! + bt_total, & + bt_clear, & + rad_total, & + rad_clear, & + rad_cloudy, & + refl_total, & + refl_clear + + ! Documentation for RTTOV radiance structure in RTTOV User Guide pg 166 + + ! Only save output if appropriate + if (Lrttov_bt) then + bt_total(1:rttovIN%nPoints, 1:inst_nchan_out) = & + transpose(reshape(radiance%bt(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) + endif + if (Lrttov_bt .and. (Lrttov_cld .or. Lrttov_aer)) then + bt_clear(1:rttovIN%nPoints, 1:inst_nchan_out) = & + transpose(reshape(radiance%bt_clear(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) + endif + + if (Lrttov_rad) then + rad_total(1:rttovIN%nPoints, 1:inst_nchan_out) = & + transpose(reshape(radiance%total(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) + endif + if (Lrttov_rad .and. (Lrttov_cld .or. Lrttov_aer)) then + rad_clear(1:rttovIN%nPoints, 1:inst_nchan_out) = & + transpose(reshape(radiance%clear(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) + rad_cloudy(1:rttovIN%nPoints, 1:inst_nchan_out) = & + transpose(reshape(radiance%cloudy(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) + endif + + if (Lrttov_refl) then + refl_total(1:rttovIN%nPoints, 1:inst_nchan_out) = & + transpose(reshape(radiance%refl(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) + endif + if (Lrttov_refl .and. (Lrttov_cld .or. Lrttov_aer)) then + bt_clear(1:rttovIN%nPoints, 1:inst_nchan_out) = & + transpose(reshape(radiance%refl_clear(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) + endif + + end subroutine cosp_rttov_save_output_mi + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 8. Save output data (PC-RTTOV) @@ -818,7 +1300,55 @@ subroutine cosp_pc_rttov_save_output(rttovIN, & endif end subroutine cosp_pc_rttov_save_output - + + +! subroutine cosp_pc_rttov_save_output_mi(rttovIN, & + subroutine cosp_pc_rttov_save_output_mi(nPoints, & + inst_nchannels_rec, & + Lrttov_bt, & + Lrttov_rad, & + bt_total, & + rad_total) + +! type(rttov_in),intent(in) :: & +! rttovIN + integer,intent(in) :: & + nPoints, & + inst_nchannels_rec + logical,intent(in) :: & + Lrttov_bt, & + Lrttov_rad +! real(wp),dimension(rttovIN%nPoints,inst_nchannels_rec),intent(inout) :: & ! Can I do this? I guess so! + real(wp),dimension(nPoints,inst_nchannels_rec),intent(inout) :: & ! Can I do this? I guess so! + bt_total, & + rad_total + +! print*,'shape(bt_total): ',shape(bt_total) +! print*,'shape(rad_total): ',shape(rad_total) +! print*,'rttovIN%nPoints: ',rttovIN%nPoints +! print*,'rttovIN%nChannels: ',rttovIN%nChannels +! print*,'nchanprof: ',nchanprof ! This is the number of predictors so not the reconstructed channel dimension +! print*,'size(pccomp%bt_pccomp): ',size(pccomp%bt_pccomp) +! print*,'size(pccomp%total_pccomp): ',size(pccomp%total_pccomp) +! print*,'nchannels_rec * rttovIN%nPoints: ',nchannels_rec * rttovIN%nPoints + + ! JKS why not just pass in rttovIN%nPoints and use nchannels_rec here? TO-DO? + ! Documentation for RTTOV radiance structure in RTTOV User Guide pg 166 + + ! Only save output if appropriate + if (Lrttov_bt) then +! bt_total(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & + bt_total(1:nPoints, 1:inst_nchannels_rec) = & + transpose(reshape(pccomp%bt_pccomp(1:(inst_nchannels_rec * nPoints)), (/ inst_nchannels_rec, nPoints/) )) + endif + + if (Lrttov_rad) then +! rad_total(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & + rad_total(1:nPoints, 1:inst_nchannels_rec) = & + transpose(reshape(pccomp%total_pccomp(1:(inst_nchannels_rec * nPoints)), (/ inst_nchannels_rec, nPoints/) )) + endif + + end subroutine cosp_pc_rttov_save_output_mi ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 9. Deallocate all RTTOV arrays and structures @@ -858,6 +1388,41 @@ subroutine cosp_rttov_deallocate_profiles(rttovIN) end subroutine cosp_rttov_deallocate_profiles + subroutine cosp_rttov_deallocate_profiles_mi(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs) + + type(rttov_in),intent(in) :: & + rttovIN + integer(kind=jpim),intent(in) :: & + inst_nChannels_rec + type(rttov_options),intent(in) :: & + inst_opts + type(rttov_coefs),intent(in) :: & + inst_coefs + + ! Does this variable need to be global? I don't think so. + nchanprof = inst_nChannels_rec * rttovIN%nPoints ! RTTOV (non-PC) needs nchan_out? JKS potential bug + + ! Deallocate structures for rttov_direct + call rttov_alloc_direct( & + errorstatus, & + 0_jpim, & ! 0 => deallocate + rttovIN%nPoints, & + nchanprof, & ! JKS + rttovIN%nLevels, & + chanprof, & ! JKS + inst_opts, & + profiles, & + inst_coefs, & + transmission, & + radiance, & + calcemis=calcemis, & + emissivity=emissivity, & + calcrefl=calcrefl, & + reflectance=reflectance) + call rttov_error('deallocation error for rttov_direct structures', lalloc = .true.) + + end subroutine cosp_rttov_deallocate_profiles_mi + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 9. Deallocate all RTTOV arrays and structures (PC-RTTOV) ! ------------------------------------------------------ @@ -897,6 +1462,50 @@ subroutine cosp_pc_rttov_deallocate_profiles(rttovIN) end subroutine cosp_pc_rttov_deallocate_profiles + subroutine cosp_pc_rttov_deallocate_profiles_mi(rttovIN, & + inst_nChannels_rec, & + inst_opts, & + inst_coefs) + + + type(rttov_in),intent(in) :: & + rttovIN + integer(kind=jpim),intent(in) :: & + inst_nChannels_rec + type(rttov_options),intent(in) :: & + inst_opts + type(rttov_coefs),intent(in) :: & + inst_coefs + + if (ASSOCIATED(predictindex)) deallocate (predictindex, stat=alloc_status(10)) + call rttov_error('mem dellocation error for "predictindex"', lalloc = .true.) + + if (ASSOCIATED(channels_rec)) deallocate (channels_rec, stat=alloc_status(11)) + call rttov_error('mem dellocation error for "channels_rec"', lalloc = .true.) + + ! Deallocate structures for rttov_direct + call rttov_alloc_direct( & + errorstatus, & + 0_jpim, & ! 0 => deallocate + rttovIN%nPoints, & + nchanprof, & + rttovIN%nLevels, & + chanprof, & + inst_opts, & + profiles, & + inst_coefs, & + transmission, & + radiance, & + calcemis=calcemis, & + emissivity=emissivity, & + npcscores=inst_opts%rt_ir%pc%npcscores * rttovIN%nPoints, & + nchannels_rec=inst_nChannels_rec * rttovIN%nPoints, & + pccomp=pccomp) + call rttov_error('deallocation error for rttov_direct structures (PC-RTTOV)', lalloc = .true.) + + end subroutine cosp_pc_rttov_deallocate_profiles_mi + + subroutine cosp_rttov_deallocate_coefs() call rttov_dealloc_coefs(errorstatus, coef_rttov) @@ -905,6 +1514,18 @@ subroutine cosp_rttov_deallocate_coefs() endif end subroutine cosp_rttov_deallocate_coefs + + subroutine cosp_rttov_deallocate_coefs_mi(inst_coefs) + + type(rttov_coefs),intent(inout) :: & + inst_coefs + + call rttov_dealloc_coefs(errorstatus, inst_coefs) + if (errorstatus /= errorstatus_success) then + write(*,*) 'coefs deallocation error' + endif + + end subroutine cosp_rttov_deallocate_coefs_mi !########################## From b147c580ee9c7fe82e1b1b8fc0477301b91f64f9 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 23 May 2023 17:14:21 -0600 Subject: [PATCH 056/159] Removed old coding writing RTTOV output to netcdf --- driver/src/cosp2_io.f90 | 201 ++------------------------------------ driver/src/cosp2_test.F90 | 44 +-------- 2 files changed, 7 insertions(+), 238 deletions(-) diff --git a/driver/src/cosp2_io.f90 b/driver/src/cosp2_io.f90 index 4aa6779b86..5038456498 100644 --- a/driver/src/cosp2_io.f90 +++ b/driver/src/cosp2_io.f90 @@ -17,8 +17,8 @@ module mod_cosp_io !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE write_cosp2_output !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, Ninst_rttov, lev, lon, lat, cospOUT, outFileName) - integer,intent(in) :: Npoints, Ncolumns, Nlevels, Nchannels, Ninst_rttov + subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Ninst_rttov, lev, lon, lat, cospOUT, outFileName) + integer,intent(in) :: Npoints, Ncolumns, Nlevels, Ninst_rttov real(wp),dimension(Npoints),intent(in) :: lon,lat real(wp),dimension(Nlevels),intent(in) :: lev type(cosp_outputs),intent(in) :: cospOUT @@ -84,14 +84,11 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, Ninst_rttov 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)) - status = nf90_def_dim(fileID,"RTTOV_CHAN",Nchannels,dimID(19)) - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) ! Define instrument channel indices for multiple RTTOV instruments if (associated(cospOUT%rttov_outputs)) then do i=1,Ninst_rttov write (i_str,fmt) i ! converting integer to string i_str using a 'internal file' - print*,'"RTTOV_CHAN_INST"//trim(i_str): ',"RTTOV_CHAN_INST"//trim(i_str) status = nf90_def_dim(fileID,"RTTOV_CHAN_INST"//trim(i_str),cospOUT % rttov_outputs(i) % nchan_out,dimID(20+i)) ! Start at 100 for RTTOV output channel dimensions if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) end do @@ -210,14 +207,6 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, Ninst_rttov status = nf90_put_att(fileID,varID(83),"units", "1") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - ! RTTOV Channel Indices (rttov_Ichannel) - status = nf90_def_var(fileID,"RTTOV_CHAN", nf90_float, (/dimID(19)/),varID(157)) - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(157),"long_name","rttov channel indices") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(157),"units", "1") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - ! CALIPSO simulator output if (associated(cospOUT%calipso_betaperp_tot)) then status = nf90_def_var(fileID,"atb532_perp",nf90_float, (/dimID(1),dimID(2),dimID(3)/),varID(9)) @@ -1446,128 +1435,14 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, Ninst_rttov ! --------------------------------------------------------------------------------------- ! RTTOV - JKS ! --------------------------------------------------------------------------------------- - - ! Brightness Temperature - if (associated(cospOUT%rttov_Ichannel)) then - status = nf90_def_var(fileID,"rttov_ichannel",nf90_float, (/dimID(19)/),varID(157)) -! status = nf90_def_var(fileID,"rttov_ichannel",nf90_float, (/dimID(1),dimID(19)/),varID(157)) - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(156),"long_name","RTTOV Channel Indices") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(156),"units", "1") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(156),"standard_name", " ") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - endif - if (associated(cospOUT%rttov_bt_total)) then - status = nf90_def_var(fileID,"rttov_bt_total",nf90_float, (/dimID(1),dimID(19)/),varID(148)) - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(148),"long_name","RTTOV All-sky Brightness Temperature") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(148),"units", "Degrees Kelvin") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(148),"standard_name", "bleh") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - endif - if (associated(cospOUT%rttov_bt_clear)) then - status = nf90_def_var(fileID,"rttov_bt_clear",nf90_float, (/dimID(1),dimID(19)/),varID(149)) - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(149),"long_name","RTTOV Clear-sky Brightness Temperature") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(149),"units", "Degrees Kelvin") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(149),"standard_name", "bleh") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - endif - if (associated(cospOUT%rttov_rad_total)) then - status = nf90_def_var(fileID,"rttov_rad_total",nf90_float, (/dimID(1),dimID(19)/),varID(150)) - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(150),"long_name","RTTOV All-sky Radiance") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(150),"units", "mW/cm-1/sr/m2") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(150),"standard_name", "bleh") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - endif - if (associated(cospOUT%rttov_rad_clear)) then - status = nf90_def_var(fileID,"rttov_rad_clear",nf90_float, (/dimID(1),dimID(19)/),varID(151)) - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(151),"long_name","RTTOV Clear-sky Radiance") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(151),"units", "mW/cm-1/sr/m2") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(151),"standard_name", "bleh") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - endif - if (associated(cospOUT%rttov_rad_cloudy)) then - status = nf90_def_var(fileID,"rttov_rad_cloudy",nf90_float, (/dimID(1),dimID(19)/),varID(152)) - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(152),"long_name","RTTOV Cloudy-sky Radiance") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(152),"units", "mW/cm-1/sr/m2") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(152),"standard_name", "bleh") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - endif - if (associated(cospOUT%rttov_refl_total)) then - status = nf90_def_var(fileID,"rttov_refl_total",nf90_float, (/dimID(1),dimID(19)/),varID(153)) - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(153),"long_name","RTTOV All-sky Reflectance") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(153),"units", "unitless") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(153),"standard_name", "bleh") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - endif - if (associated(cospOUT%rttov_refl_clear)) then - status = nf90_def_var(fileID,"rttov_refl_clear",nf90_float, (/dimID(1),dimID(19)/),varID(154)) - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(154),"long_name","RTTOV Clear-sky Reflectance") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(154),"units", "unitless") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(154),"standard_name", "bleh") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - endif - if (associated(cospOUT%rttov_bt_total_pc)) then - status = nf90_def_var(fileID,"rttov_bt_total_pc",nf90_float, (/dimID(1),dimID(19)/),varID(155)) - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(155),"long_name","PC-RTTOV All-sky Brightness Temperature") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(155),"units", "Degrees Kelvin") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(155),"standard_name", "bleh") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - endif - if (associated(cospOUT%rttov_rad_total_pc)) then - status = nf90_def_var(fileID,"rttov_rad_total_pc",nf90_float, (/dimID(1),dimID(19)/),varID(156)) - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(156),"long_name","PC-RTTOV All-sky Radiance") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(156),"units", "mW/cm-1/sr/m2") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(156),"standard_name", "bleh") - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - endif - + ! Define instrument channel indices for multiple RTTOV instruments ii = 165 ! RTTOV variable indices start at 165 if (associated(cospOUT%rttov_outputs)) then do i=1,Ninst_rttov - write (i_str,fmt) i ! converting integer to string i_str using a 'internal file' -! print*,'"RTTOV_CHAN_INST"//trim(i_str): ',"RTTOV_CHAN_INST"//trim(i_str) -! status = nf90_def_var(fileID,"RTTOV_CHAN_INST"//trim(i_str), nf90_float, (/dimID(100+i)/),varID(200+i)) ! Start at 200 for RTTOV output dimensions -! if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) -! status = nf90_put_att(fileID,varID(200+i),"long_name","rttov channel indices for instrument "//trim(i_str)) -! if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) -! status = nf90_put_att(fileID,varID(200+i),"units", "1") -! if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - + write (i_str,fmt) i ! converting integer to string i_str using a 'internal file' if (associated(cospOUT%rttov_outputs(i)%channel_indices)) then ii = ii + 1 - print*,'channel_indices' - print*,'ii: ',ii -! status = nf90_def_var(fileID,"rttov_ichannel_inst"//trim(i_str),nf90_float, (/dimID(1),dimID(20+i)/),varID(ii)) status = nf90_def_var(fileID,"rttov_ichannel_inst"//trim(i_str),nf90_float, (/dimID(20+i)/),varID(ii)) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) status = nf90_put_att(fileID,varID(ii),"long_name","RTTOV Channel Indices") @@ -1579,8 +1454,6 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, Ninst_rttov endif if (associated(cospOUT%rttov_outputs(i)%bt_total)) then ii = ii + 1 - print*,'bt_total' - print*,'ii: ',ii status = nf90_def_var(fileID,"rttov_bt_total_inst"//trim(i_str),nf90_float, (/dimID(1),dimID(20+i)/),varID(ii)) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) status = nf90_put_att(fileID,varID(ii),"long_name","RTTOV All-sky Brightness Temperature") @@ -1592,8 +1465,6 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, Ninst_rttov endif if (associated(cospOUT%rttov_outputs(i)%bt_clear)) then ii = ii + 1 - print*,'bt_clear' - print*,'ii: ',ii status = nf90_def_var(fileID,"rttov_bt_clear_inst"//trim(i_str),nf90_float, (/dimID(1),dimID(20+i)/),varID(ii)) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) status = nf90_put_att(fileID,varID(ii),"long_name","RTTOV Clear-sky Brightness Temperature") @@ -1660,11 +1531,6 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, Ninst_rttov endif if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) then ii = ii + 1 - print*,'bt_total_pc' - print*,'ii: ',ii - -! print*,shape(bt_total) - print*,'20+i: ',20+i status = nf90_def_var(fileID,"rttov_bt_total_pc_inst"//trim(i_str),nf90_float, (/dimID(1),dimID(20+i)/),varID(ii)) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) status = nf90_put_att(fileID,varID(ii),"long_name","PC-RTTOV All-sky Brightness Temperature") @@ -1676,9 +1542,6 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, Ninst_rttov endif if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) then ii = ii + 1 - print*,'rad_total_pc' - print*,'ii: ',ii - print*,'20+i: ',20+i status = nf90_def_var(fileID,"rttov_rad_total_pc_inst"//trim(i_str),nf90_float, (/dimID(1),dimID(20+i)/),varID(ii)) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) status = nf90_put_att(fileID,varID(ii),"long_name","PC-RTTOV All-sky Radiance") @@ -1687,9 +1550,7 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, Ninst_rttov if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) status = nf90_put_att(fileID,varID(ii),"standard_name", "bleh") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - print*,'end print check' - endif - + endif end do end if @@ -2173,68 +2034,24 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, Ninst_rttov status = nf90_put_var(fileID,varID(147),CFODD_HISTICODcenters) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) endif - - ! RTTOV outputs - if (associated(cospOUT%rttov_bt_total)) then - status = nf90_put_var(fileID,varID(148),cospOUT%rttov_bt_total) - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - endif - if (associated(cospOUT%rttov_bt_clear)) then - status = nf90_put_var(fileID,varID(149),cospOUT%rttov_bt_clear) - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - endif - if (associated(cospOUT%rttov_rad_total)) then - status = nf90_put_var(fileID,varID(150),cospOUT%rttov_rad_total) - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - endif - if (associated(cospOUT%rttov_rad_clear)) then - status = nf90_put_var(fileID,varID(151),cospOUT%rttov_rad_clear) - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - endif - if (associated(cospOUT%rttov_rad_cloudy)) then - status = nf90_put_var(fileID,varID(152),cospOUT%rttov_rad_cloudy) - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - endif - if (associated(cospOUT%rttov_refl_total)) then - status = nf90_put_var(fileID,varID(153),cospOUT%rttov_refl_total) - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - endif - if (associated(cospOUT%rttov_refl_clear)) then - status = nf90_put_var(fileID,varID(154),cospOUT%rttov_refl_clear) - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - endif - if (associated(cospOUT%rttov_bt_total_pc)) then - status = nf90_put_var(fileID,varID(155),cospOUT%rttov_bt_total_pc) - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - endif - if (associated(cospOUT%rttov_rad_total_pc)) then - status = nf90_put_var(fileID,varID(156),cospOUT%rttov_rad_total_pc) - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - endif - ! Define instrument channel indices for multiple RTTOV instruments + ! Define instrument channel indices for multiple RTTOV instruments ii = 165 ! RTTOV variable indices start at 166 if (associated(cospOUT%rttov_outputs)) then do i=1,Ninst_rttov write (i_str,fmt) i ! converting integer to string i_str using a 'internal file' if (associated(cospOUT%rttov_outputs(i)%channel_indices)) then ii = ii + 1 - print*,'channel_indices' - print*,'ii: ',ii status = nf90_put_var(fileID,varID(ii),cospOUT%rttov_outputs(i)%channel_indices) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) endif if (associated(cospOUT%rttov_outputs(i)%bt_total)) then ii = ii + 1 - print*,'bt_total' - print*,'ii: ',ii status = nf90_put_var(fileID,varID(ii),cospOUT%rttov_outputs(i)%bt_total) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) endif if (associated(cospOUT%rttov_outputs(i)%bt_clear)) then ii = ii + 1 - print*,'bt_clear' - print*,'ii: ',ii status = nf90_put_var(fileID,varID(ii),cospOUT%rttov_outputs(i)%bt_clear) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) endif @@ -2265,17 +2082,11 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Nchannels, Ninst_rttov endif if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) then ii = ii + 1 - print*,'bt_total_pc' -! print*,'shape(cospOUT%rttov_outputs(i)%bt_total_pc): ',shape(cospOUT%rttov_outputs(i)%bt_total_pc) - print*,'ii: ',ii status = nf90_put_var(fileID,varID(ii),cospOUT%rttov_outputs(i)%bt_total_pc) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) endif if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) then ii = ii + 1 - print*,'rad_total_pc' -! print*,'shape(cospOUT%rttov_outputs(i)%rad_total_pc): ',shape(cospOUT%rttov_outputs(i)%rad_total_pc) - print*,'ii: ',ii status = nf90_put_var(fileID,varID(ii),cospOUT%rttov_outputs(i)%rad_total_pc) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) endif diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index e8e10d637e..a774078472 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -297,16 +297,6 @@ program cosp2_test gamma_3 = (/-1., -1., 2.0, 2.0, -1., -1., 2.0, 2.0, 2.0/),& gamma_4 = (/-1., -1., 6.0, 6.0, -1., -1., 6.0, 6.0, 6.0/) -! logical, allocatable, dimension(:) :: & -! Lrttov_inst_bt, & -! Lrttov_inst_rad, & -! Lrttov_inst_refl, & -! Lrttov_inst_cld, & -! Lrttov_inst_aer, & -! Lrttov_inst_pc - -! type(rttov_instrument_config), allocatable :: rttov_instrument_configs ! JKS this won't work. DDTs would have to be in cosp.F90 - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% call cpu_time(driver_time(1)) @@ -350,38 +340,6 @@ program cosp2_test rttov_instrument_namelists(1:3) = (/'instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt'/) print*,'rttov_instrument_namelists: ',rttov_instrument_namelists - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Read in Logical arguments needed to construct outputs from RTTOV instrument namelists. - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -! allocate(Lrttov_inst_bt(rttov_Ninstruments),Lrttov_inst_rad(rttov_Ninstruments), & -! Lrttov_inst_refl(rttov_Ninstruments),Lrttov_inst_cld(rttov_Ninstruments), & -! Lrttov_inst_aer(rttov_Ninstruments),Lrttov_inst_pc(rttov_Ninstruments)) -! allocate(rttov_instrument_Nchannels(rttov_Ninstruments)) - -! do inst_idx=1,rttov_Ninstruments -! namelist/RTTOV_CONFIG/Lrttov_bt,Lrttov_rad,Lrttov_refl,Lrttov_cld,Lrttov_aer, & -! Lrttov_pc - -! open(10,file=rttov_instrument_namelists(inst_idx),status='unknown') -! read(10,nml=RTTOV_CONFIG) ! I needed to break up the namelist because I can't read a subset of values. This is weird. - -! Lrttov_inst_bt(inst_idx) = Lrttov_bt -! Lrttov_inst_rad(inst_idx) = Lrttov_rad -! Lrttov_inst_refl(inst_idx) = Lrttov_refl -! Lrttov_inst_cld(inst_idx) = Lrttov_cld -! Lrttov_inst_aer(inst_idx) = Lrttov_aer -! Lrttov_inst_pc(inst_idx) = Lrttov_pc -! end do - - -! print*,'Lrttov_inst_bt: ',Lrttov_inst_bt -! print*,'Lrttov_inst_rad: ',Lrttov_inst_rad -! print*,'Lrttov_inst_refl: ',Lrttov_inst_refl -! print*,'Lrttov_inst_cld: ',Lrttov_inst_cld -! print*,'Lrttov_inst_aer: ',Lrttov_inst_aer -! print*,'Lrttov_inst_pc: ',Lrttov_inst_pc - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Read in sample input data. !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -666,7 +624,7 @@ program cosp2_test !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Output !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - call write_cosp2_output(Npoints, Ncolumns, Nlevels, rttov_Nchannels, rttov_Ninstruments, zlev(1,Nlevels:1:-1), lon, lat, cospOUT, foutput) + call write_cosp2_output(Npoints, Ncolumns, Nlevels, rttov_Ninstruments, zlev(1,Nlevels:1:-1), lon, lat, cospOUT, foutput) call cpu_time(driver_time(8)) print*,'Time to write to output: ',driver_time(8)-driver_time(7) From 3954373f9f83dff95c3c75713cca8a9555fbe495 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 23 May 2023 17:38:27 -0600 Subject: [PATCH 057/159] Single-instrument RTTOV calls commented out --- src/cosp.F90 | 118 ++++++++++----------- src/simulator/cosp_rttov_interface_v13.F90 | 11 +- 2 files changed, 58 insertions(+), 71 deletions(-) diff --git a/src/cosp.F90 b/src/cosp.F90 index 5e30295a5e..11b692f75d 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -1571,74 +1571,74 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) print*,'Lrttov_column start' ! jks ! RTTOV - if (Lrttov_column) then +! if (Lrttov_column) then ! Allocate memory for the outputs - I won't need all of these in every situation. ! Only allocate clear-sky memory when PC-RTTOV is run. - allocate(rttov_Ichannel(rttovIN%Nchannels)) ! Channel indices - if (Lrttov_pc) then +! allocate(rttov_Ichannel(rttovIN%Nchannels)) ! Channel indices +! if (Lrttov_pc) then ! allocate(rttov_bt_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky brightness temp ! allocate(rttov_rad_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky brightness temp - allocate(rttov_bt_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky brightness temp - allocate(rttov_rad_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky brightness temp - else - allocate(rttov_bt_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky brightness temp - allocate(rttov_bt_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky brightness temp - allocate(rttov_rad_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky brightness temp - allocate(rttov_rad_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky brightness temp - allocate(rttov_rad_cloudy(rttovIN%Npoints,rttovIN%Nchannels)) ! cloudy-sky brightness temp - allocate(rttov_refl_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky Bi-directional reflectance factor - allocate(rttov_refl_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky Bi-directional reflectance factor - endif +! allocate(rttov_bt_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky brightness temp +! allocate(rttov_rad_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky brightness temp +! else +! allocate(rttov_bt_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky brightness temp +! allocate(rttov_bt_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky brightness temp +! allocate(rttov_rad_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky brightness temp +! allocate(rttov_rad_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky brightness temp +! allocate(rttov_rad_cloudy(rttovIN%Npoints,rttovIN%Nchannels)) ! cloudy-sky brightness temp +! allocate(rttov_refl_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky Bi-directional reflectance factor +! allocate(rttov_refl_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky Bi-directional reflectance factor +! endif ! JKS new RTTOV subroutine for v13 called from the RTTOV interface. - call cpu_time(driver_time(3)) +! call cpu_time(driver_time(3)) ! Run simulator - call cosp_rttov_simulate(rttovIN,Lrttov_cleanUp, & ! Inputs - rttov_Ichannel, & ! Channel Indices - rttov_bt_total,rttov_bt_clear, & ! Brightness Temp Outputs - rttov_rad_total,rttov_rad_clear,rttov_rad_cloudy, & ! Radiance Outputs - rttov_refl_total,rttov_refl_clear, & ! Reflectance Outputs - cosp_simulator(nError+1)) - call cpu_time(driver_time(4)) - print*,'Time to run RTTOV: ',driver_time(4)-driver_time(3) +! call cosp_rttov_simulate(rttovIN,Lrttov_cleanUp, & ! Inputs +! rttov_Ichannel, & ! Channel Indices +! rttov_bt_total,rttov_bt_clear, & ! Brightness Temp Outputs +! rttov_rad_total,rttov_rad_clear,rttov_rad_cloudy, & ! Radiance Outputs +! rttov_refl_total,rttov_refl_clear, & ! Reflectance Outputs +! cosp_simulator(nError+1)) +! call cpu_time(driver_time(4)) +! print*,'Time to run RTTOV: ',driver_time(4)-driver_time(3) ! Write to cospOUT - if (associated(cospOUT%rttov_Ichannel)) & - cospOUT%rttov_Ichannel(:) = rttov_Ichannel - if (Lrttov_pc) then - if (associated(cospOUT%rttov_bt_total_pc)) & - cospOUT%rttov_bt_total_pc(ij:ik,:) = rttov_bt_total - if (associated(cospOUT%rttov_rad_total_pc)) & - cospOUT%rttov_rad_total_pc(ij:ik,:) = rttov_rad_total - else - if (associated(cospOUT%rttov_bt_total)) & - cospOUT%rttov_bt_total(ij:ik,:) = rttov_bt_total - if (associated(cospOUT%rttov_bt_clear)) & - cospOUT%rttov_bt_clear(ij:ik,:) = rttov_bt_clear - if (associated(cospOUT%rttov_rad_total)) & - cospOUT%rttov_rad_total(ij:ik,:) = rttov_rad_total - if (associated(cospOUT%rttov_rad_clear)) & - cospOUT%rttov_rad_clear(ij:ik,:) = rttov_rad_clear - if (associated(cospOUT%rttov_rad_cloudy)) & - cospOUT%rttov_rad_cloudy(ij:ik,:) = rttov_rad_cloudy - if (associated(cospOUT%rttov_refl_total)) & - cospOUT%rttov_refl_total(ij:ik,:) = rttov_refl_total - if (associated(cospOUT%rttov_refl_clear)) & - cospOUT%rttov_refl_clear(ij:ik,:) = rttov_refl_clear - endif +! if (associated(cospOUT%rttov_Ichannel)) & +! cospOUT%rttov_Ichannel(:) = rttov_Ichannel +! if (Lrttov_pc) then +! if (associated(cospOUT%rttov_bt_total_pc)) & +! cospOUT%rttov_bt_total_pc(ij:ik,:) = rttov_bt_total +! if (associated(cospOUT%rttov_rad_total_pc)) & +! cospOUT%rttov_rad_total_pc(ij:ik,:) = rttov_rad_total +! else +! if (associated(cospOUT%rttov_bt_total)) & +! cospOUT%rttov_bt_total(ij:ik,:) = rttov_bt_total +! if (associated(cospOUT%rttov_bt_clear)) & +! cospOUT%rttov_bt_clear(ij:ik,:) = rttov_bt_clear +! if (associated(cospOUT%rttov_rad_total)) & +! cospOUT%rttov_rad_total(ij:ik,:) = rttov_rad_total +! if (associated(cospOUT%rttov_rad_clear)) & +! cospOUT%rttov_rad_clear(ij:ik,:) = rttov_rad_clear +! if (associated(cospOUT%rttov_rad_cloudy)) & +! cospOUT%rttov_rad_cloudy(ij:ik,:) = rttov_rad_cloudy +! if (associated(cospOUT%rttov_refl_total)) & +! cospOUT%rttov_refl_total(ij:ik,:) = rttov_refl_total +! if (associated(cospOUT%rttov_refl_clear)) & +! cospOUT%rttov_refl_clear(ij:ik,:) = rttov_refl_clear +! endif ! Free up memory from output (if necessary) - if (allocated(rttov_Ichannel)) deallocate(rttov_Ichannel) - if (allocated(rttov_bt_total)) deallocate(rttov_bt_total) - if (allocated(rttov_bt_clear)) deallocate(rttov_bt_clear) - if (allocated(rttov_rad_total)) deallocate(rttov_rad_total) - if (allocated(rttov_rad_clear)) deallocate(rttov_rad_clear) - if (allocated(rttov_rad_cloudy)) deallocate(rttov_rad_cloudy) - if (allocated(rttov_refl_total)) deallocate(rttov_refl_total) - if (allocated(rttov_refl_clear)) deallocate(rttov_refl_clear) +! if (allocated(rttov_Ichannel)) deallocate(rttov_Ichannel) +! if (allocated(rttov_bt_total)) deallocate(rttov_bt_total) +! if (allocated(rttov_bt_clear)) deallocate(rttov_bt_clear) +! if (allocated(rttov_rad_total)) deallocate(rttov_rad_total) +! if (allocated(rttov_rad_clear)) deallocate(rttov_rad_clear) +! if (allocated(rttov_rad_cloudy)) deallocate(rttov_rad_cloudy) +! if (allocated(rttov_refl_total)) deallocate(rttov_refl_total) +! if (allocated(rttov_refl_clear)) deallocate(rttov_refl_clear) - endif - print*,'Lrttov_column successful' ! jks +! endif +! print*,'Lrttov_column successful' ! jks print*,'Lrttov_column multi-inst. start' @@ -1684,20 +1684,16 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) print*,'4.' ! Run simulator call cosp_rttov_simulate_mi(rttovIN,cospIN%cfg_rttov(i),Lrttov_cleanUp, & ! Inputs - rttov_Ichannel, & ! Channel Indices rttov_bt_total,rttov_bt_clear, & ! Brightness Temp Outputs rttov_rad_total,rttov_rad_clear,rttov_rad_cloudy, & ! Radiance Outputs rttov_refl_total,rttov_refl_clear, & ! Reflectance Outputs cosp_simulator(nError+1)) -! call cosp_rttov_simulate(rttovIN,Lrttov_cleanUp, & ! Inputs -! cosp_inst_OUTS(i), & ! RTTOV output fields DDT -! cosp_simulator(nError+1)) call cpu_time(driver_time(4)) print*,'Time to run RTTOV: ',driver_time(4)-driver_time(3) ! Write to cospOUT if (associated(cospOUT % rttov_outputs(i) % channel_indices)) & - cospOUT % rttov_outputs(i) % channel_indices(:) = rttov_Ichannel + cospOUT % rttov_outputs(i) % channel_indices(:) = cospIN % cfg_rttov(i) % iChannel if (cospIN % cfg_rttov(i) % Lrttov_pc) then if (associated(cospOUT % rttov_outputs(i) % bt_total_pc)) & cospOUT % rttov_outputs(i) % bt_total_pc(ij:ik,:) = rttov_bt_total diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 72151ad2d6..b1bf019ac5 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -886,7 +886,6 @@ END SUBROUTINE COSP_RTTOV_SIMULATE ! SUBROUTINE cosp_rttov_simulate - Call subroutines in mod_cosp_rttov to run RTTOV !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SUBROUTINE COSP_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, & ! Inputs - iChannel_ret, & ! Channel index outputs bt_total,bt_clear, & ! Brightness Temp Outputs rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs refl_total,refl_clear, & ! Reflectance Outputs @@ -898,8 +897,6 @@ SUBROUTINE COSP_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, rttovConfig logical,intent(in) :: & lCleanup ! Flag to determine whether to deallocate RTTOV types - integer(kind=jpim),intent(out),dimension(rttovIN%nChannels) :: & ! Channels indices to return for output - iChannel_ret real(wp),intent(inout),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! bt_total, & ! All-sky bt_clear, & ! Clear-sky @@ -918,9 +915,7 @@ SUBROUTINE COSP_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, bt_total,rad_total, & error) -! print*,'SIZE(iChannel_ret): ',SIZE(iChannel_ret) -! print*,'SIZE(iChannel_out): ',SIZE(iChannel_out) - iChannel_ret = iChannel_out ! JKS need to fix this + print*,'end of COSP_PC_RTTOV_SIMULATE_MI' else print*,'Running COSP_REG_RTTOV_SIMULATE in multi-inst. set-up' call COSP_REG_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, & @@ -928,10 +923,6 @@ SUBROUTINE COSP_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, rad_total,rad_clear,rad_cloudy, & refl_total,refl_clear, & error) - -! print*,'SIZE(iChannel_ret): ',SIZE(iChannel_ret) -! print*,'SIZE(iChannel): ',SIZE(iChannel) - iChannel_ret = iChannel ! JKS need to fix this, better define these variables endif From c4104b6cd7a3474b995ca6c57d8394c07a5a0b1f Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 23 May 2023 17:54:46 -0600 Subject: [PATCH 058/159] Old single-instrument routines removed from cosp_rttov_interface_v13 and cosp_rttov_v13 --- src/cosp.F90 | 12 +- src/simulator/cosp_rttov_interface_v13.F90 | 196 +------ src/simulator/rttov/cosp_rttov_v13.F90 | 576 +-------------------- 3 files changed, 5 insertions(+), 779 deletions(-) diff --git a/src/cosp.F90 b/src/cosp.F90 index 11b692f75d..7dbe1f4d7f 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -54,7 +54,6 @@ MODULE MOD_COSP USE MOD_COSP_RTTOV_INTERFACE, ONLY: & cosp_rttov_init, & COSP_RTTOV_INI2, & - cosp_rttov_simulate, & cosp_rttov_simulate_mi, & rttov_cfg, & rttov_output @@ -71,7 +70,7 @@ MODULE MOD_COSP USE MOD_LIDAR_SIMULATOR, ONLY: lidar_subcolumn, lidar_column USE MOD_MODIS_SIM, ONLY: modis_subcolumn, modis_column USE MOD_PARASOL, ONLY: parasol_subcolumn, parasol_column - USE MOD_COSP_RTTOV, ONLY: rttov_IN, cosp_rttov_construct_profiles + USE MOD_COSP_RTTOV, ONLY: rttov_IN USE MOD_COSP_STATS, ONLY: COSP_LIDAR_ONLY_CLOUD,COSP_CHANGE_VERTICAL_GRID, & COSP_DIAG_WARMRAIN @@ -1646,14 +1645,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! RTTOV multi-instrument if (Lrttov_column) then print*,'0.' - ! 0. Load the column inputs into the . These are constant across instruments. -! call cosp_rttov_construct_profiles(rttovIN) ! Profile information is stored at the simulator level -! For now, the "profiles" object is complicated and different for each instrument/setting (depends on clouds, trace gases, PC-RTTOV, etc) - - ! 1. Allocate output for each requested instrument - ! 2. Run RTTOV for each instrument, passing the config files along. - ! 3. Write to COSPout if output is requested - ! 4. Free up memory from output + do i=1,cospIN%Ninst_rttov print*,i print*,'1' diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index b1bf019ac5..1db9ff7e43 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -831,56 +831,7 @@ subroutine rttov_error(msg, lalloc) end subroutine rttov_error END SUBROUTINE COSP_RTTOV_INIT - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE cosp_rttov_simulate - Call subroutines in mod_cosp_rttov to run RTTOV - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, & ! Inputs - iChannel_ret, & ! Channel index outputs - bt_total,bt_clear, & ! Brightness Temp Outputs - rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs - refl_total,refl_clear, & ! Reflectance Outputs - error) - - type(rttov_in),intent(in) :: & - rttovIN - logical,intent(in) :: & - lCleanup ! Flag to determine whether to deallocate RTTOV types - integer(kind=jpim),intent(out),dimension(rttovIN%nChannels) :: & ! Channels indices to return for output - iChannel_ret - real(wp),intent(inout),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! - bt_total, & ! All-sky - bt_clear, & ! Clear-sky - rad_total, & ! All-sky - rad_clear, & ! Clear-sky - rad_cloudy, & ! Cloudy-sky - refl_total, & ! All-sky - refl_clear ! Clear-sky - character(len=128) :: & - error ! Error messages (only populated if error encountered) - - ! Check options to determine if the principal component approach should be run - if (opts % rt_ir % pc % addpc) then - call COSP_PC_RTTOV_SIMULATE(rttovIN,lCleanup, & - bt_total,rad_total, & - error) -! print*,'SIZE(iChannel_ret): ',SIZE(iChannel_ret) -! print*,'SIZE(iChannel_out): ',SIZE(iChannel_out) - iChannel_ret = iChannel_out - else - call COSP_REG_RTTOV_SIMULATE(rttovIN,lCleanup, & - bt_total,bt_clear, & - rad_total,rad_clear,rad_cloudy, & - refl_total,refl_clear, & - error) -! print*,'SIZE(iChannel_ret): ',SIZE(iChannel_ret) -! print*,'SIZE(iChannel): ',SIZE(iChannel) - iChannel_ret = iChannel - - endif - - END SUBROUTINE COSP_RTTOV_SIMULATE - + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_simulate - Call subroutines in mod_cosp_rttov to run RTTOV @@ -931,82 +882,6 @@ END SUBROUTINE COSP_RTTOV_SIMULATE_MI !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_simulate - Call regular subroutines in mod_cosp_rttov to run RTTOV !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,lCleanup, & ! Inputs - bt_total,bt_clear, & ! Brightness Temp Outputs - rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs - refl_total,refl_clear, & ! Reflectance Outputs - error) - - use mod_cosp_rttov, only: & - cosp_rttov_allocate, & - cosp_rttov_construct_profiles, & - cosp_rttov_setup_emissivity_reflectance, & - cosp_rttov_call_direct, & - cosp_rttov_save_output, & - cosp_rttov_deallocate_profiles, & - cosp_rttov_deallocate_coefs - - type(rttov_in),intent(in) :: & - rttovIN - logical,intent(in) :: & - lCleanup ! Flag to determine whether to deallocate RTTOV types - real(wp),intent(inout),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! - bt_total, & ! All-sky - bt_clear, & ! Clear-sky - rad_total, & ! All-sky - rad_clear, & ! Clear-sky - rad_cloudy, & ! Cloudy-sky - refl_total, & ! All-sky - refl_clear ! Clear-sky - character(len=128) :: & - error ! Error messages (only populated if error encountered) - - real(wp),dimension(10) :: driver_time - - ! Run each step for running RTTOV from mod_cosp_rttov (and time them) -! print*,'cosp_rttov_allocate begin' ! jks - call cpu_time(driver_time(1)) - call cosp_rttov_allocate(rttovIN) -! print*,'cosp_rttov_allocate successful' ! jks - call cpu_time(driver_time(2)) - call cosp_rttov_construct_profiles(rttovIN) -! print*,'cosp_rttov_construct_profiles successful' ! jks - call cpu_time(driver_time(3)) - call cosp_rttov_setup_emissivity_reflectance() -! print*,'cosp_rttov_setup_emissivity_reflectance successful' ! jks - call cpu_time(driver_time(4)) - call cosp_rttov_call_direct() -! print*,'cosp_rttov_call_direct successful' ! jks - call cpu_time(driver_time(5)) - - call cosp_rttov_save_output(rttovIN, & - bt_total,bt_clear, & - rad_total,rad_clear,rad_cloudy, & - refl_total,refl_clear) -! print*,'cosp_rttov_save_and_deallocate_profiles successful' ! jks - call cpu_time(driver_time(6)) - call cosp_rttov_deallocate_profiles(rttovIN) - call cpu_time(driver_time(7)) - - print*,'Time to run "cosp_rttov_allocate": ', driver_time(2)-driver_time(1) - print*,'Time to run "cosp_rttov_construct_profiles": ', driver_time(3)-driver_time(2) - print*,'Time to run "cosp_rttov_setup_emissivity_reflectance": ',driver_time(4)-driver_time(3) - print*,'Time to run "cosp_rttov_call_direct": ', driver_time(5)-driver_time(4) - print*,'Time to run "cosp_rttov_save_output": ', driver_time(6)-driver_time(5) - print*,'Time to run "cosp_rttov_deallocate_profiles": ', driver_time(7)-driver_time(6) - - ! Deallocate the coefficient files if directed - if (lCleanup) then - call cpu_time(driver_time(8)) - call cosp_rttov_deallocate_coefs() - call cpu_time(driver_time(9)) - print*,'Time to run "cosp_rttov_deallocate_coefs": ',driver_time(9)-driver_time(8) - endif - -! print*,'Total RTTOV run time: ',driver_time(8)-driver_time(1) - - END SUBROUTINE COSP_REG_RTTOV_SIMULATE - SUBROUTINE COSP_REG_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, & ! Inputs bt_total,bt_clear, & ! Brightness Temp Outputs rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs @@ -1109,75 +984,6 @@ END SUBROUTINE COSP_REG_RTTOV_SIMULATE_MI !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_pc_rttov_simulate - Call subroutines in mod_cosp_rttov to run RTTOV !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,lCleanup, & ! Inputs - bt_total,rad_total, & ! Outputs - error) - - use mod_cosp_rttov, only: & - cosp_pc_rttov_allocate, & - cosp_rttov_construct_profiles, & - cosp_pc_rttov_setup_emissivity, & - cosp_pc_rttov_call_direct, & - cosp_pc_rttov_save_output, & - cosp_pc_rttov_deallocate_profiles, & - cosp_rttov_deallocate_coefs - - type(rttov_in),intent(in) :: & - rttovIN - logical,intent(in) :: & - lCleanup ! Flag to determine whether to deallocate RTTOV types - real(wp),intent(inout),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! - bt_total, & ! All-sky - rad_total ! All-sky - character(len=128) :: & - error ! Error messages (only populated if error encountered) - - real(wp),dimension(10) :: driver_time - - ! Run each step for running RTTOV from mod_cosp_rttov (and time them) -! print*,'cosp_rttov_allocate begin' ! jks - call cpu_time(driver_time(1)) - call cosp_pc_rttov_allocate(rttovIN) - print*,'cosp_pc_rttov_allocate successful' ! jks - call cpu_time(driver_time(2)) - call cosp_rttov_construct_profiles(rttovIN) - print*,'cosp_rttov_construct_profiles successful' ! jks - call cpu_time(driver_time(3)) - call cosp_pc_rttov_setup_emissivity() - print*,'cosp_pc_rttov_setup_emissivity successful' ! jks - call cpu_time(driver_time(4)) - call cosp_pc_rttov_call_direct() - print*,'cosp_pc_rttov_call_direct successful' ! jks - call cpu_time(driver_time(5)) - - call cosp_pc_rttov_save_output(rttovIN, & - bt_total,rad_total) - - print*,'cosp_pc_rttov_save_output successful' ! jks - call cpu_time(driver_time(6)) - call cosp_pc_rttov_deallocate_profiles(rttovIN) - call cpu_time(driver_time(7)) - - print*,'Time to run "cosp_pc_rttov_allocate": ', driver_time(2)-driver_time(1) - print*,'Time to run "cosp_rttov_construct_profiles": ', driver_time(3)-driver_time(2) - print*,'Time to run "cosp_pc_rttov_setup_emissivity": ', driver_time(4)-driver_time(3) - print*,'Time to run "cosp_pc_rttov_call_direct": ', driver_time(5)-driver_time(4) - print*,'Time to run "cosp_pc_rttov_save_output": ', driver_time(6)-driver_time(5) - print*,'Time to run "cosp_pc_rttov_deallocate_profiles": ', driver_time(7)-driver_time(6) - - ! Deallocate the coefficient files if directed - if (lCleanup) then - call cpu_time(driver_time(8)) - call cosp_rttov_deallocate_coefs() - call cpu_time(driver_time(9)) - print*,'Time to run "cosp_rttov_deallocate_coefs": ',driver_time(9)-driver_time(8) - endif - -! print*,'Total RTTOV run time: ',driver_time(8)-driver_time(1) - - END SUBROUTINE COSP_PC_RTTOV_SIMULATE - - SUBROUTINE COSP_PC_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, & ! Inputs bt_total,rad_total, & ! Outputs error) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 991dfe5b39..47f2934a55 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -83,7 +83,6 @@ module mod_cosp_rttov !#include "rttov_dealloc_coef.interface" !#include "rttov_dealloc_coef_pccomp.interface" - ! Includes when directly inputting cloud optical parameters #include "rttov_init_opt_param.interface" #include "rttov_bpr_init.interface" @@ -105,8 +104,6 @@ module mod_cosp_rttov rttov_direct_nthreads = 1_jpim integer(kind=jpim),allocatable :: & iChannel(:), & ! RTTOV channel indices -! emisChannel(:), & ! RTTOV channel emissivity -! reflChannel(:), & ! RTTOV channel reflectivity iChannel_out(:) ! Passing out the channel indices real(kind=jplm),allocatable :: & emisChannel(:), & ! RTTOV channel emissivity @@ -170,7 +167,6 @@ module mod_cosp_rttov ! JKS additional variables used in PC-RTTOV INTEGER(KIND=jpim), POINTER :: predictindex(:) INTEGER(KIND=jpim) :: nchannels_comp, npcscores, npred_pc ! npred to go here -! INTEGER(KIND=jpim) :: lo, hi ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! TYPE rttov_in @@ -192,8 +188,6 @@ module mod_cosp_rttov ! real(wp),dimension(:),pointer :: & ! surfem ! Surface emissivities for the channels ! refl, & ! Surface reflectances for the channels -! integer(kind=jpim),dimension(:),pointer :: & -! channels ! real(wp),dimension(:),pointer :: & h_surf, & ! Surface height u_surf, & ! U component of surface wind @@ -249,62 +243,6 @@ end subroutine rttov_error ! 3. Allocate RTTOV input and output structures ! 4. Build the list of profile/channel indices in chanprof ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_rttov_allocate(rttovIN & - ) - - type(rttov_in),intent(in) :: & - rttovIN - - ! Loop variables - integer(kind=jpim) :: j, jch, nch - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! 3. Allocate RTTOV input and output structures - ! ------------------------------------------------------ - ! Largely from RTTOV documentation. - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - ! Determine the total number of radiances to simulate (nchanprof). -! nchanprof = rttovIN%nChannels * rttovIN%nPoints - nchanprof = nChannels_rec * rttovIN%nPoints ! RTTOV (non-PC) needs nchan_out? JKS potential bug -! print*,'nchanprof: ',nchanprof - - ! Allocate structures for rttov_direct - call rttov_alloc_direct( & - errorstatus, & - 1_jpim, & ! 1 => allocate - rttovIN%nPoints, & - nchanprof, & - rttovIN%nLevels, & - chanprof, & - opts, & - profiles, & - coef_rttov, & - transmission, & - radiance, & - calcemis=calcemis, & - emissivity=emissivity, & - calcrefl=calcrefl, & - reflectance=reflectance, & - init=.TRUE._jplm) - call rttov_error('allocation error for rttov_direct structures' , lalloc = .false.) - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! 4. Build the list of profile/channel indices in chanprof - ! ------------------------------------------------------ - ! Largely from RTTOV documentation. - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - nch = 0_jpim - do j = 1, rttovIN%nPoints - do jch = 1, rttovIN%nChannels ! nChannels - nch = nch + 1_jpim - chanprof(nch)%prof = j - chanprof(nch)%chan = iChannel(jch) ! Example code used channel_list - end do - end do - - end subroutine cosp_rttov_allocate subroutine cosp_rttov_allocate_mi(rttovIN,inst_nChannels_rec,inst_opts, & inst_coefs,inst_iChannel) @@ -323,9 +261,6 @@ subroutine cosp_rttov_allocate_mi(rttovIN,inst_nChannels_rec,inst_opts, & ! Loop variables integer(kind=jpim) :: j, jch, nch - ! Other local variables -! integer(kind=jpim) :: inst_nchanprof ! JKS to-do. Then add inst_chanprof as an intent(out) variable - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 3. Allocate RTTOV input and output structures ! ------------------------------------------------------ @@ -333,7 +268,6 @@ subroutine cosp_rttov_allocate_mi(rttovIN,inst_nChannels_rec,inst_opts, & ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Determine the total number of radiances to simulate (nchanprof). -! nchanprof = rttovIN%nChannels * rttovIN%nPoints nchanprof = inst_nChannels_rec * rttovIN%nPoints ! RTTOV (non-PC) needs nchan_out? JKS potential bug ! print*,'nchanprof: ',nchanprof @@ -345,10 +279,8 @@ subroutine cosp_rttov_allocate_mi(rttovIN,inst_nChannels_rec,inst_opts, & nchanprof, & rttovIN%nLevels, & chanprof, & -! rttovConfig%opts, & inst_opts, & profiles, & -! rttovConfig%coefs, & inst_coefs, & transmission, & radiance, & @@ -383,92 +315,6 @@ end subroutine cosp_rttov_allocate_mi ! 3. Allocate RTTOV input and output structures ! 4. Build the list of profile/channel indices in chanprof ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_pc_rttov_allocate(rttovIN & - ) - - type(rttov_in),intent(in) :: & - rttovIN - - ! Loop variables - integer(kind=jpim) :: j, jch, nch - integer(kind=jpim) :: lo, hi - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! 3. Allocate RTTOV input and output structures - ! ------------------------------------------------------ - ! Largely from RTTOV documentation. - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - nullify(predictindex) - call rttov_get_pc_predictindex(errorstatus, opts, predictindex, file_pccoef=PC_coef_filepath) - call rttov_error('rttov_get_pc_predictindex fatal error' , lalloc = .false.) - - npred_pc = SIZE(predictindex) - nchanprof = npred_pc * rttovIN%nPoints ! Size of chanprof array is total number of predictors over all profiles - - ! Determine the number of reconstructed radiances per profile (nchannels_rec) - if (opts % rt_ir % pc % addradrec) then - if (nchannels_rec < 0) then - ! If the number of channels is negative, don't reconstruct radiances at all - print*,'radrec 1.' - opts % rt_ir % pc % addradrec = .FALSE. - else if (nchannels_rec == 0) then - ! If the number of channels is set to 0 then reconstruct all instrument channels - print*,'radrec 2.' - nchannels_rec = coef_rttov % coef % fmv_chn - allocate(channels_rec(nchannels_rec)) - channels_rec(:) = (/ (j, j = 1, nchannels_rec) /) - iChannel_out = (/ (j, j = 1, nchannels_rec) /) - else - ! Otherwise read the channel list from the file - print*,'radrec 3.' - print*,'nchannels_rec: ',nchannels_rec - allocate(channels_rec(nchannels_rec)) - channels_rec(:) = iChannel ! channels_rec is just the index of the desired channels - iChannel_out = iChannel - endif - endif - - ! Ensure we don't have unassociated pointers below when addradrec is FALSE - if (nchannels_rec <= 0) allocate(channels_rec(0)) - - ! Allocate structures for rttov_direct - CALL rttov_alloc_direct( & - errorstatus, & - 1_jpim, & ! 1 => allocate - rttovIN%nPoints, & - nchanprof, & - rttovIN%nLevels, & - chanprof, & - opts, & - profiles, & - coef_rttov, & - transmission, & - radiance, & - calcemis=calcemis, & - emissivity=emissivity, & - npcscores=npcscores * rttovIN%nPoints, & - nchannels_rec=nchannels_rec * rttovIN%nPoints, & - pccomp=pccomp, & - init=.TRUE._jplm) - call rttov_error('allocation error for rttov_direct structures (PC-RTTOV)' , lalloc = .true.) - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! 4. Build the list of profile/channel indices in chanprof - ! ------------------------------------------------------ - ! Largely from RTTOV documentation. - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - ! Populate chanprof using the channel list obtained above in predictindex(:) - do j = 1, rttovIN%nPoints - lo = (j - 1) * npred_pc + 1 - hi = lo + npred_pc - 1 - chanprof(lo:hi)%prof = j - chanprof(lo:hi)%chan = predictindex(:) - end do - - end subroutine cosp_pc_rttov_allocate - subroutine cosp_pc_rttov_allocate_mi(rttovIN,inst_PC_coef_filepath, & !inst_npcscores, & inst_coefs,inst_opts, & @@ -479,8 +325,6 @@ subroutine cosp_pc_rttov_allocate_mi(rttovIN,inst_PC_coef_filepath, & !inst_npcs rttovIN character(256),intent(in) :: & inst_PC_coef_filepath -! integer(kind=jpim),intent(in) :: & -! inst_npcscores type(rttov_coefs),intent(in) :: & inst_coefs type(rttov_options),intent(inout) :: & @@ -491,10 +335,6 @@ subroutine cosp_pc_rttov_allocate_mi(rttovIN,inst_PC_coef_filepath, & !inst_npcs inst_iChannel_in ! Channel indices the user initially requests. integer(kind=jpim),intent(inout),allocatable :: & inst_iChannel_out(:) ! Passing out the channel indices -! integer(KIND=jpim),intent(out),POINTER :: & -! inst_predictindex(:) - - ! Loop variables integer(kind=jpim) :: j, jch, nch @@ -527,16 +367,12 @@ subroutine cosp_pc_rttov_allocate_mi(rttovIN,inst_PC_coef_filepath, & !inst_npcs ! If the number of channels is set to 0 then reconstruct all instrument channels print*,'radrec 2.' inst_nchannels_rec = inst_coefs % coef % fmv_chn -! allocate(channels_rec(inst_nchannels_rec)) -! channels_rec(:) = (/ (j, j = 1, inst_nchannels_rec) /) allocate(inst_iChannel_out(inst_nchannels_rec)) inst_iChannel_out = (/ (j, j = 1, inst_nchannels_rec) /) else ! Otherwise read the channel list from the file print*,'radrec 3.' print*,'inst_nchannels_rec: ',inst_nchannels_rec -! allocate(channels_rec(nchannels_rec)) -! channels_rec(:) = iChannel ! channels_rec is just the index of the desired channels allocate(inst_iChannel_out(inst_nchannels_rec)) inst_iChannel_out = inst_iChannel_in endif @@ -588,171 +424,6 @@ end subroutine cosp_pc_rttov_allocate_mi ! ------------------------------------------------------ ! Largely from cosp_rttov_v11.F90 file. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_rttov_construct_profiles(rttovIN & - ) - - type(rttov_in),intent(in) :: & ! What is the best way to do this? Should rttovIN be a module-wide DDT? Yes. - rttovIN - - ! Loop variables - integer(kind=jpim) :: i, j ! Use i to iterate over profile, j for levels. - - ! Store profile data from rttovIN in profile type. - ! See RTTOV user guide pg 163 for description of "profiles" type - - ! "The rttov_profile structure is composed of the atmospheric part - ! and two other structures for 2 meter air and skin surface. - ! If you are not able to provide ozone, CO2, etc profiles the flags - ! ozone_data, co2_data and so on in the options structure should be - ! set to false." - - profiles(:)%gas_units = 1 ! kg/kg over moist air (default) - - do i = 1, rttovIN%nPoints - - ! Initialize trace gas concentrations from user input - ! These gases are not in COSP input files but might be in the futre - profiles(i)%co2(:) = co2 - profiles(i)%n2o(:) = n2o - profiles(i)%co(:) = co - profiles(i)%ch4(:) = ch4 - profiles(i)%so2 = so2 - -! profiles(i)%co2(:) = rttovIN%co2 -! profiles(i)%n2o(:) = rttovIN%n2o -! profiles(i)%co(:) = rttovIN%co -! profiles(i)%ch4(:) = rttovIN%ch4 - - ! Initialize column pressure, temperature, and humidity - profiles(i)%p(:) = rttovIN%p(i, :) * 1e-2 ! convert Pa to hPa - profiles(i)%t(:) = rttovIN%t(i, :) - profiles(i)%q(:) = rttovIN%q(i, :) - - ! q coefficient limit is 0.1e-10 - where(profiles(i)%q(:) < 0.1e-10) - profiles(i)%q(:) = 0.11e-10 - end where - - ! Gas profiles - profiles(i)%o3 = rttovIN%o3(i, :) - - ! 2m parameters - profiles(i)%s2m%p = rttovIN%p_surf(i) * 1e-2 ! convert Pa to hPa - profiles(i)%s2m%t = rttovIN%t2m(i) ! JKS or rttovIN%t_skin - profiles(i)%s2m%q = rttovIN%q2m(i) ! Should be the same as gas units (kg/kg) - profiles(i)%s2m%u = rttovIN%u_surf(i) - profiles(i)%s2m%v = rttovIN%v_surf(i) - profiles(i)%s2m%wfetc = 10000. ! only used by sea surface solar BRDF model. - - ! skin variables for emissivity calculations - profiles(i)%skin%t = rttovIN%t_skin(i) - - ! fastem coefficients - for mw calculations - profiles(i)%skin%fastem(1) = 3.0 - profiles(i)%skin%fastem(2) = 5.0 - profiles(i)%skin%fastem(3) = 15.0 - profiles(i)%skin%fastem(4) = 0.1 - profiles(i)%skin%fastem(5) = 0.3 - - ! Viewing angles - profiles(i)%zenangle = zenang ! pass in from cosp - profiles(i)%azangle = 0. ! hard-coded in rttov9 int JKS-? - - profiles(i)%latitude = rttovIN%latitude(i) - profiles(i)%longitude = rttovIN%longitude(i) - profiles(i)%elevation = rttovIN%h_surf(i) * 1e-3 ! Convert m to km - - ! Solar angles. JKS - get this from COSP/CESM? Doesn't seem to be passed in. - profiles(i)%sunzenangle = 0. ! hard-coded in rttov9 int - profiles(i)%sunazangle = 0. ! hard-coded in rttov9 int - - ! surface type - ! land-sea mask (lsmask) indicates proportion of land in grid - if (rttovIN%lsmask(i) < 0.5) then - profiles(i)%skin%surftype = surftype_sea - else - profiles(i)%skin%surftype = surftype_land - endif - ! sea-ice fraction - if (rttovIN%seaice(i) >= 0.5) then - profiles(i)%skin%surftype = surftype_seaice - endif - - ! dar: hard-coded to 1 (=ocean water) in rttov 9 int - profiles(i)%skin%watertype = 1 - !profiles(i) %idg = 0. ! Depreciated? - !profiles(i) %ish = 0. ! Depreciated? - end do - - ! JKS - nothing to check here, this will never trigger. - call rttov_error('error in profile initialization' , lalloc = .false.) - -! print*,'profiles(1)%p(:): ',profiles(1)%p(:) -! print*,'profiles(1)%q(:): ',profiles(1)%q(:) -! print*,'profiles(1)%t(:): ',profiles(1)%t(:) - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Only add the cloud fields if simulating cloud. - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - if (do_rttov_cld) then - - ! Set cloud mass mixing ratio units - profiles(:)%mmr_cldaer = .true. ! kg/kg for cloud and aerosol (default) - - profiles(:)%clw_scheme = 2 ! Deff scheme avoids cloud types - ! profiles%clwde_scheme = 1. ! Not implemented? - profiles(:)%ice_scheme = 1 !1:Baum 2:Baran(2014) 3:Baran(2018) - profiles(:)%icede_param = 2 ! 2:Wyser(recommended). Only used if ice effective diameter not input - - do i = 1, rttovIN%nPoints - ! Cloud scheme stuff - profiles(i)%cfrac(:) = rttovIN%tca(i,:) ! Cloud fraction for each layer - profiles(i)%cloud(1,:) = rttovIN%cldLiq(i,:) ! Cloud water mixing ratio (all in the first type for Deff) - profiles(i)%cloud(6,:) = rttovIN%cldIce(i,:) ! Cloud ice mixing ratio (1 type). See pg 74. - - ! Example UKMO input has effective radii for multiple cloud types, making identification of a single - ! liquid droplet or ice crystal effective diameter difficult. - ! I opt to let RTTOV decide on the effective radius values, but more complex implementation - ! could do a more thorough conversion between UKMO output and RTTOV input - ! profiles(i)%clwde = ! Cloud water effective diameter - ! profiles(i)%icede = ! Cloud ice effective diameter - - ! Old code for simple cloud schemes only - ! profiles(i)%cfraction = 0. - ! profiles(i)%ctp = 500. - - ! Other options not implemented -! profiles(i)%clw = ! Cloud liquid water (kg/kg) – MW only, - end do - endif - - ! JKS - nothing to check here, this will never trigger. - call rttov_error('error in cloud profile initialization' , lalloc = .false.) - - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Only add the aerosol fields if simulating aerosol. - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - if (do_rttov_aer) then - - ! Set aerosol mass mixing ratio units - profiles%mmr_cldaer = .true. ! kg/kg for cloud and aerosol (default) - - ! Read in aerosol profiles -! do i = 1, rttovIN%nPoints -! profiles(i)%aerosols(naertyp,nlayers) = ! Aerosols in different modes (see User Guide pg 80) -! -! end do - endif - - ! JKS - nothing to check here, this will never trigger. - call rttov_error('error in aerosol profile initialization' , lalloc = .true.) - - ! JKS To-do: set up scattering profiles (MW only) (rttov_profile_cloud) - - end subroutine cosp_rttov_construct_profiles subroutine cosp_rttov_construct_profiles_mi(rttovIN,Lrttov_cld,Lrttov_aer & ) @@ -966,43 +637,7 @@ end subroutine cosp_pc_rttov_setup_emissivity ! 7. rttov_call_direct - Call RTTOV forward model (Woohoo!) ! ------------------------------------------------------ ! From RTTOV example files. - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_rttov_call_direct() - - if (rttov_direct_nthreads <= 1) then - print*,'Calling rttov_direct' - call rttov_direct( & - errorstatus, &! out error flag - chanprof, &! in channel and profile index structure - opts, &! in options structure - profiles, &! in profile array - coef_rttov, &! in coefficients structure - transmission, &! inout computed transmittances - radiance, &! inout computed radiances - calcemis = calcemis, &! in flag for internal emissivity calcs - emissivity = emissivity, &! inout input/output emissivities per channel - calcrefl = calcrefl, &! in flag for internal BRDF calcs - reflectance = reflectance) ! inout input/output BRDFs per channel - else - print*,'Calling rttov_parallel_direct' - call rttov_parallel_direct( & - errorstatus, &! out error flag - chanprof, &! in channel and profile index structure - opts, &! in options structure - profiles, &! in profile array - coef_rttov, &! in coefficients structure - transmission, &! inout computed transmittances - radiance, &! inout computed radiances - calcemis = calcemis, &! in flag for internal emissivity calcs - emissivity = emissivity, &! inout input/output emissivities per channel - calcrefl = calcrefl, &! in flag for internal BRDF calcs - reflectance = reflectance,&! inout input/output BRDFs per channel - nthreads = rttov_direct_nthreads) ! in number of threads to use - endif - call rttov_error('rttov_direct error', lalloc = .true.) - - end subroutine cosp_rttov_call_direct - + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine cosp_rttov_call_direct_mi(inst_nthreads,inst_opts,inst_coefs) @@ -1053,42 +688,6 @@ end subroutine cosp_rttov_call_direct_mi ! ------------------------------------------------------ ! From RTTOV example files. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_pc_rttov_call_direct() - - if (rttov_direct_nthreads <= 1) then - print*,'Calling rttov_direct (PC-RTTOV)' - call rttov_direct( & - errorstatus, &! out error flag - chanprof, &! in channel and profile index structure - opts, &! in options structure - profiles, &! in profile array - coef_rttov, &! in coefficients structure - transmission, &! inout computed transmittances - radiance, &! inout computed radiances - calcemis = calcemis, &! in flag for internal emissivity calcs - emissivity = emissivity, &! inout input/output emissivities per channel - pccomp = pccomp, &! inout computed PC scores - channels_rec = channels_rec) ! in reconstructed channel list - else - print*,'Calling rttov_parallel_direct (PC-RTTOV)' - call rttov_parallel_direct( & - errorstatus, &! out error flag - chanprof, &! in channel and profile index structure - opts, &! in options structure - profiles, &! in profile array - coef_rttov, &! in coefficients structure - transmission, &! inout computed transmittances - radiance, &! inout computed radiances - calcemis = calcemis, &! in flag for internal emissivity calcs - emissivity = emissivity, &! inout input/output emissivities per channel - pccomp = pccomp, &! inout computed PC scores - channels_rec = channels_rec,&! in reconstructed channel list - nthreads = rttov_direct_nthreads) ! in number of threads to use - endif - call rttov_error('rttov_direct error (PC-RTTOV)', lalloc = .true.) - - end subroutine cosp_pc_rttov_call_direct - subroutine cosp_pc_rttov_call_direct_mi( & inst_nthreads,inst_opts, & inst_coefs, & @@ -1144,56 +743,7 @@ end subroutine cosp_pc_rttov_call_direct_mi ! 8. Save output data ! ------------------------------------------------------ ! JKS - Need to allow options for Tb and radiance for clear- and cloudy-skies - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_rttov_save_output(rttovIN, & - bt_total,bt_clear, & - rad_total,rad_clear,rad_cloudy, & - refl_total,refl_clear) - type(rttov_in),intent(in) :: & - rttovIN - real(wp),dimension(rttovIN%nPoints,rttovIN%nChannels),intent(inout) :: & ! Can I do this? I guess so! - bt_total, & - bt_clear, & - rad_total, & - rad_clear, & - rad_cloudy, & - refl_total, & - refl_clear - - ! Documentation for RTTOV radiance structure in RTTOV User Guide pg 166 - - ! Only save output if appropriate - if (do_rttov_bt) then - bt_total(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & - transpose(reshape(radiance%bt(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) - endif - if (do_rttov_bt .and. (do_rttov_cld .or. do_rttov_aer)) then - bt_clear(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & - transpose(reshape(radiance%bt_clear(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) - endif - - if (do_rttov_rad) then - rad_total(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & - transpose(reshape(radiance%total(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) - endif - if (do_rttov_rad .and. (do_rttov_cld .or. do_rttov_aer)) then - rad_clear(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & - transpose(reshape(radiance%clear(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) - rad_cloudy(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & - transpose(reshape(radiance%cloudy(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) - endif - - if (do_rttov_refl) then - refl_total(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & - transpose(reshape(radiance%refl(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) - endif - if (do_rttov_refl .and. (do_rttov_cld .or. do_rttov_aer)) then - bt_clear(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & - transpose(reshape(radiance%refl_clear(1:nchanprof), (/ rttovIN%nChannels, rttovIN%nPoints/) )) - endif - - end subroutine cosp_rttov_save_output - + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine cosp_rttov_save_output_mi(rttovIN,inst_nchan_out, & ! Inputs Lrttov_bt,Lrttov_rad,Lrttov_refl, & @@ -1262,47 +812,7 @@ end subroutine cosp_rttov_save_output_mi ! JKS - Need to allow options for Tb and radiance for clear- and cloudy-skies ! PC-RTTOV only does clear-sky IR calculations (can handle aerosols, but I'll ignore that for now. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -! subroutine cosp_pc_rttov_save_output(rttovIN, & -! bt_total,bt_clear, & -! rad_total,rad_clear,rad_cloudy, & -! refl_total,refl_clear) - - subroutine cosp_pc_rttov_save_output(rttovIN, & - bt_total,rad_total) - - type(rttov_in),intent(in) :: & - rttovIN - real(wp),dimension(rttovIN%nPoints,rttovIN%nChannels),intent(inout) :: & ! Can I do this? I guess so! - bt_total, & - rad_total - -! print*,'shape(bt_total): ',shape(bt_total) -! print*,'shape(rad_total): ',shape(rad_total) -! print*,'rttovIN%nPoints: ',rttovIN%nPoints -! print*,'rttovIN%nChannels: ',rttovIN%nChannels -! print*,'nchanprof: ',nchanprof ! This is the number of predictors so not the reconstructed channel dimension -! print*,'size(pccomp%bt_pccomp): ',size(pccomp%bt_pccomp) -! print*,'size(pccomp%total_pccomp): ',size(pccomp%total_pccomp) -! print*,'nchannels_rec * rttovIN%nPoints: ',nchannels_rec * rttovIN%nPoints - ! JKS why not just pass in rttovIN%nPoints and use nchannels_rec here? TO-DO? - ! Documentation for RTTOV radiance structure in RTTOV User Guide pg 166 - - ! Only save output if appropriate - if (do_rttov_bt) then - bt_total(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & - transpose(reshape(pccomp%bt_pccomp(1:(nchannels_rec * rttovIN%nPoints)), (/ rttovIN%nChannels, rttovIN%nPoints/) )) - endif - - if (do_rttov_rad) then - rad_total(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & - transpose(reshape(pccomp%total_pccomp(1:(nchannels_rec * rttovIN%nPoints)), (/ rttovIN%nChannels, rttovIN%nPoints/) )) - endif - - end subroutine cosp_pc_rttov_save_output - - -! subroutine cosp_pc_rttov_save_output_mi(rttovIN, & subroutine cosp_pc_rttov_save_output_mi(nPoints, & inst_nchannels_rec, & Lrttov_bt, & @@ -1310,15 +820,12 @@ subroutine cosp_pc_rttov_save_output_mi(nPoints, & bt_total, & rad_total) -! type(rttov_in),intent(in) :: & -! rttovIN integer,intent(in) :: & nPoints, & inst_nchannels_rec logical,intent(in) :: & Lrttov_bt, & Lrttov_rad -! real(wp),dimension(rttovIN%nPoints,inst_nchannels_rec),intent(inout) :: & ! Can I do this? I guess so! real(wp),dimension(nPoints,inst_nchannels_rec),intent(inout) :: & ! Can I do this? I guess so! bt_total, & rad_total @@ -1337,13 +844,11 @@ subroutine cosp_pc_rttov_save_output_mi(nPoints, & ! Only save output if appropriate if (Lrttov_bt) then -! bt_total(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & bt_total(1:nPoints, 1:inst_nchannels_rec) = & transpose(reshape(pccomp%bt_pccomp(1:(inst_nchannels_rec * nPoints)), (/ inst_nchannels_rec, nPoints/) )) endif if (Lrttov_rad) then -! rad_total(1:rttovIN%nPoints, 1:rttovIN%nChannels) = & rad_total(1:nPoints, 1:inst_nchannels_rec) = & transpose(reshape(pccomp%total_pccomp(1:(inst_nchannels_rec * nPoints)), (/ inst_nchannels_rec, nPoints/) )) endif @@ -1355,38 +860,6 @@ end subroutine cosp_pc_rttov_save_output_mi ! ------------------------------------------------------ ! From RTTOV example files. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_rttov_deallocate_profiles(rttovIN) - - type(rttov_in),intent(in) :: & - rttovIN - - ! JKS no longer using channel_list, rttovIN%channels instead - !deallocate (channel_list, stat=alloc_status(1)) - !if (alloc_status(1) /= 0) then - ! write(*,*) 'mem dellocation error' - !endif - - ! Deallocate structures for rttov_direct - call rttov_alloc_direct( & - errorstatus, & - 0_jpim, & ! 0 => deallocate - rttovIN%nPoints, & - nchanprof, & - rttovIN%nLevels, & - chanprof, & - opts, & - profiles, & - coef_rttov, & - transmission, & - radiance, & - calcemis=calcemis, & - emissivity=emissivity, & - calcrefl=calcrefl, & - reflectance=reflectance) - call rttov_error('deallocation error for rttov_direct structures', lalloc = .true.) - - end subroutine cosp_rttov_deallocate_profiles - subroutine cosp_rttov_deallocate_profiles_mi(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs) @@ -1428,46 +901,12 @@ end subroutine cosp_rttov_deallocate_profiles_mi ! ------------------------------------------------------ ! From RTTOV example files. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_pc_rttov_deallocate_profiles(rttovIN) - - type(rttov_in),intent(in) :: & - rttovIN - - if (ASSOCIATED(predictindex)) deallocate (predictindex, stat=alloc_status(10)) - call rttov_error('mem dellocation error for "predictindex"', lalloc = .true.) - - if (ASSOCIATED(channels_rec)) deallocate (channels_rec, stat=alloc_status(11)) - call rttov_error('mem dellocation error for "channels_rec"', lalloc = .true.) - - ! Deallocate structures for rttov_direct - call rttov_alloc_direct( & - errorstatus, & - 0_jpim, & ! 0 => deallocate - rttovIN%nPoints, & - nchanprof, & - rttovIN%nLevels, & - chanprof, & - opts, & - profiles, & - coef_rttov, & - transmission, & - radiance, & - calcemis=calcemis, & - emissivity=emissivity, & - npcscores=npcscores * rttovIN%nPoints, & - nchannels_rec=nchannels_rec * rttovIN%nPoints, & - pccomp=pccomp) - call rttov_error('deallocation error for rttov_direct structures (PC-RTTOV)', lalloc = .true.) - - end subroutine cosp_pc_rttov_deallocate_profiles - subroutine cosp_pc_rttov_deallocate_profiles_mi(rttovIN, & inst_nChannels_rec, & inst_opts, & inst_coefs) - type(rttov_in),intent(in) :: & rttovIN integer(kind=jpim),intent(in) :: & @@ -1505,16 +944,6 @@ subroutine cosp_pc_rttov_deallocate_profiles_mi(rttovIN, & end subroutine cosp_pc_rttov_deallocate_profiles_mi - - subroutine cosp_rttov_deallocate_coefs() - - call rttov_dealloc_coefs(errorstatus, coef_rttov) - if (errorstatus /= errorstatus_success) then - write(*,*) 'coefs deallocation error' - endif - - end subroutine cosp_rttov_deallocate_coefs - subroutine cosp_rttov_deallocate_coefs_mi(inst_coefs) type(rttov_coefs),intent(inout) :: & @@ -1527,7 +956,6 @@ subroutine cosp_rttov_deallocate_coefs_mi(inst_coefs) end subroutine cosp_rttov_deallocate_coefs_mi - !########################## ! Module End !########################## From 0f0dd07fdf45fdfc2c39a48db8b6a44fdcc4a77c Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 24 May 2023 10:54:08 -0600 Subject: [PATCH 059/159] single instrument rttov init calls removed --- driver/src/cosp2_test.F90 | 4 +- src/cosp.F90 | 118 +------ src/simulator/cosp_rttov_interface_v13.F90 | 355 +-------------------- src/simulator/rttov/cosp_rttov_v13.F90 | 38 ++- 4 files changed, 55 insertions(+), 460 deletions(-) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index a774078472..b51eb73390 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -448,8 +448,8 @@ program cosp2_test 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, & - rttov_Nchannels, Lrttov_bt, Lrttov_rad, Lrttov_refl, Lrttov_cld, Lrttov_aer, & - Lrttov_cldparam, Lrttov_aerparam,Lrttov_pc,rttov_input_namelist, & +! rttov_Nchannels, Lrttov_bt, Lrttov_rad, Lrttov_refl, Lrttov_cld, Lrttov_aer, & +! Lrttov_cldparam, Lrttov_aerparam,Lrttov_pc,rttov_input_namelist, & rttov_Ninstruments, rttov_instrument_namelists, rttov_configs)!, rttov_instrument_Nchannels) ! Lrttov_run,rttov_Ninstruments,rttov_instrument_namelists, & ! Input logical, input N instr., instr. nls ! rttov_instrument_configs, & ! Output object is an array of N rttov_config_opts ! JKS can this be a pointer? diff --git a/src/cosp.F90 b/src/cosp.F90 index 7dbe1f4d7f..9d62e556b1 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -52,7 +52,6 @@ MODULE MOD_COSP cloudsat_preclvl,grLidar532_histBsct,atlid_histBsct USE MOD_COSP_MODIS_INTERFACE, ONLY: cosp_modis_init, modis_IN USE MOD_COSP_RTTOV_INTERFACE, ONLY: & - cosp_rttov_init, & COSP_RTTOV_INI2, & cosp_rttov_simulate_mi, & rttov_cfg, & @@ -1567,102 +1566,20 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (allocated(isccpLEVMATCH)) deallocate(isccpLEVMATCH) endif - print*,'Lrttov_column start' ! jks - - ! RTTOV -! if (Lrttov_column) then - - ! Allocate memory for the outputs - I won't need all of these in every situation. - ! Only allocate clear-sky memory when PC-RTTOV is run. -! allocate(rttov_Ichannel(rttovIN%Nchannels)) ! Channel indices -! if (Lrttov_pc) then -! allocate(rttov_bt_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky brightness temp -! allocate(rttov_rad_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky brightness temp -! allocate(rttov_bt_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky brightness temp -! allocate(rttov_rad_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky brightness temp -! else -! allocate(rttov_bt_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky brightness temp -! allocate(rttov_bt_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky brightness temp -! allocate(rttov_rad_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky brightness temp -! allocate(rttov_rad_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky brightness temp -! allocate(rttov_rad_cloudy(rttovIN%Npoints,rttovIN%Nchannels)) ! cloudy-sky brightness temp -! allocate(rttov_refl_total(rttovIN%Npoints,rttovIN%Nchannels)) ! all-sky Bi-directional reflectance factor -! allocate(rttov_refl_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky Bi-directional reflectance factor -! endif - ! JKS new RTTOV subroutine for v13 called from the RTTOV interface. -! call cpu_time(driver_time(3)) - ! Run simulator -! call cosp_rttov_simulate(rttovIN,Lrttov_cleanUp, & ! Inputs -! rttov_Ichannel, & ! Channel Indices -! rttov_bt_total,rttov_bt_clear, & ! Brightness Temp Outputs -! rttov_rad_total,rttov_rad_clear,rttov_rad_cloudy, & ! Radiance Outputs -! rttov_refl_total,rttov_refl_clear, & ! Reflectance Outputs -! cosp_simulator(nError+1)) -! call cpu_time(driver_time(4)) -! print*,'Time to run RTTOV: ',driver_time(4)-driver_time(3) - - ! Write to cospOUT -! if (associated(cospOUT%rttov_Ichannel)) & -! cospOUT%rttov_Ichannel(:) = rttov_Ichannel -! if (Lrttov_pc) then -! if (associated(cospOUT%rttov_bt_total_pc)) & -! cospOUT%rttov_bt_total_pc(ij:ik,:) = rttov_bt_total -! if (associated(cospOUT%rttov_rad_total_pc)) & -! cospOUT%rttov_rad_total_pc(ij:ik,:) = rttov_rad_total -! else -! if (associated(cospOUT%rttov_bt_total)) & -! cospOUT%rttov_bt_total(ij:ik,:) = rttov_bt_total -! if (associated(cospOUT%rttov_bt_clear)) & -! cospOUT%rttov_bt_clear(ij:ik,:) = rttov_bt_clear -! if (associated(cospOUT%rttov_rad_total)) & -! cospOUT%rttov_rad_total(ij:ik,:) = rttov_rad_total -! if (associated(cospOUT%rttov_rad_clear)) & -! cospOUT%rttov_rad_clear(ij:ik,:) = rttov_rad_clear -! if (associated(cospOUT%rttov_rad_cloudy)) & -! cospOUT%rttov_rad_cloudy(ij:ik,:) = rttov_rad_cloudy -! if (associated(cospOUT%rttov_refl_total)) & -! cospOUT%rttov_refl_total(ij:ik,:) = rttov_refl_total -! if (associated(cospOUT%rttov_refl_clear)) & -! cospOUT%rttov_refl_clear(ij:ik,:) = rttov_refl_clear -! endif - - ! Free up memory from output (if necessary) -! if (allocated(rttov_Ichannel)) deallocate(rttov_Ichannel) -! if (allocated(rttov_bt_total)) deallocate(rttov_bt_total) -! if (allocated(rttov_bt_clear)) deallocate(rttov_bt_clear) -! if (allocated(rttov_rad_total)) deallocate(rttov_rad_total) -! if (allocated(rttov_rad_clear)) deallocate(rttov_rad_clear) -! if (allocated(rttov_rad_cloudy)) deallocate(rttov_rad_cloudy) -! if (allocated(rttov_refl_total)) deallocate(rttov_refl_total) -! if (allocated(rttov_refl_clear)) deallocate(rttov_refl_clear) - -! endif -! print*,'Lrttov_column successful' ! jks - - - print*,'Lrttov_column multi-inst. start' - ! RTTOV multi-instrument + print*,'Lrttov_column multi-inst. start' if (Lrttov_column) then - print*,'0.' - do i=1,cospIN%Ninst_rttov - print*,i - print*,'1' - ! Allocate memory for the outputs - I won't need all of these in every situation. ! Only allocate clear-sky memory when PC-RTTOV is run. print*,'cospIN % cfg_rttov(i) % nchan_out: ',cospIN % cfg_rttov(i) % nchan_out ! issue here allocate(rttov_Ichannel(cospIN % cfg_rttov(i) % nchan_out)) ! Channel indices - print*,'2' if (cospIN % cfg_rttov(i) % Lrttov_pc) then - print*,'3a' allocate(rttov_bt_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp allocate(rttov_rad_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky radiance ! allocate(rttov_bt_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky brightness temp ! allocate(rttov_rad_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky radiance else - print*,'3b' allocate(rttov_bt_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp allocate(rttov_bt_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! clear-sky brightness temp allocate(rttov_rad_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp @@ -1673,7 +1590,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) endif call cpu_time(driver_time(3)) - print*,'4.' ! Run simulator call cosp_rttov_simulate_mi(rttovIN,cospIN%cfg_rttov(i),Lrttov_cleanUp, & ! Inputs rttov_bt_total,rttov_bt_clear, & ! Brightness Temp Outputs @@ -1944,18 +1860,17 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La cloudsat_radar_freq, cloudsat_k2, cloudsat_use_gas_abs, cloudsat_do_ray, & isccp_top_height, isccp_top_height_direction, surface_radar, rcfg, lusevgrid, & luseCSATvgrid, Nvgrid, Nlevels, cloudsat_micro_scheme, & - NchanIN, Lrttov_bt, Lrttov_rad, Lrttov_refl, & - Lrttov_cld, Lrttov_aer, Lrttov_cldparam, Lrttov_aerparam, Lrttov_pc, & - rttov_input_namelist, & +! NchanIN, Lrttov_bt, Lrttov_rad, Lrttov_refl, & +! Lrttov_cld, Lrttov_aer, Lrttov_cldparam, Lrttov_aerparam, Lrttov_pc, & +! rttov_input_namelist, & rttov_Ninstruments, rttov_instrument_namelists,rttov_configs) !, rttov_instrument_Nchannels) ! INPUTS logical,intent(in) :: Lisccp,Lmodis,Lmisr,Lcloudsat,Lcalipso,LgrLidar532,Latlid,Lparasol,Lrttov - logical,intent(in) :: & - Lrttov_bt, Lrttov_rad, Lrttov_refl, & - Lrttov_cld, Lrttov_aer, Lrttov_cldparam, Lrttov_aerparam, & - Lrttov_pc - ! JKS to-do +! logical,intent(in) :: & +! Lrttov_bt, Lrttov_rad, Lrttov_refl, & +! Lrttov_cld, Lrttov_aer, Lrttov_cldparam, Lrttov_aerparam, & +! Lrttov_pc integer,intent(in) :: & cloudsat_use_gas_abs, & ! cloudsat_do_ray, & ! @@ -1965,9 +1880,8 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La Nvgrid, & ! Number of levels for new L3 grid surface_radar, & ! rttov_Ninstruments -! integer,pointer,intent(inout) :: & - integer,intent(inout) :: & - NchanIN +! integer,intent(inout) :: & +! NchanIN real(wp),intent(in) :: & cloudsat_radar_freq, & ! cloudsat_k2 ! @@ -1979,18 +1893,14 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La cloudsat_micro_scheme ! Microphysical scheme used by CLOUDSAT real(wp),dimension(10) :: driver_time - character(len=256),intent(in) :: rttov_input_namelist +! character(len=256),intent(in) :: rttov_input_namelist type(character(len=256)), dimension(rttov_Ninstruments) :: & rttov_instrument_namelists ! Array of paths to RTTOV instrument namelists ! OUTPUTS type(radar_cfg) :: rcfg -! type(rttov_cfg), :: rttov_configs type(rttov_cfg), dimension(:), allocatable :: rttov_configs -! type(rttov_cfg), dimension(rttov_Ninstruments) :: rttov_configs -! type(rttov_cfg), allocatable :: rttov_configs(:) -! integer,intent(out),dimension(rttov_Ninstruments) :: rttov_instrument_Nchannels ! Local variables integer :: i @@ -2038,17 +1948,11 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La ! I think that I will try to store an object of rttov_init_objects here, ! Could print diagnostic on timing here. -! rttov_instrument_Nchannels(:) = 0 ! initialize at 0 ! JKS clean up if (Lrttov) then call cpu_time(driver_time(1)) call cosp_rttov_ini2(Nlevels,rttov_Ninstruments, & rttov_instrument_namelists, & rttov_configs) - call cosp_rttov_init(NchanIN, Nlevels, & - Lrttov_bt,Lrttov_rad,Lrttov_refl, & - Lrttov_cld,Lrttov_aer, & - Lrttov_cldparam,Lrttov_aerparam, & - Lrttov_pc,rttov_input_namelist) call cpu_time(driver_time(2)) print*,'Time to run cosp_rttov_init: ',driver_time(2)-driver_time(1) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 1db9ff7e43..e7b50ace1a 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -492,346 +492,6 @@ end subroutine rttov_error END SUBROUTINE COSP_RTTOV_INIT_S - - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE cosp_rttov_init - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_INIT(nchan_out,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, & - Lrttov_cld,Lrttov_aer,Lrttov_cldparam,Lrttov_aerparam, & - Lrttov_pc,rttov_input_namelist) - integer,intent(inout) :: & - nchan_out ! JKS make this out only soon - integer,intent(in) :: & - nlevels - logical,intent(in) :: & - Lrttov_bt, & - Lrttov_rad, & - Lrttov_refl, & - Lrttov_cld, & - Lrttov_aer, & - Lrttov_cldparam, & - Lrttov_aerparam, & - Lrttov_pc - - ! JKS testing using a RTTOV input namelist here - ! (default cosp_rttov namelist is set in cosp.F90) - character(len=256),intent(in) :: rttov_input_namelist - - ! Local variables - character(len=256) :: & - rttov_srcDir, & - rttov_coefDir, & - OD_coef_file, & - aer_coef_file, & - cld_coef_file, & - OD_coef_filepath, & - aer_coef_filepath, & - cld_coef_filepath, & - channel_filepath - - real(wp) :: & - SO2_mr, & - N2O_mr, & - CO_mr, & - CH4_mr, & - CO2_mr, & - rttov_ZenAng - - ! Declare RTTOV namelist fields - logical :: SO2_data = .false. - logical :: N2O_data = .false. - logical :: CO_data = .false. - logical :: CO2_data = .false. - logical :: CH4_data = .false. - logical :: ozone_data = .false. - - character(len=256) :: cosp_status - integer :: & - i, & - rttov_nthreads - - integer(kind=jpim) :: ipcbnd, ipcreg - - ! Read RTTOV namelist fields - namelist/RTTOV_INPUT/Lchannel_filepath,rttov_srcDir,rttov_coefDir, & - OD_coef_filepath,aer_coef_filepath,cld_coef_filepath, & - SO2_mr,N2O_mr,CO_mr,CH4_mr,CO2_mr,rttov_ZenAng, & ! Mixing ratios - SO2_data,N2O_data,CO_data,CH4_data,CO2_data,ozone_data, & - rttov_nthreads,nchannels_rec - - ! Only read channel indices and emissivities if prompted - if (Lchannel_filepath) then - namelist/RTTOV_INPUT/channel_filepath - endif - - ! Only read some namelist fields if PC-RTTOV will run - if (Lrttov_pc) then - namelist/RTTOV_INPUT/PC_coef_filepath,ipcbnd,ipcreg,npcscores - endif - - !! JKS - Hardcode in some options that will eventually be moved to the namelist -! ipcbnd = 1 ! This should always be one per the User Guide -! ipcreg = 2 ! 300 predictors (channels). See RTTOV user guide Table 31. -! npcscores = 100 ! 100 principal component scores - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Read in namelists - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - open(10,file=rttov_input_namelist,status='unknown') - read(10,nml=RTTOV_INPUT) - close(10) - - - ! Initialize fields in module memory (cosp_rttovXX.F90) - rttovDir = rttov_srcDir - - ! Set logicals for RTTOV options - do_rttov_bt = Lrttov_bt - do_rttov_rad = Lrttov_rad - do_rttov_refl = Lrttov_refl - do_rttov_cld = Lrttov_cld - do_rttov_aer = Lrttov_aer - do_rttov_pcrttov = Lrttov_pc - rttov_cld_optparam = Lrttov_cldparam - rttov_aer_optparam = Lrttov_aerparam - - so2 = SO2_mr - n2o = N2O_mr - co = CO_mr - co2 = CO2_mr - ch4 = CH4_mr - zenang = rttov_ZenAng - - ! Set degree of parallelization - rttov_direct_nthreads = rttov_nthreads - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! 1. Initialise RTTOV options structure - ! ------------------------------------------------------ - ! See page 157 of RTTOV v13 user guide for documentation - ! Initializing all options to defaults for consistency - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - ! General configuration options - opts%config%do_checkinput = .true. - opts%config%apply_reg_limits = .false. ! True in v11 - opts%config%verbose = .false. ! JKS suppress for now - opts%config%opdep13_gas_clip = .true. - - ! General Radiative Transfer Options - ! Gas profile logicals - opts%rt_all%ozone_data = ozone_data - opts%rt_all%so2_data = so2_data - opts%rt_all%co2_data = co2_data - opts%rt_all%n2o_data = n2o_data - opts%rt_all%co_data = co_data - opts%rt_all%ch4_data = ch4_data - - ! Other general RT options (initializing to defaults for completeness) - opts%rt_all%do_lambertian = .false. - opts%rt_all%switchrad = .false. - opts%rt_all%rad_down_lin_tau = .true. - opts%rt_all%use_t2m_opdep = .true. - opts%rt_all%use_q2m = .true. - opts%rt_all%use_tskin_eff = .false. - opts%rt_all%addrefrac = .true. - opts%rt_all%plane_parallel = .false. - opts%rt_all%transmittances_only = .false. - - ! MW-only radiative transfer options: - ! JKS make this optional? - opts%rt_mw%clw_data = .false. - opts%rt_mw%clw_scheme = 2 ! Default = 2/Rosenkranz - opts%rt_mw%clw_cloud_top = 322 ! Default is 322 hPa - opts%rt_mw%fastem_version = 6 ! Default FASTEM-6 - opts%rt_mw%supply_foam_fraction = .false. - - ! UV/visible/IR-only radiative transfer options - opts%rt_ir%addsolar = .false. - opts%rt_ir%rayleigh_max_wavelength = 2._wp ! 2um - opts%rt_ir%rayleigh_min_pressure = 0._wp ! 0 hPa - opts%rt_ir%rayleigh_single_scatt = .true. - opts%rt_ir%rayleigh_depol = .true. ! Default false, recommended true - opts%rt_ir%do_nlte_correction = .false. - opts%rt_ir%solar_sea_brdf_model = 2 - opts%rt_ir%ir_sea_emis_model = 2 - - ! User options - JKS - opts%rt_ir%addaerosl = do_rttov_aer - opts%rt_ir%addclouds = do_rttov_cld - opts%rt_ir%user_aer_opt_param = rttov_aer_optparam ! User specifies the aerosol scattering optical parameters - opts%rt_ir%user_cld_opt_param = rttov_cld_optparam ! User specifies the cloud scattering optical parameters - - opts%rt_ir%grid_box_avg_cloud = .true. - opts%rt_ir%cldcol_threshold = -1._wp - opts%rt_ir%cloud_overlap = 1 ! Maximum-random overlap - opts%rt_ir%cc_low_cloud_top = 750_wp ! 750 hPa. Only applies when cloud_overlap=2. - opts%rt_ir%ir_scatt_model = 2 - opts%rt_ir%vis_scatt_model = 1 - opts%rt_ir%dom_nstreams = 8 - opts%rt_ir%dom_accuracy = 0._wp ! only applies when addclouds or addaerosl is true and DOM is selected as a scattering solver. - opts%rt_ir%dom_opdep_threshold = 0._wp - opts%rt_ir%dom_rayleigh = .false. - - ! Principal Components-only radiative transfer options: - ! Default off - opts%rt_ir%pc%addpc = .false. - opts%rt_ir%pc%npcscores = -1 - opts%rt_ir%pc%addradrec = .false. - opts%rt_ir%pc%ipcbnd = 1 - opts%rt_ir%pc%ipcreg = 1 ! The index of the required set of PC predictors - - ! Options related to interpolation and the vertical grid: - opts%interpolation%addinterp = .true. - opts%interpolation%interp_mode = 1 -! opts%interpolation%reg_limit_extrap = .true. ! Depreciated - opts%interpolation%lgradp = .false. -! opts%interpolation%spacetop = .true. ! Depreciated - - ! Options related to HTFRTC: - opts%htfrtc_opts%htfrtc = .false. - opts%htfrtc_opts%n_pc_in = -1 - opts%htfrtc_opts%reconstruct = .false. - opts%htfrtc_opts%simple_cloud = .false. - opts%htfrtc_opts%overcast = .false. - - ! Developer options that may be useful: - opts%dev%do_opdep_calc = .true. - - ! If using PC-RTTOV, some settings must be a certain way. This isn't always true though... - if (do_rttov_pcrttov) then - opts % rt_ir % pc % addpc = .true. - opts % rt_ir % pc % ipcbnd = ipcbnd - opts % rt_ir % pc % ipcreg = ipcreg - opts % rt_ir % pc % npcscores = npcscores - - ! In this example we reconstruct radiances if there is an input file - ! containing a channel list -! INQUIRE(file=radrec_filename, exist=exists) ! exists is a logical, but I don't think we need it - opts % rt_ir % pc % addradrec = .true. ! exists, I could add a logical in the namelist to determine this - - opts % interpolation % addinterp = .true. ! Allow interpolation of input profile - opts % interpolation % interp_mode = 1 ! Set interpolation method - opts % rt_all % addrefrac = .true. ! Include refraction in path calc (always for PC) - opts % rt_ir % addclouds = .false. ! Don't include cloud effects (always for PC?) - opts % rt_ir % addaerosl = .false. ! Don't include aerosol effects (not always for PC) - opts % rt_ir % addsolar = .false. ! Do not include solar radiation (always for PC?) - - endif - - ! JKS To-do: include opts_scatt settings (user guide pg 161) - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! 2. Read coefficients (from RTTOV example files) - ! ------------------------------------------------------ - ! Using the GUI to figure out files that work together could be helpful here. - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - ! Construct optical depth and cloud coefficient files - OD_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(OD_coef_filepath) - aer_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(aer_coef_filepath) - cld_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(cld_coef_filepath) - - ! Do I need logicals here to direct how to read the coefficients? - - - if (do_rttov_pcrttov) then ! PC-RTTOV cannot handle cloud, some aerosols - PC_coef_filepath = trim(rttovDir)//trim(rttov_coefDir)//trim(PC_coef_filepath) - - call rttov_read_coefs(errorstatus, coef_rttov, opts, & - file_coef=OD_coef_filepath, & -! file_scaer=aer_coef_filepath, & ! Needs to be PC-RTTOV compatible - file_pccoef=PC_coef_filepath) - else ! Read optical depth and cloud coefficient files together - call rttov_read_coefs(errorstatus, coef_rttov, opts, & - file_coef=OD_coef_filepath, & - file_scaer=aer_coef_filepath, & - file_sccld=cld_coef_filepath) - ! Ensure input number of channels is not higher than number stored in coefficient file - if (nchannels_rec > coef_rttov % coef % fmv_chn) then - nchannels_rec = coef_rttov % coef % fmv_chn - print*,'nchannels_rec cap hit' - endif - endif - - ! We aren't checking an allocation steps so this seems more appropriate. - call rttov_error('fatal error reading coefficients' , lalloc = .false.) - - ! Ensure the options and coefficients are consistent - call rttov_user_options_checkinput(errorstatus, opts, coef_rttov) - - ! We aren't checking an allocation steps so this seems more appropriate. - call rttov_error('error in rttov options' , lalloc = .false.) - - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Figure out how many channels we actually want to reconstruct - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - ! Handle different radiance reconstruction options - if (nchannels_rec < 0) then - print*,'The namelist variable "nchannels_rec" is negative, rttov_direct call will fail. Exiting.' - errorstatus = errorstatus_fatal - call rttov_exit(errorstatus) - ! If the number of channels is negative, don't reconstruct radiances at all - nchan_out = 0 - nchannels_rec = 0 ! Avoid nchanprof set to a negative value - else if (nchannels_rec == 0) then - ! If the number of channels is set to 0 then reconstruct all instrument channels - nchan_out = coef_rttov % coef % fmv_chn - nchannels_rec = coef_rttov % coef % fmv_chn ! Avoid nchanprof set to 0 - else - ! Otherwise read the channel list from the file - nchan_out = nchannels_rec - endif - - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Read in channel indices, emissivities, and reflectivities from .csv if file is passed - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - print*,'nchan_out: ',nchan_out - - if (Lchannel_filepath) then - allocate(iChannel(nchan_out)) - allocate(emisChannel(nchan_out)) - allocate(reflChannel(nchan_out)) - - open(18,file=channel_filepath,access='sequential',form="formatted") - do i = 1, nchan_out - read(18,*) iChannel(i), emisChannel(i), reflChannel(i) - end do - close(18) - else ! If nothing is passed, compute the first "nchan_out" channels. Ignore emissivity and reflectivity for now. - allocate(iChannel(nchan_out)) - iChannel(:) = (/ (i, i = 1, nchan_out) /) - endif - - - ! subsub routines - contains - ! Wrapper function for exiting RTTOV and reporting the error - subroutine rttov_error(msg, lalloc) - character(*) :: msg - logical :: lalloc - - if(lalloc) then - if (any(alloc_status /= 0)) then - write(*,*) msg - errorstatus = 1 - call rttov_exit(errorstatus) - endif - else - if (errorstatus /= errorstatus_success) then - write(*,*) msg - call rttov_exit(errorstatus) - endif - endif - end subroutine rttov_error - - END SUBROUTINE COSP_RTTOV_INIT - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_simulate - Call subroutines in mod_cosp_rttov to run RTTOV @@ -929,7 +589,13 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, call cpu_time(driver_time(2)) call cosp_rttov_construct_profiles_mi(rttovIN, & rttovConfig % opts % rt_ir % addclouds, & - rttovConfig % opts % rt_ir % addaerosl) + rttovConfig % opts % rt_ir % addaerosl, & + rttovConfig % CO2_mr, & + rttovConfig % CH4_mr, & + rttovConfig % CO_mr, & + rttovConfig % N2O_mr, & + rttovConfig % SO2_mr) + print*,'cosp_rttov_construct_profiles_mi successful' ! jks call cpu_time(driver_time(3)) call cosp_rttov_setup_emissivity_reflectance() ! Config agnostic after allocate step. @@ -1025,7 +691,12 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, call cpu_time(driver_time(2)) call cosp_rttov_construct_profiles_mi(rttovIN, & rttovConfig % opts % rt_ir % addclouds, & - rttovConfig % opts % rt_ir % addaerosl) + rttovConfig % opts % rt_ir % addaerosl, & + rttovConfig % CO2_mr, & + rttovConfig % CH4_mr, & + rttovConfig % CO_mr, & + rttovConfig % N2O_mr, & + rttovConfig % SO2_mr) print*,'cosp_rttov_construct_profiles_mi successful' ! jks call cpu_time(driver_time(3)) call cosp_pc_rttov_setup_emissivity() diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 47f2934a55..657f53b425 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -425,14 +425,26 @@ end subroutine cosp_pc_rttov_allocate_mi ! Largely from cosp_rttov_v11.F90 file. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_rttov_construct_profiles_mi(rttovIN,Lrttov_cld,Lrttov_aer & - ) + subroutine cosp_rttov_construct_profiles_mi(rttovIN, & + Lrttov_cld, & + Lrttov_aer, & + inst_co2_mr, & + inst_ch4_mr, & + inst_co_mr, & + inst_n2o_mr, & + inst_so2_mr) type(rttov_in),intent(in) :: & ! What is the best way to do this? Should rttovIN be a module-wide DDT? Yes. rttovIN - logical,intent(in) :: & - Lrttov_cld, & + logical,intent(in) :: & + Lrttov_cld, & Lrttov_aer + real(wp),intent(in) :: & + inst_co2_mr, & + inst_ch4_mr, & + inst_co_mr, & + inst_n2o_mr, & + inst_so2_mr ! Loop variables integer(kind=jpim) :: i, j ! Use i to iterate over profile, j for levels. @@ -452,12 +464,20 @@ subroutine cosp_rttov_construct_profiles_mi(rttovIN,Lrttov_cld,Lrttov_aer & ! Initialize trace gas concentrations from user input ! These gases are not in COSP input files but might be in the futre - profiles(i)%co2(:) = co2 - profiles(i)%n2o(:) = n2o - profiles(i)%co(:) = co - profiles(i)%ch4(:) = ch4 - profiles(i)%so2 = so2 + + profiles(i)%co2(:) = inst_co2_mr + profiles(i)%n2o(:) = inst_n2o_mr + profiles(i)%co(:) = inst_co_mr + profiles(i)%ch4(:) = inst_ch4_mr + profiles(i)%so2 = inst_so2_mr ! syntax slightly different? + +! profiles(i)%co2(:) = co2 +! profiles(i)%n2o(:) = n2o +! profiles(i)%co(:) = co +! profiles(i)%ch4(:) = ch4 +! profiles(i)%so2 = so2 +! For when trace gas columns are ! profiles(i)%co2(:) = rttovIN%co2 ! profiles(i)%n2o(:) = rttovIN%n2o ! profiles(i)%co(:) = rttovIN%co From fbc1d4a986750d857a5a06b3302c276f7c2bd84c Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 24 May 2023 13:52:22 -0600 Subject: [PATCH 060/159] Clean up RTTOV DDTs to remove single instrument fields. --- driver/src/cosp2_io.f90 | 4 - driver/src/cosp2_test.F90 | 115 +---- src/cosp.F90 | 517 +++++++++++---------- src/simulator/cosp_rttov_interface_v13.F90 | 61 ++- src/simulator/rttov/cosp_rttov_v13.F90 | 85 ++-- 5 files changed, 345 insertions(+), 437 deletions(-) diff --git a/driver/src/cosp2_io.f90 b/driver/src/cosp2_io.f90 index 5038456498..e3db6a8b0a 100644 --- a/driver/src/cosp2_io.f90 +++ b/driver/src/cosp2_io.f90 @@ -1591,10 +1591,6 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Ninst_rttov, lev, lon, if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) status = nf90_put_var(fileID,varID(83),loc) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - if (associated(cospOUT%rttov_Ichannel)) then - status = nf90_put_var(fileID,varID(157),cospOUT%rttov_Ichannel) - if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - endif ! CALIPSO simulator output if (associated(cospOUT%calipso_betaperp_tot)) then diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index b51eb73390..9d46b7dc89 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -448,12 +448,7 @@ program cosp2_test 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, & -! rttov_Nchannels, Lrttov_bt, Lrttov_rad, Lrttov_refl, Lrttov_cld, Lrttov_aer, & -! Lrttov_cldparam, Lrttov_aerparam,Lrttov_pc,rttov_input_namelist, & - rttov_Ninstruments, rttov_instrument_namelists, rttov_configs)!, rttov_instrument_Nchannels) -! Lrttov_run,rttov_Ninstruments,rttov_instrument_namelists, & ! Input logical, input N instr., instr. nls -! rttov_instrument_configs, & ! Output object is an array of N rttov_config_opts ! JKS can this be a pointer? -! ) + rttov_Ninstruments, rttov_instrument_namelists, rttov_configs) call cpu_time(driver_time(3)) !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -484,8 +479,7 @@ program cosp2_test Lptradarflag5,Lptradarflag6,Lptradarflag7,Lptradarflag8,Lptradarflag9,Lradarpia, & Lwr_occfreq, Lcfodd, & rttov_Ninstruments,rttov_configs, & - Lrttov_bt, Lrttov_rad, Lrttov_refl, & - Npoints, Ncolumns, Nlevels, Nlvgrid_local, rttov_Nchannels, cospOUT) + Npoints, Ncolumns, Nlevels, Nlvgrid_local, cospOUT) !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Break COSP up into pieces and loop over each COSP 'chunk'. @@ -513,13 +507,13 @@ program cosp2_test !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if (iChunk .eq. 1) then call construct_cospIN(Nptsperit,nColumns,nLevels,rttov_Ninstruments,cospIN) - call construct_cospstateIN(Nptsperit,nLevels,rttov_Nchannels,cospstateIN) + call construct_cospstateIN(Nptsperit,nLevels,cospstateIN) endif if (iChunk .eq. nChunks) then call destroy_cospIN(cospIN) call destroy_cospstateIN(cospstateIN) call construct_cospIN(Nptsperit,nColumns,nLevels,rttov_Ninstruments,cospIN) - call construct_cospstateIN(Nptsperit,nLevels,rttov_Nchannels,cospstateIN) + call construct_cospstateIN(Nptsperit,nLevels,cospstateIN) endif call cpu_time(driver_time(4)) @@ -632,15 +626,10 @@ program cosp2_test !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Free up memory !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - print*,'destroy_cosp_outputs' call destroy_cosp_outputs(cospOUT) - print*,'destroy_cospIN' call destroy_cospIN(cospIN) - print*,'destroy_cospstateIN' call destroy_cospstateIN(cospstateIN) - print*,'cosp_cleanUp' call cosp_cleanUp() - print*,'done.' ! Getting a segmentation fault here? Why? JKS contains @@ -1063,9 +1052,6 @@ subroutine construct_cospIN(npoints,ncolumns,nlevels,ninst_rttov,y) y%Npart = 4 y%Nrefl = PARASOL_NREFL allocate(y%frac_out(npoints, ncolumns,nlevels)) - if (Lrttov) then - y%nChannels_rttov = rttov_Nchannels ! RTTOV dimension - endif if (Lmodis .or. Lmisr .or. Lisccp) then allocate(y%tau_067(npoints, ncolumns,nlevels),& @@ -1118,12 +1104,11 @@ end subroutine construct_cospIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE construct_cospstateIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine construct_cospstateIN(npoints,nlevels,nchan,y) + subroutine construct_cospstateIN(npoints,nlevels,y) ! Inputs integer,intent(in) :: & npoints, & ! Number of horizontal gridpoints - nlevels, & ! Number of vertical levels - nchan ! Number of channels + nlevels ! Number of vertical levels ! Outputs type(cosp_column_inputs),intent(out) :: y @@ -1131,7 +1116,7 @@ subroutine construct_cospstateIN(npoints,nlevels,nchan,y) y%pfull(npoints,nlevels),y%phalf(npoints,nlevels+1),y%qv(npoints,nlevels), & y%o3(npoints,nlevels),y%hgt_matrix(npoints,nlevels),y%u_sfc(npoints), & y%v_sfc(npoints),y%lat(npoints),y%lon(nPoints), & - y%emis_sfc(npoints,nchan),y%refl_sfc(npoints,nchan), & +! y%emis_sfc(npoints,nchan),y%refl_sfc(npoints,nchan), & y%cloudIce(nPoints,nLevels),y%cloudLiq(nPoints,nLevels),y%surfelev(npoints),& y%fl_snow(nPoints,nLevels),y%fl_rain(nPoints,nLevels),y%seaice(npoints), & y%tca(nPoints,nLevels),y%hgt_matrix_half(npoints,nlevels)) @@ -1176,8 +1161,7 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& Lptradarflag6,Lptradarflag7,Lptradarflag8, & Lptradarflag9,Lradarpia,Lwr_occfreq,Lcfodd, & N_rttov_instruments,rttov_configs, & - Lrttov_bt,Lrttov_rad,Lrttov_refl, & ! JKS remove when going multi-instrument - Npoints,Ncolumns,Nlevels,Nlvgrid,Nchan,x) ! JKS remove Nchan when going multi-instrument + Npoints,Ncolumns,Nlevels,Nlvgrid,x) ! Inputs logical,intent(in) :: & Lpctisccp, & ! ISCCP mean cloud top pressure @@ -1274,9 +1258,6 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& LcfadDbze94, & ! CLOUDSAT radar reflectivity CFAD Ldbze94, & ! CLOUDSAT radar reflectivity LparasolRefl, & ! PARASOL reflectance - Lrttov_bt, & ! RTTOV mean clear-sky brightness temperature - Lrttov_rad, & ! RTTOV mean clear-sky radiances - Lrttov_refl, & ! RTTOV mean clear-sky radiances Lptradarflag0, & ! CLOUDSAT Lptradarflag1, & ! CLOUDSAT Lptradarflag2, & ! CLOUDSAT @@ -1296,12 +1277,8 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& Ncolumns, & ! Number of subgrid columns Nlevels, & ! Number of model levels Nlvgrid, & ! Number of levels in L3 stats computation - Nchan, & ! Number of RTTOV channels N_rttov_instruments -! integer,dimension(N_rttov_instruments),intent(in) :: & -! rttov_instrument_nchannels - type(rttov_cfg), dimension(N_rttov_instruments),intent(in) :: & rttov_configs @@ -1464,36 +1441,6 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& if (Lwr_occfreq) allocate(x%wr_occfreq_ntotal(Npoints,WR_NREGIME)) if (Lcfodd) allocate(x%cfodd_ntotal(Npoints,CFODD_NDBZE,CFODD_NICOD,CFODD_NCLASS)) - ! JKS remove when going multi-instrument - ! RTTOV - Only add non-total fields if clouds or aerosols are simulated - if (Lrttov_pc) then ! Treat PC-RTTOV fields as clear-sky only for now - allocate(x%rttov_Ichannel(Nchan)) - if (Lrttov_bt) then ! Brightness temp - allocate(x%rttov_bt_total_pc(Npoints,Nchan)) -! if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_bt_clear(Npoints,Nchan)) - endif - if (Lrttov_rad) then ! Radiance - allocate(x%rttov_rad_total_pc(Npoints,Nchan)) -! if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_rad_clear(Npoints,Nchan)) -! if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_rad_cloudy(Npoints,Nchan)) - endif - else - allocate(x%rttov_Ichannel(Nchan)) - if (Lrttov_bt) then ! Brightness temp - allocate(x%rttov_bt_total(Npoints,Nchan)) - if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_bt_clear(Npoints,Nchan)) - endif - if (Lrttov_rad) then ! Radiance - allocate(x%rttov_rad_total(Npoints,Nchan)) - if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_rad_clear(Npoints,Nchan)) - if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_rad_cloudy(Npoints,Nchan)) - endif - if (Lrttov_refl) then ! Reflectance - allocate(x%rttov_refl_total(Npoints,Nchan)) - if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_refl_clear(Npoints,Nchan)) - endif - endif - ! RTTOV - Allocate output for multiple instruments ! Do I not need to allocate the number of instruments? Because each rttov output DDT will be a pointer? if (N_rttov_instruments .gt. 0) then @@ -1551,6 +1498,8 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& end if end if end do + else + x % N_rttov_instruments = 0 end if end subroutine construct_cosp_outputs @@ -1944,49 +1893,7 @@ subroutine destroy_cosp_outputs(y) nullify(y%wr_occfreq_ntotal) endif - ! RTTOV - if (associated(y%rttov_Ichannel)) then - deallocate(y%rttov_Ichannel) - nullify(y%rttov_Ichannel) - endif - if (associated(y%rttov_bt_total)) then - deallocate(y%rttov_bt_total) - nullify(y%rttov_bt_total) - endif - if (associated(y%rttov_bt_clear)) then - deallocate(y%rttov_bt_clear) - nullify(y%rttov_bt_clear) - endif - if (associated(y%rttov_rad_total)) then - deallocate(y%rttov_rad_total) - nullify(y%rttov_rad_total) - endif - if (associated(y%rttov_rad_clear)) then - deallocate(y%rttov_rad_clear) - nullify(y%rttov_rad_clear) - endif - if (associated(y%rttov_rad_cloudy)) then - deallocate(y%rttov_rad_cloudy) - nullify(y%rttov_rad_cloudy) - endif - if (associated(y%rttov_refl_total)) then - deallocate(y%rttov_refl_total) - nullify(y%rttov_refl_total) - endif - if (associated(y%rttov_refl_clear)) then - deallocate(y%rttov_refl_clear) - nullify(y%rttov_refl_clear) - endif - if (associated(y%rttov_bt_total_pc)) then - deallocate(y%rttov_bt_total_pc) - nullify(y%rttov_bt_total_pc) - endif - if (associated(y%rttov_rad_total_pc)) then - deallocate(y%rttov_rad_total_pc) - nullify(y%rttov_rad_total_pc) - endif - - ! JKS - Add deallocate multi-inst rttov_output + ! RTTOV multi-instrument if (associated(y%rttov_outputs)) then do i=1,y % N_rttov_instruments ! Iterate over each instrument if (associated(y%rttov_outputs(i)%channel_indices)) then diff --git a/src/cosp.F90 b/src/cosp.F90 index 9d62e556b1..ab8ca6c643 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -52,7 +52,7 @@ MODULE MOD_COSP cloudsat_preclvl,grLidar532_histBsct,atlid_histBsct USE MOD_COSP_MODIS_INTERFACE, ONLY: cosp_modis_init, modis_IN USE MOD_COSP_RTTOV_INTERFACE, ONLY: & - COSP_RTTOV_INI2, & + COSP_RTTOV_INIT, & cosp_rttov_simulate_mi, & rttov_cfg, & rttov_output @@ -138,7 +138,7 @@ MODULE MOD_COSP Nlevels, & ! Number of levels. Npart, & ! Number of cloud meteors for LIDAR simulators. Nrefl, & ! Number of reflectances for PARASOL simulator - nChannels_rttov, & ! Number of RTTOV channels +! nChannels_rttov, & ! Number of RTTOV channels Ninst_rttov ! Number of RTTOV instruments real(wp) :: & emsfc_lw ! Surface emissivity @ 11micron @@ -303,22 +303,8 @@ MODULE MOD_COSP cfodd_ntotal => null() ! # of CFODD (Npoints,CFODD_NDBZE,CFODD_NICOD,CFODD_NCLASS) real(wp),dimension(:,:), pointer :: & wr_occfreq_ntotal => null() ! # of nonprecip/drizzle/precip (Npoints,WR_NREGIME) - - ! RTTOV outputs - JKS consider clear-sky and cloudy-sky values here - real(wp),pointer :: & - rttov_bt_total(:,:) => null(), & ! Brightness Temperature - rttov_bt_clear(:,:) => null(), & ! Brightness Temperature - rttov_rad_total(:,:) => null(), & ! Radiance - rttov_rad_clear(:,:) => null(), & ! Radiance - rttov_rad_cloudy(:,:) => null(), & ! Radiance - rttov_refl_total(:,:) => null(), & ! Reflectance - rttov_refl_clear(:,:) => null(), & ! Reflectance - rttov_bt_total_pc(:,:) => null(), & ! Brightness Temperature (PC-RTTOV) - rttov_rad_total_pc(:,:) => null() ! Radiance (PC-RTTOV) - integer,dimension(:),pointer :: & - rttov_Ichannel => null() - integer :: N_rttov_instruments - + integer :: & + N_rttov_instruments type(rttov_output),pointer :: & rttov_outputs(:) @@ -374,7 +360,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) Lcloudsat_column, & ! On/Off switch for column CLOUDSAT simulator Lmodis_column, & ! On/Off switch for column MODIS simulator Lrttov_column, & ! On/Off switch for column RTTOV simulator - Lrttov_pc, & ! On/Off switch for PC-RTTOV simulator +! Lrttov_pc, & ! On/Off switch for PC-RTTOV simulator Lradar_lidar_tcc, & ! On/Off switch from joint Calipso/Cloudsat product Lcloudsat_tcc, & ! Lcloudsat_tcc2, & ! @@ -462,7 +448,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) Lcloudsat_column = .false. Lmodis_column = .false. Lrttov_column = .false. - Lrttov_pc = .false. +! Lrttov_pc = .false. Lradar_lidar_tcc = .false. Llidar_only_freq_cloud = .false. Lcloudsat_tcc = .false. @@ -523,24 +509,8 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! PARASOL subcolumn if (associated(cospOUT%parasolPix_refl)) & Lparasol_subcolumn = .true. - - ! RTTOV column - if (associated(cospOUT%rttov_bt_total) .or. & - associated(cospOUT%rttov_bt_clear) .or. & - associated(cospOUT%rttov_rad_total) .or. & - associated(cospOUT%rttov_rad_clear) .or. & - associated(cospOUT%rttov_rad_cloudy) .or. & - associated(cospOUT%rttov_refl_total) .or. & - associated(cospOUT%rttov_refl_clear) .or. & - associated(cospOUT%rttov_bt_total_pc) .or. & - associated(cospOUT%rttov_rad_total_pc)) & - Lrttov_column = .true. - - ! PC-RTTOV - if (associated(cospOUT%rttov_bt_total_pc) .or. & - associated(cospOUT%rttov_rad_total_pc)) & - Lrttov_pc = .true. + ! RTTOV Column if (associated(cospOUT%rttov_outputs)) then Lrttov_column = .true. print*,'multi-inst. RTTOV called' @@ -779,7 +749,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) rttovIN%nPoints => Npoints rttovIN%nLevels => cospIN%nLevels rttovIN%nSubCols => cospIN%nColumns - rttovIN%nChannels => cospIN%nChannels_rttov rttovIN%co2 => cospgridIN%co2 rttovIN%ch4 => cospgridIN%ch4 rttovIN%n2o => cospgridIN%n2o @@ -1860,17 +1829,10 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La cloudsat_radar_freq, cloudsat_k2, cloudsat_use_gas_abs, cloudsat_do_ray, & isccp_top_height, isccp_top_height_direction, surface_radar, rcfg, lusevgrid, & luseCSATvgrid, Nvgrid, Nlevels, cloudsat_micro_scheme, & -! NchanIN, Lrttov_bt, Lrttov_rad, Lrttov_refl, & -! Lrttov_cld, Lrttov_aer, Lrttov_cldparam, Lrttov_aerparam, Lrttov_pc, & -! rttov_input_namelist, & - rttov_Ninstruments, rttov_instrument_namelists,rttov_configs) !, rttov_instrument_Nchannels) + rttov_Ninstruments, rttov_instrument_namelists,rttov_configs) ! INPUTS logical,intent(in) :: Lisccp,Lmodis,Lmisr,Lcloudsat,Lcalipso,LgrLidar532,Latlid,Lparasol,Lrttov -! logical,intent(in) :: & -! Lrttov_bt, Lrttov_rad, Lrttov_refl, & -! Lrttov_cld, Lrttov_aer, Lrttov_cldparam, Lrttov_aerparam, & -! Lrttov_pc integer,intent(in) :: & cloudsat_use_gas_abs, & ! cloudsat_do_ray, & ! @@ -1880,8 +1842,6 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La Nvgrid, & ! Number of levels for new L3 grid surface_radar, & ! rttov_Ninstruments -! integer,intent(inout) :: & -! NchanIN real(wp),intent(in) :: & cloudsat_radar_freq, & ! cloudsat_k2 ! @@ -1892,9 +1852,7 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La character(len=64),intent(in) :: & cloudsat_micro_scheme ! Microphysical scheme used by CLOUDSAT real(wp),dimension(10) :: driver_time - -! character(len=256),intent(in) :: rttov_input_namelist - + type(character(len=256)), dimension(rttov_Ninstruments) :: & rttov_instrument_namelists ! Array of paths to RTTOV instrument namelists @@ -1950,7 +1908,7 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La ! Could print diagnostic on timing here. if (Lrttov) then call cpu_time(driver_time(1)) - call cosp_rttov_ini2(Nlevels,rttov_Ninstruments, & + call cosp_rttov_init(Nlevels,rttov_Ninstruments, & rttov_instrument_namelists, & rttov_configs) @@ -2008,7 +1966,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Latlid_subcolumn, & ! EarthCare subcolumn simulator on/off switch Latlid_column, & ! EarthCare column simulator on/off switch LgrLidar532_subcolumn, & ! Ground Lidar subcolumn simulator on/off switch - LgrLidar532_column, & ! Ground Lidar column simulator on/off switch + LgrLidar532_column, & ! Ground Lidar column simulator on/off switch Lparasol_subcolumn, & ! PARASOL subcolumn simulator on/off switch Lparasol_column, & ! PARASOL column simulator on/off switch Lrttov_subcolumn, & ! RTTOV subcolumn simulator on/off switch @@ -2026,6 +1984,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, ! Local variables character(len=100) :: parasolErrorMessage logical :: alloc_status + integer :: i nError = 0 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -2588,16 +2547,16 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, ! RTTOV if (Lrttov_column) then alloc_status = .true. - if (.not. allocated(cospgridIN%emis_sfc)) then - nError=nError+1 - errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%emis_sfc has not been allocated' - alloc_status = .false. - endif - if (.not. allocated(cospgridIN%refl_sfc)) then - nError=nError+1 - errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%refl_sfc has not been allocated' - alloc_status = .false. - endif +! if (.not. allocated(cospgridIN%emis_sfc)) then +! nError=nError+1 +! errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%emis_sfc has not been allocated' +! alloc_status = .false. +! endif +! if (.not. allocated(cospgridIN%refl_sfc)) then +! nError=nError+1 +! errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%refl_sfc has not been allocated' +! alloc_status = .false. +! endif if (.not. allocated(cospgridIN%hgt_matrix_half)) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%hgt_matrix_half has not been allocated' @@ -2705,16 +2664,20 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, endif if (.not. alloc_status) then Lrttov_column = .false. - if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 - if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if endif endif @@ -2812,16 +2775,20 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lcloudsat_tcc = .false. Lcloudsat_tcc2 = .false. Lcloudsat_modis_wr = .false. - if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 - if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:)= R_UNDEF + if (associated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if if (associated(cospOUT%isccp_totalcldarea)) cospOUT%isccp_totalcldarea(:) = R_UNDEF if (associated(cospOUT%isccp_meantb)) cospOUT%isccp_meantb(:) = R_UNDEF if (associated(cospOUT%isccp_meantbclr)) cospOUT%isccp_meantbclr(:) = R_UNDEF @@ -2863,16 +2830,20 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lisccp_subcolumn = .false. Lisccp_column = .false. Lrttov_column = .false. - if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 - if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:)= R_UNDEF + if (associated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if if (associated(cospOUT%isccp_totalcldarea)) cospOUT%isccp_totalcldarea(:) = R_UNDEF if (associated(cospOUT%isccp_meantb)) cospOUT%isccp_meantb(:) = R_UNDEF if (associated(cospOUT%isccp_meantbclr)) cospOUT%isccp_meantbclr(:) = R_UNDEF @@ -2897,16 +2868,20 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lrttov_column = .false. Latlid_column = .false. LgrLidar532_column = .false. - if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 - if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:)= R_UNDEF + if (associated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if if (associated(cospOUT%isccp_totalcldarea)) cospOUT%isccp_totalcldarea(:) = R_UNDEF if (associated(cospOUT%isccp_meantb)) cospOUT%isccp_meantb(:) = R_UNDEF if (associated(cospOUT%isccp_meantbclr)) cospOUT%isccp_meantbclr(:) = R_UNDEF @@ -2983,16 +2958,20 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lisccp_subcolumn = .false. Lisccp_column = .false. Lrttov_column = .false. - if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 - if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:)= R_UNDEF + if (associated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if if (associated(cospOUT%isccp_totalcldarea)) cospOUT%isccp_totalcldarea(:) = R_UNDEF if (associated(cospOUT%isccp_meantb)) cospOUT%isccp_meantb(:) = R_UNDEF if (associated(cospOUT%isccp_meantbclr)) cospOUT%isccp_meantbclr(:) = R_UNDEF @@ -3069,16 +3048,20 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Latlid_column = .false. LgrLidar532_column = .false. Lcloudsat_modis_wr = .false. - if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 - if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if if (associated(cospOUT%calipso_cfad_sr)) cospOUT%calipso_cfad_sr(:,:,:) = R_UNDEF if (associated(cospOUT%calipso_lidarcld)) cospOUT%calipso_lidarcld(:,:) = R_UNDEF if (associated(cospOUT%calipso_lidarcldphase)) cospOUT%calipso_lidarcldphase(:,:,:) = R_UNDEF @@ -3113,16 +3096,20 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lrttov_column = .false. Lcalipso_column = .false. Lparasol_column = .false. - if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 - if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if if (associated(cospOUT%calipso_cfad_sr)) cospOUT%calipso_cfad_sr(:,:,:) = R_UNDEF if (associated(cospOUT%calipso_lidarcld)) cospOUT%calipso_lidarcld(:,:) = R_UNDEF if (associated(cospOUT%calipso_lidarcldphase)) cospOUT%calipso_lidarcldphase(:,:,:) = R_UNDEF @@ -3145,16 +3132,20 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lisccp_subcolumn = .false. Lisccp_column = .false. Lrttov_column = .false. - if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 - if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:)= R_UNDEF + if (associated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if if (associated(cospOUT%isccp_totalcldarea)) cospOUT%isccp_totalcldarea(:) = R_UNDEF if (associated(cospOUT%isccp_meantb)) cospOUT%isccp_meantb(:) = R_UNDEF if (associated(cospOUT%isccp_meantbclr)) cospOUT%isccp_meantbclr(:) = R_UNDEF @@ -3173,151 +3164,191 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%co2 contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 - if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if endif if (cospgridIN%ch4 .lt. 0) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%ch4 contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 - if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if endif if (cospgridIN%n2o .lt. 0) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%n2o contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 - if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if endif if (cospgridIN%co.lt. 0) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%co contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 - if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if endif if (any(cospgridIN%o3 .lt. 0)) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%o3 contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 - if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if endif if (any(cospgridIN%emis_sfc .lt. 0. .OR. cospgridIN%emis_sfc .gt. 1)) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%emis_sfc contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 - if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if endif if (any(cospgridIN%refl_sfc .lt. 0. .OR. cospgridIN%refl_sfc .gt. 1)) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%refl_sfc contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 - if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if endif if (any(cospgridIN%u_sfc .lt. -100. .OR. cospgridIN%u_sfc .gt. 100.)) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospIN%u_sfc contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 - if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if endif if (any(cospgridIN%v_sfc .lt. -100. .OR. cospgridIN%v_sfc .gt. 100.)) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospIN%v_sfc contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 - if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if endif if (any(cospgridIN%lat .lt. -90 .OR. cospgridIN%lat .gt. 90)) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospIN%lat contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_Ichannel)) cospOUT%rttov_Ichannel(:) = 0 - if (associated(cospOUT%rttov_bt_total)) cospOUT%rttov_bt_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_clear)) cospOUT%rttov_bt_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total)) cospOUT%rttov_rad_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_clear)) cospOUT%rttov_rad_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_cloudy)) cospOUT%rttov_rad_cloudy(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_total)) cospOUT%rttov_refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_refl_clear)) cospOUT%rttov_refl_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_bt_total_pc)) cospOUT%rttov_bt_total_pc(:,:) = R_UNDEF - if (associated(cospOUT%rttov_rad_total_pc)) cospOUT%rttov_rad_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if endif endif diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index e7b50ace1a..cdd80e9600 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -32,15 +32,8 @@ ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MODULE MOD_COSP_RTTOV_INTERFACE USE COSP_KINDS, ONLY: wp - use mod_cosp_rttov, only: nchannels_rec,iChannel,emisChannel,reflChannel, & - coef_rttov,opts,rttov_in, & - do_rttov_bt,do_rttov_rad,do_rttov_refl, & - do_rttov_cld,do_rttov_aer,do_rttov_pcrttov, & - rttov_cld_optparam,rttov_aer_optparam, & - rttov_direct_nthreads,rttovDir,PC_coef_filepath, & - so2,ch4,co,co2,n2o,zenang,npcscores,predictindex, & - iChannel_out,Lchannel_filepath - + + use mod_cosp_rttov, only: rttov_in ! rttov_const contains useful RTTOV constants USE rttov_const, ONLY : & @@ -72,7 +65,6 @@ MODULE MOD_COSP_RTTOV_INTERFACE INTEGER(KIND=jpim) :: alloc_status(60) - ! DDT for each instrument being simulated. Values to be assigned during the cosp_rttov_init subroutine type rttov_cfg logical(KIND=jplm) :: & @@ -88,6 +80,7 @@ MODULE MOD_COSP_RTTOV_INTERFACE cld_coef_filepath, & PC_coef_filepath integer(KIND=jpim) :: & + nchanprof, & rttov_direct_nthreads integer(KIND=jpim) :: & nchan_out, & @@ -98,7 +91,7 @@ MODULE MOD_COSP_RTTOV_INTERFACE CO_mr, & N2O_mr, & SO2_mr, & - rttov_ZenAng + ZenAng integer(kind=jpim), allocatable :: & iChannel(:), & ! Requested channel indices iChannel_out(:) ! Passing out the channel indices (actual output channels) @@ -108,10 +101,9 @@ MODULE MOD_COSP_RTTOV_INTERFACE type(rttov_options) :: & opts ! RTTOV options structure type(rttov_coefs) :: & - coefs + coefs ! RTTOV coefficients structure end type rttov_cfg - type rttov_output integer :: & nchan_out @@ -133,9 +125,9 @@ MODULE MOD_COSP_RTTOV_INTERFACE CONTAINS !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE cosp_rttov_ini2 + ! SUBROUTINE cosp_rttov_init !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_INI2(Nlevels,Ninstruments,instrument_namelists, & + SUBROUTINE COSP_RTTOV_INIT(Nlevels,Ninstruments,instrument_namelists, & rttov_configs) integer,intent(in) :: & @@ -162,7 +154,7 @@ SUBROUTINE COSP_RTTOV_INI2(Nlevels,Ninstruments,instrument_namelists, & end do - END SUBROUTINE COSP_RTTOV_INI2 + END SUBROUTINE COSP_RTTOV_INIT !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_init @@ -274,7 +266,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & rttov_config%CO_mr = CO_mr rttov_config%CO2_mr = CO2_mr rttov_config%CH4_mr = CH4_mr - rttov_config%rttov_ZenAng = rttov_ZenAng + rttov_config%ZenAng = rttov_ZenAng ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 1. Initialise RTTOV options structure @@ -508,7 +500,7 @@ SUBROUTINE COSP_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, rttovConfig logical,intent(in) :: & lCleanup ! Flag to determine whether to deallocate RTTOV types - real(wp),intent(inout),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! + real(wp),intent(inout),dimension(rttovIN%nPoints,rttovConfig%nchan_out) :: & ! Can I do this? I guess so! bt_total, & ! All-sky bt_clear, & ! Clear-sky rad_total, & ! All-sky @@ -563,7 +555,7 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, rttovConfig logical,intent(in) :: & lCleanup ! Flag to determine whether to deallocate RTTOV types - real(wp),intent(inout),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! + real(wp),intent(inout),dimension(rttovIN%nPoints,rttovConfig%nchan_out) :: & bt_total, & ! All-sky bt_clear, & ! Clear-sky rad_total, & ! All-sky @@ -583,7 +575,8 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, rttovConfig % nChannels_rec, & rttovConfig % opts, & rttovConfig % coefs, & - rttovConfig % iChannel) + rttovConfig % iChannel, & + rttovConfig % nchanprof) print*,'cosp_rttov_allocate successful' ! jks call cpu_time(driver_time(2)) @@ -594,7 +587,8 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, rttovConfig % CH4_mr, & rttovConfig % CO_mr, & rttovConfig % N2O_mr, & - rttovConfig % SO2_mr) + rttovConfig % SO2_mr, & + rttovConfig % ZenAng) print*,'cosp_rttov_construct_profiles_mi successful' ! jks call cpu_time(driver_time(3)) @@ -622,9 +616,9 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, print*,'cosp_rttov_save_output successful' ! jks call cpu_time(driver_time(6)) call cosp_rttov_deallocate_profiles_mi(rttovIN, & - rttovConfig % nChannels_rec, & rttovConfig % opts, & - rttovConfig % coefs) + rttovConfig % coefs, & + rttovConfig % nchanprof) call cpu_time(driver_time(7)) print*,'Time to run "cosp_rttov_allocate": ', driver_time(2)-driver_time(1) @@ -669,7 +663,7 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, rttovConfig logical,intent(in) :: & lCleanup ! Flag to determine whether to deallocate RTTOV types - real(wp),intent(inout),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! + real(wp),intent(inout),dimension(rttovIN%nPoints,rttovConfig%nchan_out) :: & ! Can I do this? I guess so! bt_total, & ! All-sky rad_total ! All-sky character(len=128) :: & @@ -681,12 +675,13 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, ! print*,'cosp_rttov_allocate begin' ! jks call cpu_time(driver_time(1)) call cosp_pc_rttov_allocate_mi(rttovIN, & - rttovConfig%PC_coef_filepath, & - rttovConfig%coefs, & - rttovConfig%opts, & - rttovConfig%nchannels_rec, & - rttovConfig%iChannel, & - rttovConfig%iChannel_out) + rttovConfig % PC_coef_filepath, & + rttovConfig % coefs, & + rttovConfig % opts, & + rttovConfig % nchannels_rec, & + rttovConfig % iChannel, & + rttovConfig % nchanprof, & + rttovConfig % iChannel_out) print*,'cosp_pc_rttov_allocate_mi successful' ! jks call cpu_time(driver_time(2)) call cosp_rttov_construct_profiles_mi(rttovIN, & @@ -696,7 +691,8 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, rttovConfig % CH4_mr, & rttovConfig % CO_mr, & rttovConfig % N2O_mr, & - rttovConfig % SO2_mr) + rttovConfig % SO2_mr, & + rttovConfig % ZenAng) print*,'cosp_rttov_construct_profiles_mi successful' ! jks call cpu_time(driver_time(3)) call cosp_pc_rttov_setup_emissivity() @@ -722,7 +718,8 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, call cosp_pc_rttov_deallocate_profiles_mi(rttovIN, & rttovConfig % nChannels_rec, & rttovConfig % opts, & - rttovConfig % coefs) + rttovConfig % coefs, & + rttovConfig % nchanprof) call cpu_time(driver_time(7)) print*,'Time to run "cosp_pc_rttov_allocate": ', driver_time(2)-driver_time(1) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 657f53b425..c840957ac5 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -112,43 +112,12 @@ module mod_cosp_rttov ! Scattering coefficients (read in once during initialization) ! JKS - KISS ! type(rttov_scatt_coef) :: & -! coef_scatt - ! RTTOV setup and options (set during initialization) - logical :: & - do_rttov_cld, & ! Include clouds in RTTOV calculations - do_rttov_aer, & ! Include aerosols in RTTOV calculations - do_rttov_bt, & ! Return brightness temps in RTTOV calculations - do_rttov_rad, & ! Return radiances in RTTOV calculations - do_rttov_refl, & ! Return reflectances in RTTOV calculations - do_rttov_pcrttov, & ! Do computations using PC-RTTOV - rttov_cld_optparam, & ! Use user-supplied optical cloud parameters - rttov_aer_optparam, & ! Use user-supplied optical aerosol parameters - Lchannel_filepath - - ! --- Well-mixed trace gas mixing ratios from user via RTTOV namelist - real(wp) :: so2 = 0._wp - real(wp) :: ch4 = 0._wp - real(wp) :: co = 0._wp - real(wp) :: co2 = 0._wp - real(wp) :: n2o = 0._wp - real(wp) :: zenang = 0._wp ! NADIR default - - character(len=256) :: & - rttovDir ! Directory for the RTTOV source code - - character(len=256) :: PC_coef_filepath = '' - -! JKS - KISS -! type(rttov_options_scatt) :: & -! opts_scatt +! coef_scatt ! module-wides variables for input !==================== integer(kind=jpim) :: dosolar - integer(kind=jpim) :: nchanprof ! JKS - jpim is RTTOV integer type - TYPE(rttov_options) :: opts ! defaults to everything optional switched off - TYPE(rttov_coefs) :: coef_rttov ! Coefficients structure TYPE(rttov_chanprof), POINTER :: chanprof(:) => NULL() ! Input channel/profile list LOGICAL(KIND=jplm), POINTER :: calcemis(:) => NULL() ! Flag to indicate calculation of emissivity within RTTOV TYPE(rttov_emissivity), POINTER :: emissivity(:) => NULL() ! Input/output surface emissivity @@ -178,7 +147,6 @@ module mod_cosp_rttov nPoints, & ! Number of profiles to simulate nLevels, & ! Number of levels nSubCols, & ! Number of subcolumns - nChannels, & ! Number of channels to simulate ! JKS, can remove now month ! Month (needed for surface emissivity calculation) real(wp),pointer :: & ! Could change the dimensionality of these in the future co2, & ! Carbon dioxide @@ -245,7 +213,7 @@ end subroutine rttov_error ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine cosp_rttov_allocate_mi(rttovIN,inst_nChannels_rec,inst_opts, & - inst_coefs,inst_iChannel) + inst_coefs,inst_iChannel,inst_nchanprof) type(rttov_in),intent(in) :: & rttovIN @@ -257,7 +225,8 @@ subroutine cosp_rttov_allocate_mi(rttovIN,inst_nChannels_rec,inst_opts, & inst_coefs integer(kind=jpim),dimension(inst_nChannels_rec),intent(in) :: & inst_iChannel - + integer(kind=jpim),intent(inout) :: & + inst_nchanprof ! Loop variables integer(kind=jpim) :: j, jch, nch @@ -268,15 +237,14 @@ subroutine cosp_rttov_allocate_mi(rttovIN,inst_nChannels_rec,inst_opts, & ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Determine the total number of radiances to simulate (nchanprof). - nchanprof = inst_nChannels_rec * rttovIN%nPoints ! RTTOV (non-PC) needs nchan_out? JKS potential bug -! print*,'nchanprof: ',nchanprof + inst_nchanprof = inst_nChannels_rec * rttovIN%nPoints ! RTTOV (non-PC) needs nchan_out? JKS potential bug ! Allocate structures for rttov_direct call rttov_alloc_direct( & errorstatus, & 1_jpim, & ! 1 => allocate rttovIN%nPoints, & - nchanprof, & + inst_nchanprof, & rttovIN%nLevels, & chanprof, & inst_opts, & @@ -319,7 +287,7 @@ end subroutine cosp_rttov_allocate_mi subroutine cosp_pc_rttov_allocate_mi(rttovIN,inst_PC_coef_filepath, & !inst_npcscores, & inst_coefs,inst_opts, & inst_nchannels_rec,inst_iChannel_in, & - inst_iChannel_out) !,inst_predictindex) + inst_nchanprof, inst_iChannel_out) !,inst_predictindex) type(rttov_in),intent(in) :: & rttovIN @@ -333,6 +301,8 @@ subroutine cosp_pc_rttov_allocate_mi(rttovIN,inst_PC_coef_filepath, & !inst_npcs inst_nchannels_rec integer(kind=jpim),intent(in),dimension(inst_nchannels_rec) :: & inst_iChannel_in ! Channel indices the user initially requests. + integer(kind=jpim),intent(inout) :: & + inst_nchanprof integer(kind=jpim),intent(inout),allocatable :: & inst_iChannel_out(:) ! Passing out the channel indices @@ -355,7 +325,7 @@ subroutine cosp_pc_rttov_allocate_mi(rttovIN,inst_PC_coef_filepath, & !inst_npcs ! npred_pc is only used in the pc_rttov_allocate step so I can remove the global definition later inst_npred_pc = SIZE(predictindex) - nchanprof = inst_npred_pc * rttovIN%nPoints ! Size of chanprof array is total number of predictors over all profiles + inst_nchanprof = inst_npred_pc * rttovIN%nPoints ! Size of chanprof array is total number of predictors over all profiles ! Determine the number of reconstructed radiances per profile (nchannels_rec) if (inst_opts % rt_ir % pc % addradrec) then @@ -386,7 +356,7 @@ subroutine cosp_pc_rttov_allocate_mi(rttovIN,inst_PC_coef_filepath, & !inst_npcs errorstatus, & 1_jpim, & ! 1 => allocate rttovIN%nPoints, & - nchanprof, & + inst_nchanprof, & rttovIN%nLevels, & chanprof, & ! Make this instrument-specific? The rttov_config DDT would then be assigned to this value. Allocation difficulties? inst_opts, & @@ -432,7 +402,8 @@ subroutine cosp_rttov_construct_profiles_mi(rttovIN, & inst_ch4_mr, & inst_co_mr, & inst_n2o_mr, & - inst_so2_mr) + inst_so2_mr, & + inst_zenang) type(rttov_in),intent(in) :: & ! What is the best way to do this? Should rttovIN be a module-wide DDT? Yes. rttovIN @@ -444,7 +415,8 @@ subroutine cosp_rttov_construct_profiles_mi(rttovIN, & inst_ch4_mr, & inst_co_mr, & inst_n2o_mr, & - inst_so2_mr + inst_so2_mr, & + inst_zenang ! Loop variables integer(kind=jpim) :: i, j ! Use i to iterate over profile, j for levels. @@ -515,7 +487,7 @@ subroutine cosp_rttov_construct_profiles_mi(rttovIN, & profiles(i)%skin%fastem(5) = 0.3 ! Viewing angles - profiles(i)%zenangle = zenang ! pass in from cosp + profiles(i)%zenangle = inst_zenang ! pass in from cosp profiles(i)%azangle = 0. ! hard-coded in rttov9 int JKS-? profiles(i)%latitude = rttovIN%latitude(i) @@ -881,26 +853,28 @@ end subroutine cosp_pc_rttov_save_output_mi ! From RTTOV example files. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_rttov_deallocate_profiles_mi(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs) + subroutine cosp_rttov_deallocate_profiles_mi(rttovIN, & + inst_opts, & + inst_coefs, & + inst_nchanprof) type(rttov_in),intent(in) :: & rttovIN - integer(kind=jpim),intent(in) :: & - inst_nChannels_rec +! integer(kind=jpim),intent(in) :: & +! inst_nChannels_rec type(rttov_options),intent(in) :: & inst_opts type(rttov_coefs),intent(in) :: & inst_coefs + integer(kind=jpim),intent(in) :: & + inst_nchanprof - ! Does this variable need to be global? I don't think so. - nchanprof = inst_nChannels_rec * rttovIN%nPoints ! RTTOV (non-PC) needs nchan_out? JKS potential bug - ! Deallocate structures for rttov_direct call rttov_alloc_direct( & errorstatus, & 0_jpim, & ! 0 => deallocate rttovIN%nPoints, & - nchanprof, & ! JKS + inst_nchanprof, & rttovIN%nLevels, & chanprof, & ! JKS inst_opts, & @@ -925,9 +899,10 @@ end subroutine cosp_rttov_deallocate_profiles_mi subroutine cosp_pc_rttov_deallocate_profiles_mi(rttovIN, & inst_nChannels_rec, & inst_opts, & - inst_coefs) + inst_coefs, & + inst_nchanprof) - type(rttov_in),intent(in) :: & + type(rttov_in),intent(in) :: & rttovIN integer(kind=jpim),intent(in) :: & inst_nChannels_rec @@ -935,6 +910,8 @@ subroutine cosp_pc_rttov_deallocate_profiles_mi(rttovIN, & inst_opts type(rttov_coefs),intent(in) :: & inst_coefs + integer(kind=jpim),intent(in) :: & + inst_nchanprof if (ASSOCIATED(predictindex)) deallocate (predictindex, stat=alloc_status(10)) call rttov_error('mem dellocation error for "predictindex"', lalloc = .true.) @@ -947,7 +924,7 @@ subroutine cosp_pc_rttov_deallocate_profiles_mi(rttovIN, & errorstatus, & 0_jpim, & ! 0 => deallocate rttovIN%nPoints, & - nchanprof, & + inst_nchanprof, & rttovIN%nLevels, & chanprof, & inst_opts, & From 383ac08077e7b28ce331ac04b9ac0195669d5210 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Mon, 5 Jun 2023 12:15:35 -0600 Subject: [PATCH 061/159] Remove old namelist dependencies, update STUB functionality, correct PC-RTTOV all-sky output labelling. --- driver/run/cosp2_input_rttov_nl.txt | 2 +- driver/run/cosp2_output_pcrttov_nl.txt | 9 - .../run/instrument_nls/cosp2_rttov_inst1.txt | 4 +- .../run/instrument_nls/cosp2_rttov_inst2.txt | 4 +- .../run/instrument_nls/cosp2_rttov_inst3.txt | 4 +- driver/src/cosp2_io.f90 | 26 +-- driver/src/cosp2_test.F90 | 71 ++---- src/cosp.F90 | 25 +- src/simulator/cosp_rttov_interfaceSTUB.F90 | 141 ++++++----- src/simulator/cosp_rttov_interface_v13.F90 | 218 +++++++++--------- src/simulator/rttov/cosp_rttov_v13.F90 | 114 +++++---- 11 files changed, 303 insertions(+), 315 deletions(-) diff --git a/driver/run/cosp2_input_rttov_nl.txt b/driver/run/cosp2_input_rttov_nl.txt index 4b7dadba38..852c06e1d9 100644 --- a/driver/run/cosp2_input_rttov_nl.txt +++ b/driver/run/cosp2_input_rttov_nl.txt @@ -85,7 +85,7 @@ rttov_Ninstruments=3, ! rttov_instrument_namelists = (/'test1','test2','test3'/), ! rttov_instrument_namelists(1:3) = (/'test1','test2','test3'/), - rttov_Nchannels=2300, ! Number of channels to be computed + Lrttov_localtime=.false., ! May not be necessary at this level rttov_Nlocaltime=2, rttov_localtime=10.0,13.0, ! To implement local time rttov_localtimewindow=1.0,1.0, ! To implement local time width diff --git a/driver/run/cosp2_output_pcrttov_nl.txt b/driver/run/cosp2_output_pcrttov_nl.txt index 16120d928a..9c8a349949 100644 --- a/driver/run/cosp2_output_pcrttov_nl.txt +++ b/driver/run/cosp2_output_pcrttov_nl.txt @@ -134,15 +134,6 @@ Lclmodis=.true., !- RTTOV Lrttov_run=.true., ! Run RTTOV? - Lrttov_bt=.true., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aer=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_localtime=.false., ! May not be necessary at this level - Lrttov_pc=.true., ! -CLOUDSAT precipitation frequency/occurence diagnostics Lptradarflag0=.true., Lptradarflag1=.true., diff --git a/driver/run/instrument_nls/cosp2_rttov_inst1.txt b/driver/run/instrument_nls/cosp2_rttov_inst1.txt index a0e69018ab..0e16f5691b 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst1.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst1.txt @@ -35,9 +35,9 @@ Lrttov_aerparam=.false., ! Use user input aerosol optical parameters Lrttov_pc=.false., ! Run with PC-RTTOV !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec2=1000, ! 2300 + nchannels_rec=0, ! 2300 !-------------- RTTOV Filepaths - Lchannel_filepath2=.false., + Lchannel_filepath=.false., channel_filepath='rttov_channel_input_AIRS.csv', rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', rttov_coefDir='rtcoef_rttov13/', diff --git a/driver/run/instrument_nls/cosp2_rttov_inst2.txt b/driver/run/instrument_nls/cosp2_rttov_inst2.txt index e12705a79b..587f32b560 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst2.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst2.txt @@ -35,9 +35,9 @@ Lrttov_aerparam=.false., ! Use user input aerosol optical parameters Lrttov_pc=.false., ! Run with PC-RTTOV !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec2=500, ! 2300 + nchannels_rec=500, ! 2300 !-------------- RTTOV Filepaths - Lchannel_filepath2=.false., + Lchannel_filepath=.false., channel_filepath='rttov_channel_input_AIRS.csv', rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', rttov_coefDir='rtcoef_rttov13/', diff --git a/driver/run/instrument_nls/cosp2_rttov_inst3.txt b/driver/run/instrument_nls/cosp2_rttov_inst3.txt index 58c34cfdc0..05b417a0d5 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst3.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst3.txt @@ -35,9 +35,9 @@ Lrttov_aerparam=.false., ! Use user input aerosol optical parameters Lrttov_pc=.true., ! Run with PC-RTTOV !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec2=250, ! 2300 + nchannels_rec=0, ! 2300 !-------------- RTTOV Filepaths - Lchannel_filepath2=.false., + Lchannel_filepath=.false., channel_filepath='rttov_channel_input_AIRS.csv', rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', rttov_coefDir='rtcoef_rttov13/', diff --git a/driver/src/cosp2_io.f90 b/driver/src/cosp2_io.f90 index e3db6a8b0a..751ad74acd 100644 --- a/driver/src/cosp2_io.f90 +++ b/driver/src/cosp2_io.f90 @@ -1449,7 +1449,7 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Ninst_rttov, lev, lon, if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) status = nf90_put_att(fileID,varID(ii),"units", "1") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(ii),"standard_name", " ") + status = nf90_put_att(fileID,varID(ii),"standard_name", "rttov_ichan") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) endif if (associated(cospOUT%rttov_outputs(i)%bt_total)) then @@ -1460,7 +1460,7 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Ninst_rttov, lev, lon, if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) status = nf90_put_att(fileID,varID(ii),"units", "Degrees Kelvin") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(ii),"standard_name", "bleh") + status = nf90_put_att(fileID,varID(ii),"standard_name", "rttov_allsky_bt") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) endif if (associated(cospOUT%rttov_outputs(i)%bt_clear)) then @@ -1471,7 +1471,7 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Ninst_rttov, lev, lon, if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) status = nf90_put_att(fileID,varID(ii),"units", "Degrees Kelvin") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(ii),"standard_name", "bleh") + status = nf90_put_att(fileID,varID(ii),"standard_name", "rttov_clearsky_bt") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) endif if (associated(cospOUT%rttov_outputs(i)%rad_total)) then @@ -1482,7 +1482,7 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Ninst_rttov, lev, lon, if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) status = nf90_put_att(fileID,varID(ii),"units", "mW/cm-1/sr/m2") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(ii),"standard_name", "bleh") + status = nf90_put_att(fileID,varID(ii),"standard_name", "rttov_allsky_rad") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) endif if (associated(cospOUT%rttov_outputs(i)%rad_clear)) then @@ -1493,7 +1493,7 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Ninst_rttov, lev, lon, if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) status = nf90_put_att(fileID,varID(ii),"units", "mW/cm-1/sr/m2") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(ii),"standard_name", "bleh") + status = nf90_put_att(fileID,varID(ii),"standard_name", "rttov_clearsky_rad") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) endif if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) then @@ -1504,7 +1504,7 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Ninst_rttov, lev, lon, if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) status = nf90_put_att(fileID,varID(ii),"units", "mW/cm-1/sr/m2") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(ii),"standard_name", "bleh") + status = nf90_put_att(fileID,varID(ii),"standard_name", "rttov_cloudysky_rad") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) endif if (associated(cospOUT%rttov_outputs(i)%refl_total)) then @@ -1526,29 +1526,29 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Ninst_rttov, lev, lon, if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) status = nf90_put_att(fileID,varID(ii),"units", "unitless") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(ii),"standard_name", "bleh") + status = nf90_put_att(fileID,varID(ii),"standard_name", "rttov_allsky_refl") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) endif if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) then ii = ii + 1 - status = nf90_def_var(fileID,"rttov_bt_total_pc_inst"//trim(i_str),nf90_float, (/dimID(1),dimID(20+i)/),varID(ii)) + status = nf90_def_var(fileID,"rttov_bt_clear_pc_inst"//trim(i_str),nf90_float, (/dimID(1),dimID(20+i)/),varID(ii)) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(ii),"long_name","PC-RTTOV All-sky Brightness Temperature") + status = nf90_put_att(fileID,varID(ii),"long_name","PC-RTTOV Clear-sky Brightness Temperature") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) status = nf90_put_att(fileID,varID(ii),"units", "Degrees Kelvin") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(ii),"standard_name", "bleh") + status = nf90_put_att(fileID,varID(ii),"standard_name", "pcrttov_clearsky_bt") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) endif if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) then ii = ii + 1 - status = nf90_def_var(fileID,"rttov_rad_total_pc_inst"//trim(i_str),nf90_float, (/dimID(1),dimID(20+i)/),varID(ii)) + status = nf90_def_var(fileID,"rttov_rad_clear_pc_inst"//trim(i_str),nf90_float, (/dimID(1),dimID(20+i)/),varID(ii)) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(ii),"long_name","PC-RTTOV All-sky Radiance") + status = nf90_put_att(fileID,varID(ii),"long_name","PC-RTTOV Clear-sky Radiance") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) status = nf90_put_att(fileID,varID(ii),"units", "mW/cm-1/sr/m2") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) - status = nf90_put_att(fileID,varID(ii),"standard_name", "bleh") + status = nf90_put_att(fileID,varID(ii),"standard_name", "pcrttov_clearsky_rad") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) endif end do diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 9d46b7dc89..70ff0cf63d 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -73,7 +73,7 @@ program cosp2_test implicit none ! Input/Output driver file control - character(len=256) :: cosp_input_namelist,rttov_input_namelist + character(len=256) :: cosp_input_namelist character(len=64) :: cosp_output_namelist = 'cosp2_output_nl.txt' ! Test data @@ -135,8 +135,6 @@ program cosp2_test overlap, & ! Overlap type: 1=max, 2=rand, 3=max/rand isccp_topheight, & ! ISCCP cloud top height isccp_topheight_direction, & ! ISCCP cloud top height direction -! rttov_Ninstruments, & ! RTTOV: Number of instruments to simulate - rttov_Nchannels, & ! RTTOV: Number of channels to be computed rttov_Nlocaltime ! RTTOV: Number of local times to be computed integer :: rttov_Ninstruments = 0 real(wp) :: & ! @@ -147,6 +145,7 @@ program cosp2_test csat_vgrid, & ! CloudSat vertical grid? use_precipitation_fluxes ! True if precipitation fluxes are input to the ! algorithm + logical :: Lrttov_localtime = .false. real(wp),dimension(10) :: & ! JKS - reasonable limit at 10 rttov_localtime, & ! RTTOV subsetting by local time in hours [0,24] rttov_localtimewindow ! Width of local time window (hrs). @@ -160,17 +159,15 @@ program cosp2_test dinput ! Directory where the input files are located character(len=600) :: & fileIN ! dinput+finput - type(character(len=256)), allocatable, dimension(:) :: & + type(character(len=128)), allocatable, dimension(:) :: & rttov_instrument_namelists ! Array of paths to RTTOV instrument namelists -! type(integer), allocatable, dimension(:) :: & -! rttov_instrument_Nchannels namelist/COSP_INPUT/overlap, isccp_topheight, isccp_topheight_direction, npoints, & npoints_it, ncolumns, nlevels, use_vgrid, Nlvgrid, csat_vgrid, dinput, finput, & foutput, cloudsat_radar_freq, surface_radar, cloudsat_use_gas_abs,cloudsat_do_ray,& cloudsat_k2, cloudsat_micro_scheme, lidar_ice_type, use_precipitation_fluxes, & - rttov_Nchannels, rttov_Nlocaltime, rttov_localtime, rttov_localtimewindow, & - rttov_Ninstruments,rttov_instrument_namelists + rttov_Ninstruments, rttov_instrument_namelists, & + Lrttov_localtime, rttov_Nlocaltime, rttov_localtime, rttov_localtimewindow ! Output namelist logical :: Lcfaddbze94,Ldbze94,Latb532,LcfadLidarsr532,Lclcalipso,Lclhcalipso, & @@ -196,15 +193,6 @@ program cosp2_test Lptradarflag9,Lradarpia, & Lwr_occfreq,Lcfodd logical :: Lrttov_run = .false. - logical :: Lrttov_bt = .false. - logical :: Lrttov_rad = .false. - logical :: Lrttov_refl = .false. - logical :: Lrttov_cld = .false. - logical :: Lrttov_cldparam = .false. - logical :: Lrttov_aer = .false. - logical :: Lrttov_aerparam = .false. - logical :: Lrttov_localtime = .false. - logical :: Lrttov_pc = .false. namelist/COSP_OUTPUT/Lcfaddbze94,Ldbze94,Latb532,LcfadLidarsr532,Lclcalipso, & Lclhcalipso,Lcllcalipso,Lclmcalipso,Lcltcalipso,LparasolRefl, & Lclcalipsoliq,Lclcalipsoice,Lclcalipsoun,Lclcalipsotmp, & @@ -228,9 +216,6 @@ program cosp2_test Ltautlogmodis,Ltauwlogmodis,Ltauilogmodis,Lreffclwmodis, & Lreffclimodis,Lpctmodis,Llwpmodis,Liwpmodis,Lclmodis, & Lrttov_run, & - Lrttov_bt, Lrttov_rad, Lrttov_refl, & ! RTTOV output fields - Lrttov_cld, Lrttov_cldparam,Lrttov_aer, Lrttov_aerparam, & ! RTTOV cld/aero - Lrttov_localtime,Lrttov_pc, & ! RTTOV other Lptradarflag0,Lptradarflag1,Lptradarflag2,Lptradarflag3, & Lptradarflag4,Lptradarflag5,Lptradarflag6,Lptradarflag7, & Lptradarflag8,Lptradarflag9,Lradarpia, & @@ -314,15 +299,6 @@ program cosp2_test open(10,file=cosp_output_namelist,status='unknown') read(10,nml=cosp_output) close(10) - - ! Save the path for the RTTOV input namelist to read later - ! Because cosp2_test is an outer program, rttov_input_name cannot be optional. - ! I use this solution, which isn't great but works. - if (command_argument_count() .ge. 3) then - call get_command_argument(3, rttov_input_namelist) - else - rttov_input_namelist = 'false' - endif ! Jonah namelist checking area print*,'Lrttov_run: ',Lrttov_run @@ -388,7 +364,7 @@ program cosp2_test Lclthinmeanzse .or. Lclzopaquecalipsose) Lcalipso = .true. if (LlidarBetaMol532gr .or. LcfadLidarsr532gr .or. Latb532gr .or. LclgrLidar532 .or. & - LclhgrLidar532 .or. LcllgrLidar532 .or. LclmgrLidar532 .or. LcltgrLidar532) & + LclhgrLidar532 .or. LcllgrLidar532 .or. LclmgrLidar532 .or. LcltgrLidar532) & LgrLidar532 = .true. if (LlidarBetaMol355 .or. LcfadLidarsr355 .or. Latb355 .or. Lclatlid .or. & @@ -404,19 +380,16 @@ program cosp2_test if (Lparasolrefl) Lparasol = .true. ! JKS - This will need to be revamped. Each instrument needs these flags - if ((Lrttov_bt .or. Lrttov_rad .or. Lrttov_refl) .and. (rttov_input_namelist /= 'false')) Lrttov = .true. - if ((Lrttov_bt .or. Lrttov_rad .or. Lrttov_refl) .and. (rttov_input_namelist .eq. 'false')) then - print*,'An RTTOV output must be true and a RTTOV namelist must be provided to run RTTOV.' - Lrttov = .false. - Lrttov_bt = .false. - Lrttov_rad = .false. - Lrttov_refl = .false. + if (Lrttov_run .and. (rttov_Ninstruments .gt. 0)) Lrttov = .true. + if ((Lrttov_run) .and. (rttov_Ninstruments .le. 0)) then + print*,'Lrttov_run is "true" but rttov_Ninstruments < 1. COSP-RTTOV will not run.' + Lrttov = .false. endif - if (Lrttov_pc) then - Lrttov_refl = .false. ! PC-RTTOV does not do reflectances - Lrttov_cld = .false. ! PC-RTTOV does not do aerosols - Lrttov_aer = .false. ! PC-RTTOV does not do clouds + if ((Lrttov_run .eq. .false.) .and. (rttov_Ninstruments .gt. 0)) then + print*,'rttov_Ninstruments > 0 but Lrttov_run is "false". COSP-RTTOV will not run.' + Lrttov = .false. endif + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1443,7 +1416,7 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& ! RTTOV - Allocate output for multiple instruments ! Do I not need to allocate the number of instruments? Because each rttov output DDT will be a pointer? - if (N_rttov_instruments .gt. 0) then + if ((N_rttov_instruments .gt. 0) .and. (Lrttov)) then x % N_rttov_instruments = N_rttov_instruments allocate(x % rttov_outputs(N_rttov_instruments)) ! Need to allocate a pointer? do i=1,N_rttov_instruments @@ -1452,10 +1425,8 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& print*,'rttov_configs(i) % Lrttov_bt: ',rttov_configs(i) % Lrttov_bt print*,'rttov_configs(i) % Lrttov_rad: ',rttov_configs(i) % Lrttov_rad print*,'rttov_configs(i) % Lrttov_refl: ',rttov_configs(i) % Lrttov_refl - print*,'rttov_configs(i) % opts % rt_ir % addaerosl: ',rttov_configs(i) % opts % rt_ir % addaerosl - print*,'rttov_configs(i) % opts % rt_ir % addclouds: ',rttov_configs(i) % opts % rt_ir % addclouds - print*,'rttov_configs(i) % opts % rt_ir % user_aer_opt_param: ',rttov_configs(i) % opts % rt_ir % user_aer_opt_param - print*,'rttov_configs(i) % opts % rt_ir % user_cld_opt_param: ',rttov_configs(i) % opts % rt_ir % user_cld_opt_param + print*,'rttov_configs(i) % Lrttov_cld: ',rttov_configs(i) % Lrttov_cld + print*,'rttov_configs(i) % Lrttov_aer: ',rttov_configs(i) % Lrttov_aer print*,'rttov_configs(i) % Lrttov_pc: ',rttov_configs(i) % Lrttov_pc print*,'1.' @@ -1477,22 +1448,22 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& allocate(x % rttov_outputs(i) % channel_indices(rttov_configs(i) % nchan_out)) if (rttov_configs(i) % Lrttov_bt) then ! Brightness temp allocate(x % rttov_outputs(i) % bt_total(Npoints,rttov_configs(i) % nchan_out)) - if ((rttov_configs(i) % opts % rt_ir % addclouds) .or. (rttov_configs(i) % opts % rt_ir % addaerosl)) then + if ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer)) then allocate(x % rttov_outputs(i) % bt_clear(Npoints,rttov_configs(i) % nchan_out)) end if end if if (rttov_configs(i) % Lrttov_rad) then ! Radiance allocate(x % rttov_outputs(i) % rad_total(Npoints,rttov_configs(i) % nchan_out)) - if ((rttov_configs(i) % opts % rt_ir % addclouds) .or. (rttov_configs(i) % opts % rt_ir % addaerosl)) then + if ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer)) then allocate(x % rttov_outputs(i) % rad_clear(Npoints,rttov_configs(i) % nchan_out)) end if - if ((rttov_configs(i) % opts % rt_ir % addclouds) .or. (rttov_configs(i) % opts % rt_ir % addaerosl)) then + if ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer)) then allocate(x % rttov_outputs(i) % rad_cloudy(Npoints,rttov_configs(i) % nchan_out)) end if end if if (rttov_configs(i) % Lrttov_refl) then ! Reflectance allocate(x % rttov_outputs(i) % refl_total(Npoints,rttov_configs(i) % nchan_out)) - if ((rttov_configs(i) % opts % rt_ir % addclouds) .or. (rttov_configs(i) % opts % rt_ir % addaerosl)) then + if ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer)) then allocate(x % rttov_outputs(i) % refl_clear(Npoints,rttov_configs(i) % nchan_out)) end if end if diff --git a/src/cosp.F90 b/src/cosp.F90 index ab8ca6c643..b95ccb4de9 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -53,7 +53,7 @@ MODULE MOD_COSP USE MOD_COSP_MODIS_INTERFACE, ONLY: cosp_modis_init, modis_IN USE MOD_COSP_RTTOV_INTERFACE, ONLY: & COSP_RTTOV_INIT, & - cosp_rttov_simulate_mi, & + cosp_rttov_simulate, & rttov_cfg, & rttov_output USE MOD_COSP_MISR_INTERFACE, ONLY: cosp_misr_init, misr_IN @@ -360,7 +360,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) Lcloudsat_column, & ! On/Off switch for column CLOUDSAT simulator Lmodis_column, & ! On/Off switch for column MODIS simulator Lrttov_column, & ! On/Off switch for column RTTOV simulator -! Lrttov_pc, & ! On/Off switch for PC-RTTOV simulator Lradar_lidar_tcc, & ! On/Off switch from joint Calipso/Cloudsat product Lcloudsat_tcc, & ! Lcloudsat_tcc2, & ! @@ -448,7 +447,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) Lcloudsat_column = .false. Lmodis_column = .false. Lrttov_column = .false. -! Lrttov_pc = .false. Lradar_lidar_tcc = .false. Llidar_only_freq_cloud = .false. Lcloudsat_tcc = .false. @@ -1544,10 +1542,8 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) print*,'cospIN % cfg_rttov(i) % nchan_out: ',cospIN % cfg_rttov(i) % nchan_out ! issue here allocate(rttov_Ichannel(cospIN % cfg_rttov(i) % nchan_out)) ! Channel indices if (cospIN % cfg_rttov(i) % Lrttov_pc) then - allocate(rttov_bt_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp - allocate(rttov_rad_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky radiance - ! allocate(rttov_bt_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky brightness temp - ! allocate(rttov_rad_clear(rttovIN%Npoints,rttovIN%Nchannels)) ! clear-sky radiance + allocate(rttov_bt_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp + allocate(rttov_rad_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky radiance else allocate(rttov_bt_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp allocate(rttov_bt_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! clear-sky brightness temp @@ -1560,7 +1556,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) call cpu_time(driver_time(3)) ! Run simulator - call cosp_rttov_simulate_mi(rttovIN,cospIN%cfg_rttov(i),Lrttov_cleanUp, & ! Inputs + call cosp_rttov_simulate(rttovIN,cospIN%cfg_rttov(i),Lrttov_cleanUp, & ! Inputs rttov_bt_total,rttov_bt_clear, & ! Brightness Temp Outputs rttov_rad_total,rttov_rad_clear,rttov_rad_cloudy, & ! Radiance Outputs rttov_refl_total,rttov_refl_clear, & ! Reflectance Outputs @@ -1573,9 +1569,9 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospOUT % rttov_outputs(i) % channel_indices(:) = cospIN % cfg_rttov(i) % iChannel if (cospIN % cfg_rttov(i) % Lrttov_pc) then if (associated(cospOUT % rttov_outputs(i) % bt_total_pc)) & - cospOUT % rttov_outputs(i) % bt_total_pc(ij:ik,:) = rttov_bt_total + cospOUT % rttov_outputs(i) % bt_total_pc(ij:ik,:) = rttov_bt_clear if (associated(cospOUT % rttov_outputs(i) % rad_total_pc)) & - cospOUT % rttov_outputs(i) % rad_total_pc(ij:ik,:) = rttov_rad_total + cospOUT % rttov_outputs(i) % rad_total_pc(ij:ik,:) = rttov_rad_clear else if (associated(cospOUT % rttov_outputs(i) % bt_total)) & cospOUT % rttov_outputs(i) % bt_total(ij:ik,:) = rttov_bt_total @@ -1832,7 +1828,8 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La rttov_Ninstruments, rttov_instrument_namelists,rttov_configs) ! INPUTS - logical,intent(in) :: Lisccp,Lmodis,Lmisr,Lcloudsat,Lcalipso,LgrLidar532,Latlid,Lparasol,Lrttov + logical,intent(in) :: Lisccp,Lmodis,Lmisr,Lcloudsat,Lcalipso,LgrLidar532,Latlid,Lparasol + logical,intent(inout) :: Lrttov integer,intent(in) :: & cloudsat_use_gas_abs, & ! cloudsat_do_ray, & ! @@ -1853,7 +1850,7 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La cloudsat_micro_scheme ! Microphysical scheme used by CLOUDSAT real(wp),dimension(10) :: driver_time - type(character(len=256)), dimension(rttov_Ninstruments) :: & + type(character(len=128)), dimension(rttov_Ninstruments) :: & rttov_instrument_namelists ! Array of paths to RTTOV instrument namelists ! OUTPUTS @@ -1908,8 +1905,8 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La ! Could print diagnostic on timing here. if (Lrttov) then call cpu_time(driver_time(1)) - call cosp_rttov_init(Nlevels,rttov_Ninstruments, & - rttov_instrument_namelists, & + call cosp_rttov_init(Lrttov,Nlevels,rttov_Ninstruments, & + rttov_instrument_namelists, & rttov_configs) call cpu_time(driver_time(2)) diff --git a/src/simulator/cosp_rttov_interfaceSTUB.F90 b/src/simulator/cosp_rttov_interfaceSTUB.F90 index 6ea698c5ff..a375d3f817 100644 --- a/src/simulator/cosp_rttov_interfaceSTUB.F90 +++ b/src/simulator/cosp_rttov_interfaceSTUB.F90 @@ -39,24 +39,62 @@ MODULE MOD_COSP_RTTOV_INTERFACE ! DDT for each instrument being simulated. Values to be assigned during the cosp_rttov_init subroutine type rttov_cfg - logical :: & + logical :: & Lrttov_bt, & Lrttov_rad, & Lrttov_refl, & Lrttov_cld, & Lrttov_aer, & - Lrttov_cldparam, & - Lrttov_aerparam, & Lrttov_pc - character(len=256) :: & + character(len=256) :: & rttov_srcDir, & rttov_coefDir, & OD_coef_filepath, & aer_coef_filepath, & cld_coef_filepath, & PC_coef_filepath + integer :: & + nchanprof, & + rttov_direct_nthreads + integer :: & + nchan_out, & + nchannels_rec + real(wp) :: & + CO2_mr, & + CH4_mr, & + CO_mr, & + N2O_mr, & + SO2_mr, & + ZenAng + integer,allocatable :: & + iChannel(:), & ! Requested channel indices + iChannel_out(:) ! Passing out the channel indices (actual output channels) + real(kind=wp),allocatable :: & + emisChannel(:), & ! RTTOV channel emissivity + reflChannel(:) ! RTTOV channel reflectivity +! type(rttov_options) :: & +! opts ! RTTOV options structure +! type(rttov_coefs) :: & +! coefs ! RTTOV coefficients structure end type rttov_cfg + type rttov_output + integer :: & + nchan_out + integer,pointer :: & + channel_indices(:) + real(wp),pointer :: & + bt_total(:,:), & + bt_clear(:,:), & + rad_total(:,:), & + rad_clear(:,:), & + rad_cloudy(:,:), & + refl_total(:,:), & + refl_clear(:,:), & + bt_total_pc(:,:), & + rad_total_pc(:,:) + end type rttov_output + CONTAINS @@ -81,71 +119,58 @@ END SUBROUTINE COSP_RTTOV_INI2 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_init !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_INIT(NchanIN,nlevels,Lrttov_bt,Lrttov_rad,Lrttov_refl, & - Lrttov_cld,Lrttov_aer,Lrttov_cldparam,Lrttov_aerparam, & - Lrttov_pc,rttov_input_namelist,rttov_pc_nchan) - integer,intent(in) :: & - NchanIN, & - nlevels -! integer,intent(in),dimension(RTTOV_MAX_CHANNELS) :: & -! channelsIN ! RTTOV channels - logical,intent(in) :: & - Lrttov_bt, & - Lrttov_rad, & - Lrttov_refl, & - Lrttov_cld, & - Lrttov_aer, & - Lrttov_cldparam, & - Lrttov_aerparam, & - Lrttov_pc - - ! JKS testing using a RTTOV input namelist here - ! (default cosp_rttov namelist is set in cosp.F90) - character(len=256),intent(in) :: rttov_input_namelist + SUBROUTINE COSP_RTTOV_INIT(Lrttov,Nlevels,Ninstruments,instrument_namelists, & + rttov_configs) - integer,intent(inout),optional :: & ! JKS return number of channels determined by ipcreg - rttov_pc_nchan - - print*,'Running COSP_RTTOV_INIT from STUB files.', & + logical,intent(inout) :: & + Lrttov + integer,intent(in) :: & + Nlevels, & + Ninstruments + type(character(len=128)), dimension(Ninstruments) :: & + instrument_namelists ! Array of paths to RTTOV instrument namelists + type(rttov_cfg), dimension(:), allocatable :: & ! intent(out)? + rttov_configs + + Lrttov = .false. + + print*,'Running COSP_RTTOV_INIT from STUB files.', & 'To run RTTOV, compile COSP after setting environmental variable "RTTOV"' - + END SUBROUTINE COSP_RTTOV_INIT - + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_simulate - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,lCleanup, & ! Inputs - iChannel_ret, & ! Channel index outputs + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & ! Inputs bt_total,bt_clear, & ! Brightness Temp Outputs rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs refl_total,refl_clear, & ! Reflectance Outputs - error) - - type(rttov_in),intent(in) :: & - rttovIN - logical,intent(in) :: & - lCleanup ! Flag to determine whether to deallocate RTTOV types - integer,intent(inout),dimension(rttovIN%nChannels) :: & - iChannel_ret - real(wp),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! - bt_total, & ! All-sky - bt_clear, & ! Clear-sky - rad_total, & ! All-sky - rad_clear, & ! Clear-sky - rad_cloudy, & ! Cloudy-sky - refl_total, & ! All-sky - refl_clear ! Clear-sky - character(len=128) :: & - error ! Error messages (only populated if error encountered) - - - print*,'Running COSP_RTTOV_SIMULATE from STUB files.', & + error) + + type(rttov_in),intent(in) :: & + rttovIN + type(rttov_cfg),intent(inout) :: & + rttovConfig + logical,intent(in) :: & + lCleanup ! Flag to determine whether to deallocate RTTOV types + real(wp),intent(inout),dimension(rttovIN%nPoints,rttovConfig%nchan_out) :: & ! Can I do this? I guess so! + bt_total, & ! All-sky + bt_clear, & ! Clear-sky + rad_total, & ! All-sky + rad_clear, & ! Clear-sky + rad_cloudy, & ! Cloudy-sky + refl_total, & ! All-sky + refl_clear ! Clear-sky + character(len=128) :: & + error ! Error messages (only populated if error encountered) + + print*,'Running COSP_RTTOV_SIMULATE from STUB files.', & 'To run RTTOV, compile COSP after setting environmental variable "RTTOV"' - ! How do I want the interface to function? How should it to be consistent with the rest of COSP? - + ! How do I want the interface to function? How should it to be consistent with the rest of COSP? + END SUBROUTINE COSP_RTTOV_SIMULATE - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_pc_rttov_simulate !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index cdd80e9600..a1732972a6 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -71,6 +71,8 @@ MODULE MOD_COSP_RTTOV_INTERFACE Lrttov_bt, & Lrttov_rad, & Lrttov_refl, & + Lrttov_cld, & + Lrttov_aer, & Lrttov_pc character(len=256) :: & rttov_srcDir, & @@ -95,7 +97,7 @@ MODULE MOD_COSP_RTTOV_INTERFACE integer(kind=jpim), allocatable :: & iChannel(:), & ! Requested channel indices iChannel_out(:) ! Passing out the channel indices (actual output channels) - real(kind=jplm),allocatable :: & + real(kind=jprb),allocatable :: & emisChannel(:), & ! RTTOV channel emissivity reflChannel(:) ! RTTOV channel reflectivity type(rttov_options) :: & @@ -127,13 +129,15 @@ MODULE MOD_COSP_RTTOV_INTERFACE !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_init !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_INIT(Nlevels,Ninstruments,instrument_namelists, & + SUBROUTINE COSP_RTTOV_INIT(Lrttov, Nlevels,Ninstruments,instrument_namelists, & rttov_configs) + logical,intent(in) :: & + Lrttov integer,intent(in) :: & Nlevels, & Ninstruments - type(character(len=256)), dimension(Ninstruments) :: & + type(character(len=128)), dimension(Ninstruments) :: & instrument_namelists ! Array of paths to RTTOV instrument namelists type(rttov_cfg), dimension(:), allocatable :: & ! intent(out)? rttov_configs @@ -146,7 +150,6 @@ SUBROUTINE COSP_RTTOV_INIT(Nlevels,Ninstruments,instrument_namelists, & ! Create config objects for each instrument to be simulated by RTTOV. Return to the main subroutine. do inst_idx=1,Ninstruments print*,'inst_idx: ',inst_idx - print*,'Nlevels: ',Nlevels print*,'instrument_namelists(inst_idx): ',instrument_namelists(inst_idx) ! print*,'kind(rttov_configs(inst_idx)): ',kind(rttov_configs(inst_idx)) ! print*,'rttov_configs(inst_idx): ',rttov_configs(inst_idx) @@ -164,7 +167,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & integer,intent(in) :: & Nlevels - character(len=256),intent(in) :: & + character(len=128),intent(in) :: & namelist_filepath ! Array of paths to RTTOV instrument namelists type(rttov_cfg),intent(out) :: & ! intent(out)? rttov_config @@ -197,7 +200,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & logical :: Lrttov_aerparam = .false. logical :: Lrttov_pc = .false. - logical :: Lchannel_filepath2 = .false. + logical :: Lchannel_filepath = .false. logical :: SO2_data = .false. logical :: N2O_data = .false. @@ -210,7 +213,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & character(len=256) :: cosp_status integer :: & i, & - nchannels_rec2 + nchannels_rec integer, target :: & rttov_nthreads @@ -223,7 +226,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & ! Read RTTOV namelist fields namelist/RTTOV_INPUT/Lrttov_bt,Lrttov_rad,Lrttov_refl,Lrttov_cld, & ! Logicals for RTTOV configuration Lrttov_aer,Lrttov_cldparam,Lrttov_aerparam, & ! - Lrttov_pc,nchannels_rec2,Lchannel_filepath2, & + Lrttov_pc,nchannels_rec,Lchannel_filepath, & channel_filepath,rttov_srcDir,rttov_coefDir, & OD_coef_filepath,aer_coef_filepath,cld_coef_filepath, & PC_coef_filepath, & @@ -320,6 +323,9 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & rttov_config % opts % rt_ir % ir_sea_emis_model = 2 ! User options - JKS + ! Duplicate for STUB functionality + rttov_config % Lrttov_aer = Lrttov_aer + rttov_config % Lrttov_cld = Lrttov_cld rttov_config % opts % rt_ir % addaerosl = Lrttov_aer rttov_config % opts % rt_ir % addclouds = Lrttov_cld rttov_config % opts % rt_ir % user_aer_opt_param = Lrttov_aerparam ! User specifies the aerosol scattering optical parameters @@ -402,9 +408,9 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & file_sccld=rttov_config % cld_coef_filepath) ! Ensure input number of channels is not higher than number stored in coefficient file - if (nchannels_rec2 > rttov_config % coefs % coef % fmv_chn) then - nchannels_rec2 = rttov_config % coefs % coef % fmv_chn - print*,'nchannels_rec2 cap hit' + if (nchannels_rec > rttov_config % coefs % coef % fmv_chn) then + nchannels_rec = rttov_config % coefs % coef % fmv_chn + print*,'nchannels_rec cap hit' endif endif @@ -424,21 +430,21 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & ! Handle different radiance reconstruction options ! JKS - I need to set these two separate variables here? Can one be set later? - if (nchannels_rec2 < 0) then - print*,'The namelist variable "nchannels_rec2" is negative, rttov_direct call will fail. Exiting.' + if (nchannels_rec < 0) then + print*,'The namelist variable "nchannels_rec" is negative, rttov_direct call will fail. Exiting.' errorstatus = errorstatus_fatal call rttov_exit(errorstatus) ! If the number of channels is negative, don't reconstruct radiances at all rttov_config % nchan_out = 0 rttov_config % nchannels_rec = 0 ! Avoid nchanprof set to a negative value - else if (nchannels_rec2 == 0) then + else if (nchannels_rec == 0) then ! If the number of channels is set to 0 then reconstruct all instrument channels rttov_config % nchan_out = rttov_config % coefs % coef % fmv_chn rttov_config % nchannels_rec = rttov_config % coefs % coef % fmv_chn ! Avoid nchanprof set to 0 else ! Otherwise read the channel list from the file - rttov_config % nchan_out = nchannels_rec2 - rttov_config % nchannels_rec = nchannels_rec2 + rttov_config % nchan_out = nchannels_rec + rttov_config % nchannels_rec = nchannels_rec endif @@ -446,7 +452,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & ! Read in channel indices, emissivities, and reflectivities from .csv if file is passed !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - if (Lchannel_filepath2) then + if (Lchannel_filepath) then allocate(rttov_config % iChannel(rttov_config % nchan_out)) allocate(rttov_config % emisChannel(rttov_config % nchan_out)) allocate(rttov_config % reflChannel(rttov_config % nchan_out)) @@ -488,7 +494,7 @@ END SUBROUTINE COSP_RTTOV_INIT_S !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_simulate - Call subroutines in mod_cosp_rttov to run RTTOV !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, & ! Inputs + SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & ! Inputs bt_total,bt_clear, & ! Brightness Temp Outputs rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs refl_total,refl_clear, & ! Reflectance Outputs @@ -514,14 +520,14 @@ SUBROUTINE COSP_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, ! Check options to determine if the principal component approach should be run if (rttovConfig % opts % rt_ir % pc % addpc) then print*,'Running COSP_PC_RTTOV_SIMULATE in multi-inst. set-up' - call COSP_PC_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, & - bt_total,rad_total, & + call COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & + bt_clear,rad_clear, & error) - print*,'end of COSP_PC_RTTOV_SIMULATE_MI' + print*,'end of COSP_PC_RTTOV_SIMULATE' else print*,'Running COSP_REG_RTTOV_SIMULATE in multi-inst. set-up' - call COSP_REG_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, & + call COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & bt_total,bt_clear, & rad_total,rad_clear,rad_cloudy, & refl_total,refl_clear, & @@ -529,25 +535,25 @@ SUBROUTINE COSP_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, endif - END SUBROUTINE COSP_RTTOV_SIMULATE_MI + END SUBROUTINE COSP_RTTOV_SIMULATE !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_simulate - Call regular subroutines in mod_cosp_rttov to run RTTOV !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_REG_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, & ! Inputs + SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & ! Inputs bt_total,bt_clear, & ! Brightness Temp Outputs rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs refl_total,refl_clear, & ! Reflectance Outputs error) use mod_cosp_rttov, only: & - cosp_rttov_allocate_mi, & - cosp_rttov_construct_profiles_mi, & + cosp_rttov_allocate, & + cosp_rttov_construct_profiles, & cosp_rttov_setup_emissivity_reflectance, & - cosp_rttov_call_direct_mi, & - cosp_rttov_save_output_mi, & - cosp_rttov_deallocate_profiles_mi, & - cosp_rttov_deallocate_coefs_mi + cosp_rttov_call_direct, & + cosp_rttov_save_output, & + cosp_rttov_deallocate_profiles, & + cosp_rttov_deallocate_coefs type(rttov_in),intent(in) :: & rttovIN @@ -571,54 +577,56 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, ! Run each step for running RTTOV from mod_cosp_rttov (and time them) print*,'cosp_rttov_allocate begin' ! jks call cpu_time(driver_time(1)) - call cosp_rttov_allocate_mi(rttovIN, & - rttovConfig % nChannels_rec, & - rttovConfig % opts, & - rttovConfig % coefs, & - rttovConfig % iChannel, & - rttovConfig % nchanprof) + call cosp_rttov_allocate(rttovIN, & + rttovConfig % nChannels_rec, & + rttovConfig % opts, & + rttovConfig % coefs, & + rttovConfig % iChannel, & + rttovConfig % nchanprof) print*,'cosp_rttov_allocate successful' ! jks call cpu_time(driver_time(2)) - call cosp_rttov_construct_profiles_mi(rttovIN, & - rttovConfig % opts % rt_ir % addclouds, & - rttovConfig % opts % rt_ir % addaerosl, & - rttovConfig % CO2_mr, & - rttovConfig % CH4_mr, & - rttovConfig % CO_mr, & - rttovConfig % N2O_mr, & - rttovConfig % SO2_mr, & - rttovConfig % ZenAng) + call cosp_rttov_construct_profiles(rttovIN, & + rttovConfig % Lrttov_cld, & + rttovConfig % Lrttov_aer, & +! rttovConfig % opts % rt_ir % addclouds, & +! rttovConfig % opts % rt_ir % addaerosl, & + rttovConfig % CO2_mr, & + rttovConfig % CH4_mr, & + rttovConfig % CO_mr, & + rttovConfig % N2O_mr, & + rttovConfig % SO2_mr, & + rttovConfig % ZenAng) - print*,'cosp_rttov_construct_profiles_mi successful' ! jks + print*,'cosp_rttov_construct_profiles successful' ! jks call cpu_time(driver_time(3)) call cosp_rttov_setup_emissivity_reflectance() ! Config agnostic after allocate step. print*,'cosp_rttov_setup_emissivity_reflectance successful' ! jks call cpu_time(driver_time(4)) - call cosp_rttov_call_direct_mi(rttovConfig % rttov_direct_nthreads, & - rttovConfig % opts, & - rttovConfig % coefs) + call cosp_rttov_call_direct(rttovConfig % rttov_direct_nthreads, & + rttovConfig % opts, & + rttovConfig % coefs) print*,'cosp_rttov_call_direct successful' ! jks call cpu_time(driver_time(5)) - call cosp_rttov_save_output_mi(rttovIN, & + call cosp_rttov_save_output(rttovIN, & rttovConfig % nchan_out, & rttovConfig % Lrttov_bt, & rttovConfig % Lrttov_rad, & rttovConfig % Lrttov_refl, & - rttovConfig % opts % rt_ir % addclouds, & - rttovConfig % opts % rt_ir % addaerosl, & + rttovConfig % Lrttov_cld, & + rttovConfig % Lrttov_aer, & bt_total,bt_clear, & rad_total,rad_clear,rad_cloudy, & refl_total,refl_clear) print*,'cosp_rttov_save_output successful' ! jks call cpu_time(driver_time(6)) - call cosp_rttov_deallocate_profiles_mi(rttovIN, & - rttovConfig % opts, & - rttovConfig % coefs, & - rttovConfig % nchanprof) + call cosp_rttov_deallocate_profiles(rttovIN, & + rttovConfig % opts, & + rttovConfig % coefs, & + rttovConfig % nchanprof) call cpu_time(driver_time(7)) print*,'Time to run "cosp_rttov_allocate": ', driver_time(2)-driver_time(1) @@ -631,31 +639,31 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, ! Deallocate the coefficient files if directed if (lCleanup) then call cpu_time(driver_time(8)) - call cosp_rttov_deallocate_coefs_mi(rttovConfig % coefs) + call cosp_rttov_deallocate_coefs(rttovConfig % coefs) call cpu_time(driver_time(9)) print*,'Time to run "cosp_rttov_deallocate_coefs": ',driver_time(9)-driver_time(8) endif ! print*,'Total RTTOV run time: ',driver_time(8)-driver_time(1) - END SUBROUTINE COSP_REG_RTTOV_SIMULATE_MI + END SUBROUTINE COSP_REG_RTTOV_SIMULATE !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_pc_rttov_simulate - Call subroutines in mod_cosp_rttov to run RTTOV !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_PC_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, & ! Inputs - bt_total,rad_total, & ! Outputs + SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & ! Inputs + bt_clear,rad_clear, & ! Outputs error) use mod_cosp_rttov, only: & - cosp_pc_rttov_allocate_mi, & - cosp_rttov_construct_profiles_mi, & + cosp_pc_rttov_allocate, & + cosp_rttov_construct_profiles, & cosp_pc_rttov_setup_emissivity, & - cosp_pc_rttov_call_direct_mi, & - cosp_pc_rttov_save_output_mi, & - cosp_pc_rttov_deallocate_profiles_mi, & - cosp_rttov_deallocate_coefs_mi + cosp_pc_rttov_call_direct, & + cosp_pc_rttov_save_output, & + cosp_pc_rttov_deallocate_profiles, & + cosp_rttov_deallocate_coefs type(rttov_in),intent(in) :: & rttovIN @@ -664,8 +672,8 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, logical,intent(in) :: & lCleanup ! Flag to determine whether to deallocate RTTOV types real(wp),intent(inout),dimension(rttovIN%nPoints,rttovConfig%nchan_out) :: & ! Can I do this? I guess so! - bt_total, & ! All-sky - rad_total ! All-sky + bt_clear, & ! All-sky + rad_clear ! All-sky character(len=128) :: & error ! Error messages (only populated if error encountered) @@ -674,52 +682,52 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, ! Run each step for running RTTOV from mod_cosp_rttov (and time them) ! print*,'cosp_rttov_allocate begin' ! jks call cpu_time(driver_time(1)) - call cosp_pc_rttov_allocate_mi(rttovIN, & - rttovConfig % PC_coef_filepath, & - rttovConfig % coefs, & - rttovConfig % opts, & - rttovConfig % nchannels_rec, & - rttovConfig % iChannel, & - rttovConfig % nchanprof, & - rttovConfig % iChannel_out) - print*,'cosp_pc_rttov_allocate_mi successful' ! jks + call cosp_pc_rttov_allocate(rttovIN, & + rttovConfig % PC_coef_filepath, & + rttovConfig % coefs, & + rttovConfig % opts, & + rttovConfig % nchannels_rec, & + rttovConfig % iChannel, & + rttovConfig % nchanprof, & + rttovConfig % iChannel_out) + print*,'cosp_pc_rttov_allocate successful' ! jks call cpu_time(driver_time(2)) - call cosp_rttov_construct_profiles_mi(rttovIN, & - rttovConfig % opts % rt_ir % addclouds, & - rttovConfig % opts % rt_ir % addaerosl, & - rttovConfig % CO2_mr, & - rttovConfig % CH4_mr, & - rttovConfig % CO_mr, & - rttovConfig % N2O_mr, & - rttovConfig % SO2_mr, & - rttovConfig % ZenAng) - print*,'cosp_rttov_construct_profiles_mi successful' ! jks + call cosp_rttov_construct_profiles(rttovIN, & + rttovConfig % Lrttov_cld, & + rttovConfig % Lrttov_aer, & + rttovConfig % CO2_mr, & + rttovConfig % CH4_mr, & + rttovConfig % CO_mr, & + rttovConfig % N2O_mr, & + rttovConfig % SO2_mr, & + rttovConfig % ZenAng) + print*,'cosp_rttov_construct_profiles successful' ! jks call cpu_time(driver_time(3)) call cosp_pc_rttov_setup_emissivity() print*,'cosp_pc_rttov_setup_emissivity successful' ! jks call cpu_time(driver_time(4)) - call cosp_pc_rttov_call_direct_mi(rttovConfig % rttov_direct_nthreads, & - rttovConfig % opts, & - rttovConfig % coefs, & - rttovConfig % nchannels_rec, & - rttovConfig % iChannel_out) ! iChannel_out should have been updated + call cosp_pc_rttov_call_direct(rttovConfig % rttov_direct_nthreads, & + rttovConfig % opts, & + rttovConfig % coefs, & + rttovConfig % nchannels_rec, & + rttovConfig % iChannel_out) ! iChannel_out should have been updated print*,'cosp_pc_rttov_call_direct successful' ! jks call cpu_time(driver_time(5)) - call cosp_pc_rttov_save_output_mi(rttovIN%nPoints, & - rttovConfig%nchannels_rec, & - rttovConfig%Lrttov_bt, & - rttovConfig%Lrttov_rad, & - bt_total, & - rad_total) + call cosp_pc_rttov_save_output(rttovIN%nPoints, & + rttovConfig%nchannels_rec, & + rttovConfig%Lrttov_bt, & + rttovConfig%Lrttov_rad, & + bt_clear, & + rad_clear) print*,'cosp_pc_rttov_save_output successful' ! jks call cpu_time(driver_time(6)) - call cosp_pc_rttov_deallocate_profiles_mi(rttovIN, & - rttovConfig % nChannels_rec, & - rttovConfig % opts, & - rttovConfig % coefs, & - rttovConfig % nchanprof) + call cosp_pc_rttov_deallocate_profiles(rttovIN, & + rttovConfig % nChannels_rec, & + rttovConfig % opts, & + rttovConfig % coefs, & + rttovConfig % nchanprof) call cpu_time(driver_time(7)) print*,'Time to run "cosp_pc_rttov_allocate": ', driver_time(2)-driver_time(1) @@ -732,12 +740,12 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE_MI(rttovIN,rttovConfig,lCleanup, ! Deallocate the coefficient files if directed if (lCleanup) then call cpu_time(driver_time(8)) -! call cosp_rttov_deallocate_coefs_mi(rttovConfig % coefs) ! JKS this again with PC-RTTOV... +! call cosp_rttov_deallocate_coefs(rttovConfig % coefs) ! JKS this again with PC-RTTOV... call cpu_time(driver_time(9)) print*,'Time to run "cosp_rttov_deallocate_coefs": ',driver_time(9)-driver_time(8) endif - END SUBROUTINE COSP_PC_RTTOV_SIMULATE_MI + END SUBROUTINE COSP_PC_RTTOV_SIMULATE ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! END MODULE diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index c840957ac5..40ae08be15 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -212,8 +212,8 @@ end subroutine rttov_error ! 4. Build the list of profile/channel indices in chanprof ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_rttov_allocate_mi(rttovIN,inst_nChannels_rec,inst_opts, & - inst_coefs,inst_iChannel,inst_nchanprof) + subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & + inst_coefs,inst_iChannel,inst_nchanprof) type(rttov_in),intent(in) :: & rttovIN @@ -275,7 +275,7 @@ subroutine cosp_rttov_allocate_mi(rttovIN,inst_nChannels_rec,inst_opts, & end do end do - end subroutine cosp_rttov_allocate_mi + end subroutine cosp_rttov_allocate ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE pc_rttov_allocate - Subroutine for running PC-RTTOV @@ -284,10 +284,10 @@ end subroutine cosp_rttov_allocate_mi ! 4. Build the list of profile/channel indices in chanprof ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_pc_rttov_allocate_mi(rttovIN,inst_PC_coef_filepath, & !inst_npcscores, & - inst_coefs,inst_opts, & - inst_nchannels_rec,inst_iChannel_in, & - inst_nchanprof, inst_iChannel_out) !,inst_predictindex) + subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, & !inst_npcscores, & + inst_coefs,inst_opts, & + inst_nchannels_rec,inst_iChannel_in, & + inst_nchanprof, inst_iChannel_out) !,inst_predictindex) type(rttov_in),intent(in) :: & rttovIN @@ -386,7 +386,7 @@ subroutine cosp_pc_rttov_allocate_mi(rttovIN,inst_PC_coef_filepath, & !inst_npcs chanprof(lo:hi)%chan = predictindex(:) end do - end subroutine cosp_pc_rttov_allocate_mi + end subroutine cosp_pc_rttov_allocate ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -395,15 +395,15 @@ end subroutine cosp_pc_rttov_allocate_mi ! Largely from cosp_rttov_v11.F90 file. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_rttov_construct_profiles_mi(rttovIN, & - Lrttov_cld, & - Lrttov_aer, & - inst_co2_mr, & - inst_ch4_mr, & - inst_co_mr, & - inst_n2o_mr, & - inst_so2_mr, & - inst_zenang) + subroutine cosp_rttov_construct_profiles(rttovIN, & + Lrttov_cld, & + Lrttov_aer, & + inst_co2_mr, & + inst_ch4_mr, & + inst_co_mr, & + inst_n2o_mr, & + inst_so2_mr, & + inst_zenang) type(rttov_in),intent(in) :: & ! What is the best way to do this? Should rttovIN be a module-wide DDT? Yes. rttovIN @@ -443,13 +443,7 @@ subroutine cosp_rttov_construct_profiles_mi(rttovIN, & profiles(i)%ch4(:) = inst_ch4_mr profiles(i)%so2 = inst_so2_mr ! syntax slightly different? -! profiles(i)%co2(:) = co2 -! profiles(i)%n2o(:) = n2o -! profiles(i)%co(:) = co -! profiles(i)%ch4(:) = ch4 -! profiles(i)%so2 = so2 - -! For when trace gas columns are +! For when trace gas columns are supplied ! profiles(i)%co2(:) = rttovIN%co2 ! profiles(i)%n2o(:) = rttovIN%n2o ! profiles(i)%co(:) = rttovIN%co @@ -584,7 +578,7 @@ subroutine cosp_rttov_construct_profiles_mi(rttovIN, & ! JKS To-do: set up scattering profiles (MW only) (rttov_profile_cloud) - end subroutine cosp_rttov_construct_profiles_mi + end subroutine cosp_rttov_construct_profiles ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 6. rttov_setup_emissivity_reflectance - Specify surface emissivity and reflectance @@ -631,7 +625,9 @@ end subroutine cosp_pc_rttov_setup_emissivity ! From RTTOV example files. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_rttov_call_direct_mi(inst_nthreads,inst_opts,inst_coefs) + subroutine cosp_rttov_call_direct(inst_nthreads, & + inst_opts, & + inst_coefs) integer(KIND=jpim),intent(in) :: & inst_nthreads @@ -672,7 +668,7 @@ subroutine cosp_rttov_call_direct_mi(inst_nthreads,inst_opts,inst_coefs) endif call rttov_error('rttov_direct error', lalloc = .true.) - end subroutine cosp_rttov_call_direct_mi + end subroutine cosp_rttov_call_direct ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -680,11 +676,11 @@ end subroutine cosp_rttov_call_direct_mi ! ------------------------------------------------------ ! From RTTOV example files. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_pc_rttov_call_direct_mi( & - inst_nthreads,inst_opts, & - inst_coefs, & - inst_nchannels_rec, & - inst_channels_rec) + subroutine cosp_pc_rttov_call_direct(inst_nthreads, & + inst_opts, & + inst_coefs, & + inst_nchannels_rec, & + inst_channels_rec) integer(KIND=jpim),intent(in) :: & inst_nthreads @@ -729,7 +725,7 @@ subroutine cosp_pc_rttov_call_direct_mi( & endif call rttov_error('rttov_direct error (PC-RTTOV)', lalloc = .true.) - end subroutine cosp_pc_rttov_call_direct_mi + end subroutine cosp_pc_rttov_call_direct ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 8. Save output data @@ -737,7 +733,7 @@ end subroutine cosp_pc_rttov_call_direct_mi ! JKS - Need to allow options for Tb and radiance for clear- and cloudy-skies ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_rttov_save_output_mi(rttovIN,inst_nchan_out, & ! Inputs + subroutine cosp_rttov_save_output(rttovIN,inst_nchan_out, & ! Inputs Lrttov_bt,Lrttov_rad,Lrttov_refl, & Lrttov_cld,Lrttov_aer, & bt_total,bt_clear, & @@ -795,7 +791,7 @@ subroutine cosp_rttov_save_output_mi(rttovIN,inst_nchan_out, & ! Inputs transpose(reshape(radiance%refl_clear(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) endif - end subroutine cosp_rttov_save_output_mi + end subroutine cosp_rttov_save_output ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -805,12 +801,12 @@ end subroutine cosp_rttov_save_output_mi ! PC-RTTOV only does clear-sky IR calculations (can handle aerosols, but I'll ignore that for now. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_pc_rttov_save_output_mi(nPoints, & - inst_nchannels_rec, & - Lrttov_bt, & - Lrttov_rad, & - bt_total, & - rad_total) + subroutine cosp_pc_rttov_save_output(nPoints, & + inst_nchannels_rec, & + Lrttov_bt, & + Lrttov_rad, & + bt_clear, & + rad_clear) integer,intent(in) :: & nPoints, & @@ -819,8 +815,8 @@ subroutine cosp_pc_rttov_save_output_mi(nPoints, & Lrttov_bt, & Lrttov_rad real(wp),dimension(nPoints,inst_nchannels_rec),intent(inout) :: & ! Can I do this? I guess so! - bt_total, & - rad_total + bt_clear, & + rad_clear ! print*,'shape(bt_total): ',shape(bt_total) ! print*,'shape(rad_total): ',shape(rad_total) @@ -836,16 +832,16 @@ subroutine cosp_pc_rttov_save_output_mi(nPoints, & ! Only save output if appropriate if (Lrttov_bt) then - bt_total(1:nPoints, 1:inst_nchannels_rec) = & + bt_clear(1:nPoints, 1:inst_nchannels_rec) = & transpose(reshape(pccomp%bt_pccomp(1:(inst_nchannels_rec * nPoints)), (/ inst_nchannels_rec, nPoints/) )) endif if (Lrttov_rad) then - rad_total(1:nPoints, 1:inst_nchannels_rec) = & + rad_clear(1:nPoints, 1:inst_nchannels_rec) = & transpose(reshape(pccomp%total_pccomp(1:(inst_nchannels_rec * nPoints)), (/ inst_nchannels_rec, nPoints/) )) endif - end subroutine cosp_pc_rttov_save_output_mi + end subroutine cosp_pc_rttov_save_output ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 9. Deallocate all RTTOV arrays and structures @@ -853,10 +849,10 @@ end subroutine cosp_pc_rttov_save_output_mi ! From RTTOV example files. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_rttov_deallocate_profiles_mi(rttovIN, & - inst_opts, & - inst_coefs, & - inst_nchanprof) + subroutine cosp_rttov_deallocate_profiles(rttovIN, & + inst_opts, & + inst_coefs, & + inst_nchanprof) type(rttov_in),intent(in) :: & rttovIN @@ -888,7 +884,7 @@ subroutine cosp_rttov_deallocate_profiles_mi(rttovIN, & reflectance=reflectance) call rttov_error('deallocation error for rttov_direct structures', lalloc = .true.) - end subroutine cosp_rttov_deallocate_profiles_mi + end subroutine cosp_rttov_deallocate_profiles ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 9. Deallocate all RTTOV arrays and structures (PC-RTTOV) @@ -896,11 +892,11 @@ end subroutine cosp_rttov_deallocate_profiles_mi ! From RTTOV example files. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_pc_rttov_deallocate_profiles_mi(rttovIN, & - inst_nChannels_rec, & - inst_opts, & - inst_coefs, & - inst_nchanprof) + subroutine cosp_pc_rttov_deallocate_profiles(rttovIN, & + inst_nChannels_rec, & + inst_opts, & + inst_coefs, & + inst_nchanprof) type(rttov_in),intent(in) :: & rttovIN @@ -939,9 +935,9 @@ subroutine cosp_pc_rttov_deallocate_profiles_mi(rttovIN, & pccomp=pccomp) call rttov_error('deallocation error for rttov_direct structures (PC-RTTOV)', lalloc = .true.) - end subroutine cosp_pc_rttov_deallocate_profiles_mi + end subroutine cosp_pc_rttov_deallocate_profiles - subroutine cosp_rttov_deallocate_coefs_mi(inst_coefs) + subroutine cosp_rttov_deallocate_coefs(inst_coefs) type(rttov_coefs),intent(inout) :: & inst_coefs @@ -951,7 +947,7 @@ subroutine cosp_rttov_deallocate_coefs_mi(inst_coefs) write(*,*) 'coefs deallocation error' endif - end subroutine cosp_rttov_deallocate_coefs_mi + end subroutine cosp_rttov_deallocate_coefs !########################## ! Module End From e9ad4671888788c30b8a9941671eb2d417686199 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 7 Jun 2023 13:41:46 -0600 Subject: [PATCH 062/159] new branch for CESM2.2 integration --- src/simulator/cosp_rttov_interface_v13.F90 | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index a1732972a6..9d7a662750 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -589,8 +589,6 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, call cosp_rttov_construct_profiles(rttovIN, & rttovConfig % Lrttov_cld, & rttovConfig % Lrttov_aer, & -! rttovConfig % opts % rt_ir % addclouds, & -! rttovConfig % opts % rt_ir % addaerosl, & rttovConfig % CO2_mr, & rttovConfig % CH4_mr, & rttovConfig % CO_mr, & From 6c3683d7dc393e298635020bc91c75ce362ec8a4 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Fri, 9 Jun 2023 10:32:19 -0600 Subject: [PATCH 063/159] added tag and modified instrument 2 COSP-RTTOV namelist --- driver/run/instrument_nls/cosp2_rttov_inst2.txt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/driver/run/instrument_nls/cosp2_rttov_inst2.txt b/driver/run/instrument_nls/cosp2_rttov_inst2.txt index 587f32b560..c996bb718c 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst2.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst2.txt @@ -29,8 +29,8 @@ Lrttov_bt=.true., ! Calculate RTTOV brightness temps Lrttov_rad=.true., ! Calculate RTTOV radiances Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.true., ! Calculate RTTOV all-sky + cloudy-sky values Lrttov_cldparam=.false., ! Use user input cloud optical parameters Lrttov_aerparam=.false., ! Use user input aerosol optical parameters Lrttov_pc=.false., ! Run with PC-RTTOV @@ -41,9 +41,12 @@ channel_filepath='rttov_channel_input_AIRS.csv', rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov9pred101L/rtcoef_eos_2_airs_pcrttov_compat.H5', - aer_coef_filepath='cldaer_visir/scaercoef_eos_2_airs_cams.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_airs.H5', +! OD_coef_filepath='rttov9pred101L/rtcoef_eos_2_airs_pcrttov_compat.H5', +! aer_coef_filepath='cldaer_visir/scaercoef_eos_2_airs_cams.H5', +! cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_airs.H5', + OD_coef_filepath='rttov13pred54L/rtcoef_ticfire_1_mbfiri_o3co2.dat', + aer_coef_filepath='cldaer_visir/scaercoef_ticfire_1_mbfiri_cams.dat', + cld_coef_filepath='cldaer_visir/sccldcoef_ticfire_1_mbfiri.dat', PC_coef_filepath='pc/pccoef_eos_2_airs_landsea.H5', !-------------- RTTOV Trace Gas Logicals (must match coefficient files) SO2_data=.false., From e7882e51831bccc3cba852173d9ead364b34a283 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Fri, 23 Jun 2023 14:31:41 -0600 Subject: [PATCH 064/159] Updates with multi-chunk functionality. I initially tested on small inputs where there was no need for iteration. Using the larger data that required chunking the input broke a few things that I needed to fix. --- driver/run/cosp2_input_rttov_nl.um_global.txt | 92 +++++++++++++++++++ .../run/instrument_nls/cosp2_rttov_inst1.txt | 10 +- .../run/instrument_nls/cosp2_rttov_inst2.txt | 14 +-- driver/src/cosp2_test.F90 | 51 +++++----- src/cosp.F90 | 35 ++++--- src/simulator/cosp_rttov_interface_v13.F90 | 51 ++++------ src/simulator/rttov/cosp_rttov_v13.F90 | 30 +++--- 7 files changed, 184 insertions(+), 99 deletions(-) create mode 100644 driver/run/cosp2_input_rttov_nl.um_global.txt diff --git a/driver/run/cosp2_input_rttov_nl.um_global.txt b/driver/run/cosp2_input_rttov_nl.um_global.txt new file mode 100644 index 0000000000..bc0eadd1ae --- /dev/null +++ b/driver/run/cosp2_input_rttov_nl.um_global.txt @@ -0,0 +1,92 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&COSP_INPUT + NPOINTS=1728, ! 1728,6912 + NPOINTS_IT=500,! 1000 Max number of gridpoints to be processed in one iteration + NCOLUMNS=20, ! Number of subcolumns + NLEVELS=54, ! Number of model levels + USE_VGRID=.true., ! Use fixed vertical grid for outputs? (if .true. then you need to define number of levels with Nlr) + NLVGRID=40, ! Number of levels in statistical outputs (only used if USE_VGRID=.true.) + CSAT_VGRID=.true., ! CloudSat vertical grid? (if .true. then the CloudSat standard grid is used for the outputs. + ! USE_VGRID needs also be .true.) + DINPUT='./', ! Directory where the input files are located. Useful when processing multiple files. + ! Leave blank ('') if you are using the full path in FINPUT. + FINPUT='../data/inputs/UKMO/cosp_input.um_global.nc', ! List input NetCDF files + FOUTPUT='../data/outputs/UKMO/cosp2_output.um_global.nc', + !---------------------------------------------------------------------------------- + !--------------- Inputs related to radar simulations + !---------------------------------------------------------------------------------- + cloudsat_RADAR_FREQ=94.0, ! CloudSat radar frequency (GHz) + SURFACE_RADAR=0, ! surface=1, spaceborne=0 + cloudsat_use_gas_abs=1, ! include gaseous absorption? yes=1,no=0 + cloudsat_do_ray=0, ! calculate/output Rayleigh refl=1, not=0 + cloudsat_k2=-1, ! |K|^2, -1=use frequency dependent default + use_precipitation_fluxes=.true., ! True if precipitation fluxes are input to the algorithm + cloudsat_micro_scheme='MMF_v3_single_moment', !'MMF_v3.5_two_moment' + !---------------------------------------------------------------------------------- + !---------------- Inputs related to lidar simulations + !---------------------------------------------------------------------------------- + lidar_ice_type=0, ! Ice particle shape in lidar calculations (0=ice-spheres ; 1=ice-non-spherical) + OVERLAP=3, ! overlap assumption used by scops: 1=max, 2=rand, 3=max/rand + !---------------------------------------------------------------------------------- + !---------------- Inputs related to ISCCP simulator + !---------------------------------------------------------------------------------- + ISCCP_TOPHEIGHT=1, ! 1 = adjust top height using both a computed + ! infrared brightness temperature and the visible + ! optical depth to adjust cloud top pressure. Note + ! that this calculation is most appropriate to compare + ! to ISCCP data during sunlit hours. + ! 2 = do not adjust top height, that is cloud top + ! pressure is the actual cloud top pressure + ! in the model + ! 3 = adjust top height using only the computed + ! infrared brightness temperature. Note that this + ! calculation is most appropriate to compare to ISCCP + ! IR only algortihm (i.e. you can compare to nighttime + ! ISCCP data with this option) + ISCCP_TOPHEIGHT_DIRECTION=2, ! direction for finding atmosphere pressure level + ! with interpolated temperature equal to the radiance + ! determined cloud-top temperature + ! 1 = find the *lowest* altitude (highest pressure) level + ! with interpolated temperature equal to the radiance + ! determined cloud-top temperature + ! 2 = find the *highest* altitude (lowest pressure) level + ! with interpolated temperature equal to the radiance + ! determined cloud-top temperature. This is the + ! default value since V4.0 of the ISCCP simulator. + ! ONLY APPLICABLE IF top_height EQUALS 1 or 3 + !---------------------------------------------------------------------------------- + !-------------- RTTOV inputs + !---------------------------------------------------------------------------------- + rttov_Ninstruments=3, +! rttov_instrument_namelists = (/'test1','test2','test3'/), +! rttov_instrument_namelists(1:3) = (/'test1','test2','test3'/), + Lrttov_localtime=.false., ! May not be necessary at this level + rttov_Nlocaltime=2, + rttov_localtime=10.0,13.0, ! To implement local time + rttov_localtimewindow=1.0,1.0, ! To implement local time width +/ diff --git a/driver/run/instrument_nls/cosp2_rttov_inst1.txt b/driver/run/instrument_nls/cosp2_rttov_inst1.txt index 0e16f5691b..6676db2ce3 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst1.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst1.txt @@ -41,9 +41,13 @@ channel_filepath='rttov_channel_input_AIRS.csv', rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov9pred101L/rtcoef_eos_2_airs_pcrttov_compat.H5', - aer_coef_filepath='cldaer_visir/scaercoef_eos_2_airs_cams.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_airs.H5', + + OD_coef_filepath='rttov13pred54L/rtcoef_eos_2_modis-shifted_7gas.dat', + aer_coef_filepath='cldaer_visir/scaercoef_eos_2_modis-shifted_cams.dat', + cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_modis-shifted.dat', +! OD_coef_filepath='rttov9pred101L/rtcoef_eos_2_airs_pcrttov_compat.H5', +! aer_coef_filepath='cldaer_visir/scaercoef_eos_2_airs_cams.H5', +! cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_airs.H5', PC_coef_filepath='pc/pccoef_eos_2_airs_landsea.H5', !-------------- RTTOV Trace Gas Logicals (must match coefficient files) SO2_data=.false., diff --git a/driver/run/instrument_nls/cosp2_rttov_inst2.txt b/driver/run/instrument_nls/cosp2_rttov_inst2.txt index c996bb718c..6b4bd64c3a 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst2.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst2.txt @@ -35,18 +35,18 @@ Lrttov_aerparam=.false., ! Use user input aerosol optical parameters Lrttov_pc=.false., ! Run with PC-RTTOV !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=500, ! 2300 + nchannels_rec=0, ! do all !-------------- RTTOV Filepaths Lchannel_filepath=.false., channel_filepath='rttov_channel_input_AIRS.csv', rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', rttov_coefDir='rtcoef_rttov13/', -! OD_coef_filepath='rttov9pred101L/rtcoef_eos_2_airs_pcrttov_compat.H5', -! aer_coef_filepath='cldaer_visir/scaercoef_eos_2_airs_cams.H5', -! cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_airs.H5', - OD_coef_filepath='rttov13pred54L/rtcoef_ticfire_1_mbfiri_o3co2.dat', - aer_coef_filepath='cldaer_visir/scaercoef_ticfire_1_mbfiri_cams.dat', - cld_coef_filepath='cldaer_visir/sccldcoef_ticfire_1_mbfiri.dat', + OD_coef_filepath='rttov9pred101L/rtcoef_eos_2_airs_pcrttov_compat.H5', + aer_coef_filepath='cldaer_visir/scaercoef_eos_2_airs_cams.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_airs.H5', +! OD_coef_filepath='rttov13pred54L/rtcoef_ticfire_1_mbfiri_o3co2.dat', +! aer_coef_filepath='cldaer_visir/scaercoef_ticfire_1_mbfiri_cams.dat', +! cld_coef_filepath='cldaer_visir/sccldcoef_ticfire_1_mbfiri.dat', PC_coef_filepath='pc/pccoef_eos_2_airs_landsea.H5', !-------------- RTTOV Trace Gas Logicals (must match coefficient files) SO2_data=.false., diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 70ff0cf63d..5b204e9c63 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -518,25 +518,30 @@ program cosp2_test ! Assign RTTOV values ! Keeping these structures since refl and emis could come from model input cospstateIN%emis_sfc = 0._wp - cospstateIN%refl_sfc = 0._wp + cospstateIN%refl_sfc = 0._wp ! Well-mixed gases are not in COSP offline input - ! Moved user input of well-mixed gases to cosp2_rttov_nl + ! Moved user input of well-mixed gases to instrument namelists ! Keeping these structures since gases could come from model input - cospstateIN%co2 = 0._wp - cospstateIN%ch4 = 0._wp - cospstateIN%n2o = 0._wp - cospstateIN%co = 0._wp - + cospstateIN%co2(:) = 0._wp + cospstateIN%ch4(:) = 0._wp + cospstateIN%n2o(:) = 0._wp + cospstateIN%co(:) = 0._wp + +! cospstateIN%co2 = 0._wp +! cospstateIN%ch4 = 0._wp +! cospstateIN%n2o = 0._wp +! cospstateIN%co = 0._wp + ! From the data input file - cospstateIN%u_sfc = u_wind - cospstateIN%v_sfc = v_wind - cospstateIN%lat = lat - cospstateIN%lon = lon - + cospstateIN%u_sfc = u_wind(start_idx:end_idx) + cospstateIN%v_sfc = v_wind(start_idx:end_idx) + cospstateIN%lat = lat(start_idx:end_idx) + cospstateIN%lon = lon(start_idx:end_idx) + cospstateIN%o3 = mr_ozone(start_idx:end_idx,Nlevels:1:-1) cospstateIN%tca = tca(start_idx:end_idx,Nlevels:1:-1) - + ! Combine large-scale and convective cloud mixing ratios for RTTOV cospstateIN%cloudIce = mr_lsice(start_idx:end_idx,Nlevels:1:-1) + mr_ccice(start_idx:end_idx,Nlevels:1:-1) cospstateIN%cloudLiq = mr_lsliq(start_idx:end_idx,Nlevels:1:-1) + mr_ccliq(start_idx:end_idx,Nlevels:1:-1) @@ -546,11 +551,10 @@ program cosp2_test cospstateIN%fl_rain = fl_lsrain(start_idx:end_idx,Nlevels:1:-1) + fl_ccrain(start_idx:end_idx,Nlevels:1:-1) cospstateIN%fl_snow = fl_lssnow(start_idx:end_idx,Nlevels:1:-1) + fl_ccsnow(start_idx:end_idx,Nlevels:1:-1) + & fl_lsgrpl(start_idx:end_idx,Nlevels:1:-1) - + ! Inputs not supplied in the UKMO test data - cospstateIN%seaice(1:nPoints) = 0._wp - cospstateIN%month = 0 - + cospstateIN%seaice(:) = 0._wp + cospstateIN%month = 0 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Generate subcolumns and compute optical inputs. @@ -568,10 +572,11 @@ program cosp2_test cospstateIN,cospIN) call cpu_time(driver_time(6)) - + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Call COSP !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + cosp_status = COSP_SIMULATOR(cospIN, cospstateIN, cospOUT,start_idx,end_idx,.false.) do ij=1,size(cosp_status,1) if (cosp_status(ij) .ne. '') print*,trim(cosp_status(ij)) @@ -1526,11 +1531,11 @@ subroutine destroy_cospstateIN(y) if (allocated(y%hgt_matrix_half)) deallocate(y%hgt_matrix_half) if (allocated(y%surfelev)) deallocate(y%surfelev) ! Must be allocatable, and these are single values. Waiting for GCM integration -! if (allocated(y%month)) deallocate(y%month) -! if (allocated(y%co2)) deallocate(y%co2) -! if (allocated(y%ch4)) deallocate(y%ch4) -! if (allocated(y%n2o)) deallocate(y%n2o) -! if (allocated(y%co)) deallocate(y%co) + if (allocated(y%month)) deallocate(y%month) + if (allocated(y%co2)) deallocate(y%co2) + if (allocated(y%ch4)) deallocate(y%ch4) + if (allocated(y%n2o)) deallocate(y%n2o) + if (allocated(y%co)) deallocate(y%co) if (allocated(y%o3)) deallocate(y%o3) if (allocated(y%u_sfc)) deallocate(y%u_sfc) if (allocated(y%v_sfc)) deallocate(y%v_sfc) diff --git a/src/cosp.F90 b/src/cosp.F90 index b95ccb4de9..60b088e5a7 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -104,9 +104,9 @@ MODULE MOD_COSP skt, & ! Surface temperature (K) surfelev ! Surface Elevation (m) ! Fields used ONLY by RTTOV - integer :: & + integer,allocatable,dimension(:) :: & month ! Month for surface emissivty atlas (1-12) - real(wp) :: & + real(wp),allocatable,dimension(:) :: & co2, & ! CO2 (kg/kg) ch4, & ! Methane (kg/kg) n2o, & ! N2O (kg/kg) @@ -408,8 +408,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Initialize error reporting for output cosp_simulator(:)='' - - + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 1) Determine if using full inputs or subset !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -511,7 +510,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! RTTOV Column if (associated(cospOUT%rttov_outputs)) then Lrttov_column = .true. - print*,'multi-inst. RTTOV called' endif ! Set flag to deallocate rttov types (only done on final call to simulator) @@ -1534,12 +1532,11 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) endif ! RTTOV multi-instrument - print*,'Lrttov_column multi-inst. start' if (Lrttov_column) then do i=1,cospIN%Ninst_rttov ! Allocate memory for the outputs - I won't need all of these in every situation. ! Only allocate clear-sky memory when PC-RTTOV is run. - print*,'cospIN % cfg_rttov(i) % nchan_out: ',cospIN % cfg_rttov(i) % nchan_out ! issue here +! print*,'cospIN % cfg_rttov(i) % nchan_out: ',cospIN % cfg_rttov(i) % nchan_out ! JKS allocate(rttov_Ichannel(cospIN % cfg_rttov(i) % nchan_out)) ! Channel indices if (cospIN % cfg_rttov(i) % Lrttov_pc) then allocate(rttov_bt_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp @@ -1556,13 +1553,13 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) call cpu_time(driver_time(3)) ! Run simulator - call cosp_rttov_simulate(rttovIN,cospIN%cfg_rttov(i),Lrttov_cleanUp, & ! Inputs + call cosp_rttov_simulate(rttovIN,cospIN%cfg_rttov(i),Lrttov_cleanUp, & ! Inputs rttov_bt_total,rttov_bt_clear, & ! Brightness Temp Outputs rttov_rad_total,rttov_rad_clear,rttov_rad_cloudy, & ! Radiance Outputs rttov_refl_total,rttov_refl_clear, & ! Reflectance Outputs cosp_simulator(nError+1)) call cpu_time(driver_time(4)) - print*,'Time to run RTTOV: ',driver_time(4)-driver_time(3) +! print*,'Time to run RTTOV: ',driver_time(4)-driver_time(3) ! JKS ! Write to cospOUT if (associated(cospOUT % rttov_outputs(i) % channel_indices)) & @@ -1601,10 +1598,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) end do - endif - - print*,'Lrttov_column multi-inst. successful' - + endif !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 6) Compute multi-instrument products @@ -1910,7 +1904,7 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La rttov_configs) call cpu_time(driver_time(2)) - print*,'Time to run cosp_rttov_init: ',driver_time(2)-driver_time(1) +! print*,'Time to run cosp_rttov_init: ',driver_time(2)-driver_time(1) endif if (Lcloudsat) call cosp_cloudsat_init(cloudsat_radar_freq,cloudsat_k2, & @@ -3157,7 +3151,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, ! RTTOV Inputs if (Lrttov_column) then - if (cospgridIN%co2 .lt. 0) then + if (any(cospgridIN%co2 .lt. 0)) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%co2 contains values out of range' Lrttov_column = .false. @@ -3176,7 +3170,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, end do end if endif - if (cospgridIN%ch4 .lt. 0) then + if (any(cospgridIN%ch4 .lt. 0)) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%ch4 contains values out of range' Lrttov_column = .false. @@ -3195,7 +3189,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, end do end if endif - if (cospgridIN%n2o .lt. 0) then + if (any(cospgridIN%n2o .lt. 0)) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%n2o contains values out of range' Lrttov_column = .false. @@ -3214,7 +3208,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, end do end if endif - if (cospgridIN%co.lt. 0) then + if (any(cospgridIN%co.lt. 0)) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%co contains values out of range' Lrttov_column = .false. @@ -4139,8 +4133,11 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, size(cospgridIN%v_sfc) .ne. cospIN%Npoints .OR. & size(cospgridIN%skt) .ne. cospIN%Npoints .OR. & size(cospgridIN%phalf,1) .ne. cospIN%Npoints .OR. & - size(cospgridIN%qv,1) .ne. cospIN%Npoints .OR. & + size(cospgridIN%seaice) .ne. cospIN%Npoints .OR. & + size(cospgridIN%cloudIce,1) .ne. cospIN%Npoints .OR. & + size(cospgridIN%cloudLiq,1) .ne. cospIN%Npoints .OR. & size(cospgridIN%land) .ne. cospIN%Npoints .OR. & + size(cospgridIN%lon) .ne. cospIN%Npoints .OR. & size(cospgridIN%lat) .ne. cospIN%Npoints) then Lrttov_column = .false. nError=nError+1 diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 9d7a662750..7f8d8973d8 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -149,8 +149,8 @@ SUBROUTINE COSP_RTTOV_INIT(Lrttov, Nlevels,Ninstruments,instrument_namelists, ! Create config objects for each instrument to be simulated by RTTOV. Return to the main subroutine. do inst_idx=1,Ninstruments - print*,'inst_idx: ',inst_idx - print*,'instrument_namelists(inst_idx): ',instrument_namelists(inst_idx) +! print*,'inst_idx: ',inst_idx +! print*,'instrument_namelists(inst_idx): ',instrument_namelists(inst_idx) ! print*,'kind(rttov_configs(inst_idx)): ',kind(rttov_configs(inst_idx)) ! print*,'rttov_configs(inst_idx): ',rttov_configs(inst_idx) call cosp_rttov_init_s(Nlevels,instrument_namelists(inst_idx),rttov_configs(inst_idx)) @@ -243,8 +243,6 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & read(10,nml=RTTOV_INPUT) close(10) - print*,'Lrttov_pc: ',Lrttov_pc - ! Set logicals for RTTOV config rttov_config%Lrttov_bt = Lrttov_bt rttov_config%Lrttov_rad = Lrttov_rad @@ -519,14 +517,13 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & ! Check options to determine if the principal component approach should be run if (rttovConfig % opts % rt_ir % pc % addpc) then - print*,'Running COSP_PC_RTTOV_SIMULATE in multi-inst. set-up' +! print*,'Running COSP_PC_RTTOV_SIMULATE in multi-inst. set-up' call COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & bt_clear,rad_clear, & error) - print*,'end of COSP_PC_RTTOV_SIMULATE' else - print*,'Running COSP_REG_RTTOV_SIMULATE in multi-inst. set-up' +! print*,'Running COSP_REG_RTTOV_SIMULATE in multi-inst. set-up' call COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & bt_total,bt_clear, & rad_total,rad_clear,rad_cloudy, & @@ -575,7 +572,6 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, real(wp),dimension(10) :: driver_time ! Run each step for running RTTOV from mod_cosp_rttov (and time them) - print*,'cosp_rttov_allocate begin' ! jks call cpu_time(driver_time(1)) call cosp_rttov_allocate(rttovIN, & rttovConfig % nChannels_rec, & @@ -584,7 +580,6 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % iChannel, & rttovConfig % nchanprof) - print*,'cosp_rttov_allocate successful' ! jks call cpu_time(driver_time(2)) call cosp_rttov_construct_profiles(rttovIN, & rttovConfig % Lrttov_cld, & @@ -596,16 +591,13 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % SO2_mr, & rttovConfig % ZenAng) - print*,'cosp_rttov_construct_profiles successful' ! jks call cpu_time(driver_time(3)) call cosp_rttov_setup_emissivity_reflectance() ! Config agnostic after allocate step. - print*,'cosp_rttov_setup_emissivity_reflectance successful' ! jks call cpu_time(driver_time(4)) call cosp_rttov_call_direct(rttovConfig % rttov_direct_nthreads, & rttovConfig % opts, & rttovConfig % coefs) - print*,'cosp_rttov_call_direct successful' ! jks call cpu_time(driver_time(5)) call cosp_rttov_save_output(rttovIN, & @@ -619,7 +611,6 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rad_total,rad_clear,rad_cloudy, & refl_total,refl_clear) - print*,'cosp_rttov_save_output successful' ! jks call cpu_time(driver_time(6)) call cosp_rttov_deallocate_profiles(rttovIN, & rttovConfig % opts, & @@ -627,19 +618,19 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % nchanprof) call cpu_time(driver_time(7)) - print*,'Time to run "cosp_rttov_allocate": ', driver_time(2)-driver_time(1) - print*,'Time to run "cosp_rttov_construct_profiles": ', driver_time(3)-driver_time(2) - print*,'Time to run "cosp_rttov_setup_emissivity_reflectance": ',driver_time(4)-driver_time(3) - print*,'Time to run "cosp_rttov_call_direct": ', driver_time(5)-driver_time(4) - print*,'Time to run "cosp_rttov_save_output": ', driver_time(6)-driver_time(5) - print*,'Time to run "cosp_rttov_deallocate_profiles": ', driver_time(7)-driver_time(6) +! print*,'Time to run "cosp_rttov_allocate": ', driver_time(2)-driver_time(1) +! print*,'Time to run "cosp_rttov_construct_profiles": ', driver_time(3)-driver_time(2) +! print*,'Time to run "cosp_rttov_setup_emissivity_reflectance": ',driver_time(4)-driver_time(3) +! print*,'Time to run "cosp_rttov_call_direct": ', driver_time(5)-driver_time(4) +! print*,'Time to run "cosp_rttov_save_output": ', driver_time(6)-driver_time(5) +! print*,'Time to run "cosp_rttov_deallocate_profiles": ', driver_time(7)-driver_time(6) ! Deallocate the coefficient files if directed if (lCleanup) then call cpu_time(driver_time(8)) call cosp_rttov_deallocate_coefs(rttovConfig % coefs) call cpu_time(driver_time(9)) - print*,'Time to run "cosp_rttov_deallocate_coefs": ',driver_time(9)-driver_time(8) +! print*,'Time to run "cosp_rttov_deallocate_coefs": ',driver_time(9)-driver_time(8) endif ! print*,'Total RTTOV run time: ',driver_time(8)-driver_time(1) @@ -678,7 +669,6 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, real(wp),dimension(10) :: driver_time ! Run each step for running RTTOV from mod_cosp_rttov (and time them) -! print*,'cosp_rttov_allocate begin' ! jks call cpu_time(driver_time(1)) call cosp_pc_rttov_allocate(rttovIN, & rttovConfig % PC_coef_filepath, & @@ -688,7 +678,6 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % iChannel, & rttovConfig % nchanprof, & rttovConfig % iChannel_out) - print*,'cosp_pc_rttov_allocate successful' ! jks call cpu_time(driver_time(2)) call cosp_rttov_construct_profiles(rttovIN, & rttovConfig % Lrttov_cld, & @@ -699,10 +688,8 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % N2O_mr, & rttovConfig % SO2_mr, & rttovConfig % ZenAng) - print*,'cosp_rttov_construct_profiles successful' ! jks call cpu_time(driver_time(3)) call cosp_pc_rttov_setup_emissivity() - print*,'cosp_pc_rttov_setup_emissivity successful' ! jks call cpu_time(driver_time(4)) call cosp_pc_rttov_call_direct(rttovConfig % rttov_direct_nthreads, & rttovConfig % opts, & @@ -710,7 +697,6 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % nchannels_rec, & rttovConfig % iChannel_out) ! iChannel_out should have been updated - print*,'cosp_pc_rttov_call_direct successful' ! jks call cpu_time(driver_time(5)) call cosp_pc_rttov_save_output(rttovIN%nPoints, & rttovConfig%nchannels_rec, & @@ -719,7 +705,6 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, bt_clear, & rad_clear) - print*,'cosp_pc_rttov_save_output successful' ! jks call cpu_time(driver_time(6)) call cosp_pc_rttov_deallocate_profiles(rttovIN, & rttovConfig % nChannels_rec, & @@ -728,19 +713,19 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % nchanprof) call cpu_time(driver_time(7)) - print*,'Time to run "cosp_pc_rttov_allocate": ', driver_time(2)-driver_time(1) - print*,'Time to run "cosp_rttov_construct_profiles": ', driver_time(3)-driver_time(2) - print*,'Time to run "cosp_pc_rttov_setup_emissivity": ', driver_time(4)-driver_time(3) - print*,'Time to run "cosp_pc_rttov_call_direct": ', driver_time(5)-driver_time(4) - print*,'Time to run "cosp_pc_rttov_save_output": ', driver_time(6)-driver_time(5) - print*,'Time to run "cosp_pc_rttov_deallocate_profiles": ', driver_time(7)-driver_time(6) +! print*,'Time to run "cosp_pc_rttov_allocate": ', driver_time(2)-driver_time(1) +! print*,'Time to run "cosp_rttov_construct_profiles": ', driver_time(3)-driver_time(2) +! print*,'Time to run "cosp_pc_rttov_setup_emissivity": ', driver_time(4)-driver_time(3) +! print*,'Time to run "cosp_pc_rttov_call_direct": ', driver_time(5)-driver_time(4) +! print*,'Time to run "cosp_pc_rttov_save_output": ', driver_time(6)-driver_time(5) +! print*,'Time to run "cosp_pc_rttov_deallocate_profiles": ', driver_time(7)-driver_time(6) ! Deallocate the coefficient files if directed if (lCleanup) then call cpu_time(driver_time(8)) ! call cosp_rttov_deallocate_coefs(rttovConfig % coefs) ! JKS this again with PC-RTTOV... call cpu_time(driver_time(9)) - print*,'Time to run "cosp_rttov_deallocate_coefs": ',driver_time(9)-driver_time(8) +! print*,'Time to run "cosp_rttov_deallocate_coefs": ',driver_time(9)-driver_time(8) endif END SUBROUTINE COSP_PC_RTTOV_SIMULATE diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 40ae08be15..d1cb769d02 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -73,7 +73,6 @@ module mod_cosp_rttov #include "rttov_dealloc_coefs.interface" #include "rttov_alloc_direct.interface" #include "rttov_init_emis_refl.interface" -#include "rttov_user_options_checkinput.interface" #include "rttov_print_opts.interface" #include "rttov_print_profile.interface" #include "rttov_get_pc_predictindex.interface" @@ -146,9 +145,10 @@ module mod_cosp_rttov integer(kind=jpim),pointer :: & ! JKS trying this nPoints, & ! Number of profiles to simulate nLevels, & ! Number of levels - nSubCols, & ! Number of subcolumns - month ! Month (needed for surface emissivity calculation) - real(wp),pointer :: & ! Could change the dimensionality of these in the future + nSubCols ! Number of subcolumns + integer(kind=jpim),dimension(:),pointer :: & + month + real(wp),dimension(:),pointer :: & ! Could change the dimensionality of these in the future co2, & ! Carbon dioxide ch4, & ! Methane n2o, & ! n2o @@ -327,7 +327,8 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, & !inst_npcscor inst_npred_pc = SIZE(predictindex) inst_nchanprof = inst_npred_pc * rttovIN%nPoints ! Size of chanprof array is total number of predictors over all profiles - ! Determine the number of reconstructed radiances per profile (nchannels_rec) + ! Determine the number of reconstructed radiances per profile (nchannels_rec) + if (allocated(inst_iChannel_out)) deallocate(inst_iChannel_out) ! Reset because this variable is internal and used by multiple instruments. ! JKS if (inst_opts % rt_ir % pc % addradrec) then if (inst_nchannels_rec < 0) then ! If the number of channels is negative, don't reconstruct radiances at all @@ -342,7 +343,6 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, & !inst_npcscor else ! Otherwise read the channel list from the file print*,'radrec 3.' - print*,'inst_nchannels_rec: ',inst_nchannels_rec allocate(inst_iChannel_out(inst_nchannels_rec)) inst_iChannel_out = inst_iChannel_in endif @@ -435,7 +435,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & do i = 1, rttovIN%nPoints ! Initialize trace gas concentrations from user input - ! These gases are not in COSP input files but might be in the futre + ! These gases are not in COSP input files but might be in the future profiles(i)%co2(:) = inst_co2_mr profiles(i)%n2o(:) = inst_n2o_mr @@ -464,7 +464,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & ! 2m parameters profiles(i)%s2m%p = rttovIN%p_surf(i) * 1e-2 ! convert Pa to hPa - profiles(i)%s2m%t = rttovIN%t2m(i) ! JKS or rttovIN%t_skin + profiles(i)%s2m%t = rttovIN%t2m(i) profiles(i)%s2m%q = rttovIN%q2m(i) ! Should be the same as gas units (kg/kg) profiles(i)%s2m%u = rttovIN%u_surf(i) profiles(i)%s2m%v = rttovIN%v_surf(i) @@ -472,7 +472,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & ! skin variables for emissivity calculations profiles(i)%skin%t = rttovIN%t_skin(i) - + ! fastem coefficients - for mw calculations profiles(i)%skin%fastem(1) = 3.0 profiles(i)%skin%fastem(2) = 5.0 @@ -508,7 +508,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & profiles(i)%skin%watertype = 1 !profiles(i) %idg = 0. ! Depreciated? !profiles(i) %ish = 0. ! Depreciated? - end do + end do ! JKS - nothing to check here, this will never trigger. call rttov_error('error in profile initialization' , lalloc = .false.) @@ -631,11 +631,15 @@ subroutine cosp_rttov_call_direct(inst_nthreads, & integer(KIND=jpim),intent(in) :: & inst_nthreads - type(rttov_options),intent(in) :: & + type(rttov_options),intent(in) :: & inst_opts - type(rttov_coefs),intent(in) :: & + type(rttov_coefs),intent(in) :: & inst_coefs +! print*,'shape(chanprof%prof): ',shape(chanprof%prof) +! print*,'shape(chanprof%chan): ',shape(chanprof%chan) +! print*,'shape(bt_total): ',shape(bt_total) + if (inst_nthreads <= 1) then print*,'Calling rttov_direct' call rttov_direct( & @@ -730,7 +734,6 @@ end subroutine cosp_pc_rttov_call_direct ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 8. Save output data ! ------------------------------------------------------ - ! JKS - Need to allow options for Tb and radiance for clear- and cloudy-skies ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine cosp_rttov_save_output(rttovIN,inst_nchan_out, & ! Inputs @@ -797,7 +800,6 @@ end subroutine cosp_rttov_save_output ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 8. Save output data (PC-RTTOV) ! ------------------------------------------------------ - ! JKS - Need to allow options for Tb and radiance for clear- and cloudy-skies ! PC-RTTOV only does clear-sky IR calculations (can handle aerosols, but I'll ignore that for now. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From e416de2309b0557dfa8a9edcc92d3dad32b9fc97 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Mon, 26 Jun 2023 08:24:44 -0600 Subject: [PATCH 065/159] Update STUB file functionality --- src/simulator/cosp_rttov_interfaceSTUB.F90 | 6 ++++-- src/simulator/rttov/cosp_rttovSTUB.F90 | 15 ++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/simulator/cosp_rttov_interfaceSTUB.F90 b/src/simulator/cosp_rttov_interfaceSTUB.F90 index a375d3f817..4ee4760eae 100644 --- a/src/simulator/cosp_rttov_interfaceSTUB.F90 +++ b/src/simulator/cosp_rttov_interfaceSTUB.F90 @@ -174,15 +174,17 @@ END SUBROUTINE COSP_RTTOV_SIMULATE !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_pc_rttov_simulate !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,lCleanup, & ! Inputs + SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & ! Inputs bt_total,rad_total, & ! Outputs error) type(rttov_in),intent(in) :: & rttovIN + type(rttov_cfg),intent(inout) :: & + rttovConfig logical,intent(in) :: & lCleanup ! Flag to determine whether to deallocate RTTOV types - real(wp),intent(inout),dimension(rttovIN%nPoints,rttovIN%nChannels) :: & ! Can I do this? I guess so! + real(wp),intent(inout),dimension(rttovIN%nPoints,rttovConfig%nchan_out) :: & ! Can I do this? I guess so! bt_total, & ! All-sky rad_total ! All-sky character(len=128) :: & diff --git a/src/simulator/rttov/cosp_rttovSTUB.F90 b/src/simulator/rttov/cosp_rttovSTUB.F90 index c8a3a668e3..5a52a97c7e 100644 --- a/src/simulator/rttov/cosp_rttovSTUB.F90 +++ b/src/simulator/rttov/cosp_rttovSTUB.F90 @@ -53,18 +53,20 @@ MODULE MOD_COSP_RTTOV ! TYPE rttov_IN - Data type specific to inputs required by RTTOV ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% type rttov_IN - integer,pointer :: & + integer,pointer :: & ! JKS trying this nPoints, & ! Number of profiles to simulate nLevels, & ! Number of levels - nSubCols, & ! Number of subcolumns - nChannels, & ! Number of channels to simulate - month ! Month (needed for surface emissivity calculation) - real(wp),pointer :: & - zenang, & ! Satellite zenith angle + nSubCols ! Number of subcolumns + integer,dimension(:),pointer :: & + month + real(wp),dimension(:),pointer :: & ! Could change the dimensionality of these in the future co2, & ! Carbon dioxide ch4, & ! Methane n2o, & ! n2o co ! Carbon monoxide +! real(wp),dimension(:),pointer :: & +! surfem ! Surface emissivities for the channels +! refl, & ! Surface reflectances for the channels real(wp),dimension(:),pointer :: & h_surf, & ! Surface height u_surf, & ! U component of surface wind @@ -83,7 +85,6 @@ MODULE MOD_COSP_RTTOV t, & ! Temperature q, & ! Specific humidity o3 ! Ozone - ! These fields below are needed ONLY for the RTTOV all-sky brightness temperature real(wp),dimension(:,:),pointer :: & tca, & ! Cloud fraction From 814ea16a77e87ca91c33545c0634f5fefe8bd991 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Fri, 30 Jun 2023 08:02:42 -0600 Subject: [PATCH 066/159] Flexible multi-instrument RTTOV namelist inputs working! --- .gitignore | 1 + build/Makefile | 2 +- driver/run/cosp2_input_rttov_nl.txt | 3 +-- driver/src/cosp2_test.F90 | 31 ++++++++++++----------------- 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 5e2719567d..24b8931ec8 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ driver/run/cosp2_test # Ignore anything in a .ipynb_checkpoint directory **/.ipynb_checkpoints/* +src/simulator/plot_testRTTOV_output.ipynb diff --git a/build/Makefile b/build/Makefile index 40bcc8ab7c..536385eba8 100644 --- a/build/Makefile +++ b/build/Makefile @@ -62,7 +62,7 @@ COSP_OBJS = cosp.o cosp_config.o cosp_stats.o cosp_constants.o cosp_errorHandlin cosp_calipso_interface.o lidar_simulator.o cosp_cloudsat_interface.o quickbeam.o \ cosp_grLidar532_interface.o cosp_atlid_interface.o -# Add RTTOV files appropriately. JKS: cosp should only need to depend on the interface, not the simulator. +# Add RTTOV files appropriately. ifdef RTTOV COSP_OBJS += cosp_rttov_interface_v13.o cosp_rttov_v13.o else diff --git a/driver/run/cosp2_input_rttov_nl.txt b/driver/run/cosp2_input_rttov_nl.txt index 852c06e1d9..207f9ed86d 100644 --- a/driver/run/cosp2_input_rttov_nl.txt +++ b/driver/run/cosp2_input_rttov_nl.txt @@ -83,8 +83,7 @@ !-------------- RTTOV inputs !---------------------------------------------------------------------------------- rttov_Ninstruments=3, -! rttov_instrument_namelists = (/'test1','test2','test3'/), -! rttov_instrument_namelists(1:3) = (/'test1','test2','test3'/), + rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt', Lrttov_localtime=.false., ! May not be necessary at this level rttov_Nlocaltime=2, rttov_localtime=10.0,13.0, ! To implement local time diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 5b204e9c63..079fdda475 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -159,8 +159,10 @@ program cosp2_test dinput ! Directory where the input files are located character(len=600) :: & fileIN ! dinput+finput - type(character(len=128)), allocatable, dimension(:) :: & - rttov_instrument_namelists ! Array of paths to RTTOV instrument namelists + character(len=128), dimension(50) :: & ! Arbitrary limit of 50 should be fine. + rttov_instrument_namelists ! Input of paths to RTTOV instrument namelists + character(len=128), allocatable :: & + rttov_instrument_namelists_final(:) ! Array of paths to RTTOV instrument namelists namelist/COSP_INPUT/overlap, isccp_topheight, isccp_topheight_direction, npoints, & npoints_it, ncolumns, nlevels, use_vgrid, Nlvgrid, csat_vgrid, dinput, finput, & @@ -237,7 +239,7 @@ program cosp2_test sd ! Hydrometeor description type(radar_cfg) :: & rcfg_cloudsat ! Radar configuration - type(rttov_cfg), dimension(:), allocatable, target :: & ! JKS check + type(rttov_cfg), dimension(:), allocatable, target :: & rttov_configs type(cosp_outputs) :: & cospOUT ! COSP simulator outputs @@ -303,19 +305,13 @@ program cosp2_test ! Jonah namelist checking area print*,'Lrttov_run: ',Lrttov_run print*,'rttov_Ninstruments: ',rttov_Ninstruments - allocate(rttov_instrument_namelists(rttov_Ninstruments)) - -! if (Lrttov_run) then -! namelist/COSP_INPUT/rttov_instrument_namelists -! endif - -! open(10,file=cosp_input_namelist,status='unknown') -! read(10,nml=cosp_input) - -! print*,'rttov_instrument_namelists: ',rttov_instrument_namelists - rttov_instrument_namelists(1:3) = (/'instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt'/) - print*,'rttov_instrument_namelists: ',rttov_instrument_namelists - + + ! Shift the namelists read in into a shorter array for cosp_init: + allocate(rttov_instrument_namelists_final(rttov_Ninstruments)) + rttov_instrument_namelists_final(:) = rttov_instrument_namelists(1:rttov_Ninstruments) + + print*,'rttov_instrument_namelists_final: ',rttov_instrument_namelists_final + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Read in sample input data. !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -421,7 +417,7 @@ program cosp2_test 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, & - rttov_Ninstruments, rttov_instrument_namelists, rttov_configs) + rttov_Ninstruments, rttov_instrument_namelists_final, rttov_configs) call cpu_time(driver_time(3)) !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1530,7 +1526,6 @@ subroutine destroy_cospstateIN(y) if (allocated(y%hgt_matrix)) deallocate(y%hgt_matrix) if (allocated(y%hgt_matrix_half)) deallocate(y%hgt_matrix_half) if (allocated(y%surfelev)) deallocate(y%surfelev) -! Must be allocatable, and these are single values. Waiting for GCM integration if (allocated(y%month)) deallocate(y%month) if (allocated(y%co2)) deallocate(y%co2) if (allocated(y%ch4)) deallocate(y%ch4) From 2f016a3760e0839300ad95bc7cf3c5361dab5ecc Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 18 Jul 2023 15:56:41 -0600 Subject: [PATCH 067/159] Clean up --- build/Makefile | 5 - src/simulator/rttov/cosp_rttov_v13_old.F90 | 1319 -------------------- 2 files changed, 1324 deletions(-) delete mode 100644 src/simulator/rttov/cosp_rttov_v13_old.F90 diff --git a/build/Makefile b/build/Makefile index 536385eba8..0cb618401d 100644 --- a/build/Makefile +++ b/build/Makefile @@ -87,11 +87,6 @@ driver: make cosp2_test mv cosp2_test ../driver/run -# I would like to set the env variable here, but it won't work. -driver_rttov: - make driver - - # Dependencies for normal COSP libary cosp.o : cosp_kinds.o cosp_modis_interface.o cosp_constants.o \ cosp_misr_interface.o cosp_isccp_interface.o cosp_calipso_interface.o \ diff --git a/src/simulator/rttov/cosp_rttov_v13_old.F90 b/src/simulator/rttov/cosp_rttov_v13_old.F90 deleted file mode 100644 index d52670ae01..0000000000 --- a/src/simulator/rttov/cosp_rttov_v13_old.F90 +++ /dev/null @@ -1,1319 +0,0 @@ -! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -! Copyright (c) 2016, Regents of the University of Colorado -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are -! permitted provided that the following conditions are met: -! -! 1. Redistributions of source code must retain the above copyright notice, this list of -! conditions and the following disclaimer. -! -! 2. Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other -! materials provided with the distribution. -! -! 3. Neither the name of the copyright holder nor the names of its contributors may be -! used to endorse or promote products derived from this software without specific prior -! written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -! MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -! THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -! OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -! -! History -! March 2016 - M. Johnston - Original version -! April 2016 - D. Swales - Modified for use in COSPv2.0 -! JKS fill this in when working :) - -! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -module mod_cosp_rttov - use rttov_const, only : errorstatus_success, errorstatus_fatal, & - platform_name,inst_name -! Use RTTOV v13 types here, more may be needed - use rttov_types, only : rttov_options,rttov_coefs,rttov_profile, & - rttov_transmission,rttov_radiance,rttov_chanprof, & - rttov_emissivity,rttov_reflectance,rttov_opt_param -! use rttov_types, only : rttov_options,rttov_coefs,profile_type, & -! transmission_type,radiance_type,rttov_chanprof, & -! rttov_emissivity,profile_cloud_type,rttov_scatt_coef, & -! rttov_options_scatt - use rttov_const, only : surftype_sea, surftype_land, surftype_seaice, & - errorstatus_success,errorstatus_fatal, & - platform_name,inst_name, & - sensor_id_mw,sensor_id_po - use rttov_unix_env, only : rttov_exit - use cosp_kinds, only : wp - use mod_cosp_config, only : RTTOV_MAX_CHANNELS,N_HYDRO,rttovDir - use cosp_phys_constants, only : mdry=>amd,mO3=>amO3,mco2=>amCO2,mCH4=>amCH4, & - mn2o=>amN2O,mco=>amCO - - - ! The rttov_emis_atlas_data type must be imported separately - use mod_rttov_emis_atlas, ONLY : & - rttov_emis_atlas_data, & - atlas_type_ir, atlas_type_mw - - ! The rttov_brdf_atlas_data type must be imported separately - use mod_rttov_brdf_atlas, ONLY : rttov_brdf_atlas_data - - ! jpim, jprb and jplm are the RTTOV integer, real and logical KINDs - use parkind1, ONLY : jpim, jprb, jplm - - use rttov_unix_env, ONLY : rttov_exit - - implicit none - - -! Old includes -!#include "rttov_direct.interface" -!#include "rttov_alloc_prof.interface" -!#include "rttov_alloc_rad.interface" -!#include "rttov_alloc_transmission.interface" -!#include "rttov_dealloc_coefs.interface" -!#include "rttov_user_options_checkinput.interface" -!#include "rttov_read_coefs.interface" -!#include "rttov_get_emis.interface" -!#include "rttov_boundaryconditions.interface" - -! New includes for v13 (will need to clean up others) -#include "rttov_direct.interface" -#include "rttov_parallel_direct.interface" -#include "rttov_read_coefs.interface" -#include "rttov_dealloc_coefs.interface" -#include "rttov_alloc_direct.interface" -#include "rttov_init_emis_refl.interface" -#include "rttov_user_options_checkinput.interface" -#include "rttov_print_opts.interface" -#include "rttov_print_profile.interface" -#include "rttov_skipcommentline.interface" - -! Includes when directly inputting cloud optical parameters -#include "rttov_init_opt_param.interface" -#include "rttov_bpr_init.interface" -#include "rttov_bpr_calc.interface" -#include "rttov_bpr_dealloc.interface" -#include "rttov_legcoef_calc.interface" - - - ! Module parameters - integer, parameter :: maxlim = 10000 - real(wp),parameter :: eps = 0.622 - - ! Initialization parameters - integer :: & - platform, & ! RTTOV platform - sensor, & ! RTTOV instrument - satellite, & ! RTTOV satellite - nChannels ! Number of channels - integer,dimension(RTTOV_MAX_CHANNELS) :: & - iChannel ! RTTOV channel numbers - - ! Scattering coefficients (read in once during initialization) - type(rttov_coefs) :: & - coef_rttov -! JKS - KISS -! type(rttov_scatt_coef) :: & -! coef_scatt - ! RTTOV setup and options (set during initialization) - type(rttov_options) :: & - opts ! defaults to everything optional switched off - -! JKS - KISS -! type(rttov_options_scatt) :: & -! opts_scatt -contains - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE rttov_column - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine rttov_column(nPoints,nLevels,nSubCols,q,p,t,o3,ph,h_surf,u_surf,v_surf, & - p_surf,t_skin,t2m,q2m,lsmask,lon,lat,seaice,co2,ch4,n2o,co, & - zenang,lCleanup, & - ! Outputs - Tb,error, & - ! Optional arguments for surface emissivity calculation. - surfem,month, & -! coef_rttov, & ! JKS added coef_rttov - ! Optional arguments for all-sky calculation. - tca,ciw,clw,rain,snow) - ! Inputs - integer,intent(in) :: & - nPoints, & ! Number of gridpoints - nLevels, & ! Number of vertical levels - nSubCols ! Number of subcolumns - real(wp),intent(in) :: & - co2, & ! CO2 mixing ratio (kg/kg) - ch4, & ! CH4 mixing ratio (kg/kg) - n2o, & ! N2O mixing ratio (kg/kg) - co, & ! CO mixing ratio (kg/kg) - zenang ! Satellite zenith angle - real(wp),dimension(nPoints),intent(in) :: & - h_surf, & ! Surface height (m) - u_surf, & ! Surface u-wind (m/s) - v_surf, & ! Surface v-wind (m/s) - p_surf, & ! Surface pressure (Pa) - t_skin, & ! Skin temperature (K) - t2m, & ! 2-meter temperature (K) - q2m, & ! 2-meter specific humidity (kg/kg) - lsmask, & ! Land/sea mask - lon, & ! Longitude (deg) - lat, & ! Latitude (deg) - seaice ! Seaice fraction (0-1) - real(wp),dimension(nPoints,nLevels),intent(in) :: & - q, & ! Specific humidity (kg/kg) - p, & ! Pressure(Pa) - t, & ! Temperature (K) - o3 ! Ozone - real(wp),dimension(nPoints,nLevels+1),intent(in) :: & - ph ! Pressure @ half-levels (Pa) - logical,intent(in) :: & - lCleanup ! Flag to determine whether to deallocate RTTOV types - - ! Optional inputs (Needed for surface emissivity calculation) - integer,optional :: & - month ! Month (needed to determine table to load) - real(wp),dimension(nChannels),optional :: & - surfem ! Surface emissivity for each RTTOV channel - - ! JKS: Are these outputs - type(rttov_emis_atlas_data) :: emis_atlas ! Data structure for emissivity atlas - type(rttov_brdf_atlas_data) :: brdf_atlas ! Data structure for BRDF atlas - - ! Optional inputs (Needed for all-sky calculation) - real(wp),dimension(nPoints,nLevels),optional :: & - tca ! Total column cloud amount (0-1) - real(wp),dimension(nPoints,nSubCols,nLevels),optional :: & - ciw, & ! Cloud ice - clw, & ! Cloud liquid - rain, & ! Precipitation flux (kg/m2/s) - snow ! Precipitation flux (kg/m2/s) - - ! Outputs - real(wp),dimension(nPoints,nChannels) :: & - Tb ! RTTOV brightness temperature. - character(len=128) :: & - error ! Error messages (only populated if error encountered) - - ! Local variables - integer :: & - nloop,rmod,il,istart,istop,za,i,j,subcol,errorstatus,npts_it - integer,dimension(60) :: & - alloc_status - real(wp),dimension(nPoints) :: & - sh_surf - real(wp),dimension(nPoints,nLevels) :: & - sh,totalice - real(wp),dimension(nSubCols,nPoints,nChannels) :: & - Tbs ! Subcolumn brightness temperature - logical :: & - use_totalice, mmr_snowrain, cfrac - logical :: & - lallSky, & ! Control for type of brightness temperature calculation - ! (False(default) => clear-sky brightness temperature, True => All-sky) - lsfcEmis ! Control for surface emissivity calculation (true => compute surface emissivity, - ! provided that the field "month" is available) - - ! v13 local variables - integer(kind=jpim) :: atlas_type - -! Old includes (v11) -!#include "rttov_read_coefs.interface" -!#include "rttov_read_scattcoeffs.interface" -!#include "rttov_user_options_checkinput.interface" -!#include "rttov_dealloc_coefs.interface" -!#include "rttov_dealloc_scattcoeffs.interface" -!#include "rttov_setup_emis_atlas.interface" -!#include "rttov_deallocate_emis_atlas.interface" -!#include "rttov_print_opts.interface" -!#include "rttov_print_profile.interface" -!#include "rttov_boundaryconditions.interface" - -! New includes for v13 (will need to clean up others) -#include "rttov_direct.interface" -#include "rttov_parallel_direct.interface" -#include "rttov_read_coefs.interface" -#include "rttov_dealloc_coefs.interface" -#include "rttov_alloc_direct.interface" -#include "rttov_init_emis_refl.interface" -#include "rttov_user_options_checkinput.interface" -#include "rttov_print_opts.interface" -#include "rttov_print_profile.interface" -#include "rttov_skipcommentline.interface" - -! Includes when directly inputting cloud optical parameters -#include "rttov_init_opt_param.interface" -#include "rttov_bpr_init.interface" -#include "rttov_bpr_calc.interface" -#include "rttov_bpr_dealloc.interface" -#include "rttov_legcoef_calc.interface" - -! Use emissivity atlas -#include "rttov_setup_emis_atlas.interface" -#include "rttov_get_emis.interface" -#include "rttov_deallocate_emis_atlas.interface" - -! Use BRDF atlas -#include "rttov_setup_brdf_atlas.interface" -#include "rttov_get_brdf.interface" -#include "rttov_deallocate_brdf_atlas.interface" - - ! Initialize some things - totalice = 0._wp - Tbs(:,:,:) = 0._wp - Tb(:,:) = 0._wp - error = '' - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Setup for call to RTTOV - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! First, check to see if we are doing an all-sky or clear-sky calculation brightness - ! temperature - lallSky = .false. - if (present(tca) .and. present(clw) .and. present(ciw) .and. present(rain) & - .and. present(snow)) lallSky=.true. - - ! Check to see if we need to compute the surface emissivity (defualt is to compute - ! surface emissivity using the atlas tables) - lsfcEmis = .true. - if (present(surfem)) lsfcEmis = .false. - - ! We also need the month for the emissivity atlas, so check... - if (.not. present(month)) lsfcEmis = .false. - - if (lsfcEmis .eq. .false. .and. .not. present(surfem)) then - error = 'ERROR (rttov_column): User did not provide surface emissivity and did not '//& - 'request the surface emissivity to be calculated!!!' - return - endif - - ! Convert specific humidity to ppmv - sh = ( q / ( q + eps * ( 1._wp - q ) ) ) * 1e6 - sh_surf = ( q2m / ( q2m + eps * ( 1._wp - q2m ) ) ) * 1e6 - - ! Settings unique to all-sky call. - use_totalice = .false. - mmr_snowrain = .true. - cfrac = .true. -! opts_scatt%lusercfrac = cfrac ! This type is not in v13 - - ! RTTOV can handle only about 100 profiles at a time (fixme: check this with roger), - ! so we are putting a loop of 100 - nloop = npoints / maxlim - rmod = mod( npoints, maxlim ) - if( rmod .ne. 0 ) then - nloop = nloop + 1 - endif - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Initialize emissivity atlas data for chosen sensor. - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - ! Old "rttov_setup_emis_atlas" subroutine call -! call rttov_setup_emis_atlas(errorstatus,opts,month,coef_rttov,path=trim(rttovDir)//"emis_data/") - - ! New v13 subroutine call from "example_atlas_fwd.F90" - if (coef_rttov%coef%id_sensor == sensor_id_mw .or. & - coef_rttov%coef%id_sensor == sensor_id_po) then - atlas_type = atlas_type_mw ! MW atlas - else - atlas_type = atlas_type_ir ! IR atlas - endif - call rttov_setup_emis_atlas( & - errorstatus, & - opts, & - month, & - atlas_type, & ! Selects MW (1) or IR (2) - emis_atlas, & - path = trim(rttovDir)//"emis_data/", & ! The default path to atlas data - coefs = coef_rttov) ! This is mandatory for the CNRM MW atlas, ignored by TELSEM2; - ! if supplied for IR atlases they are initialised for this sensor - ! and this makes the atlas much faster to access - - if (errorstatus /= errorstatus_success) then - error = 'ERROR (rttov_column): Error reading emis atlas data!' - return - endif - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Some quality control prior to RTTOV call - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! v11 quality control - ! Ensure the options and coefficients are consistent -! if(opts_scatt%config%do_checkinput) then -! call rttov_user_options_checkinput(errorstatus, opts, coef_rttov) -! if (errorstatus /= errorstatus_success) then -! error = 'ERROR (rttov_column): Error when checking input data!' -! return -! endif -! endif - - ! v13 quality control - ! Ensure the options and coefficients are consistent - call rttov_user_options_checkinput(errorstatus, opts, coef_rttov) - if (errorstatus /= errorstatus_success) then - write(*,*) 'error in rttov options' - error = 'ERROR (rttov_column): Error when checking input data!' - call rttov_exit(errorstatus) ! JKS not sure if this is the right way to exit in COSP - endif - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Call to RTTOV - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Looping over maxlim number of profiles - do il = 1, nloop - istart = (il - 1) * maxlim + 1 - istop = min(il * maxlim, npoints) - if( ( il .eq. nloop ) .and. ( rmod .ne. 0 ) ) then - npts_it = rmod - else - npts_it = maxlim - endif - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Clear-sky brightness temperature - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - if (.not. lallSky) then - call rttov_multprof(nChannels,iChannel,surfem,npts_it,nLevels,platform, & - satellite,sensor,opts,coef_rttov,zenang, & - p(istart:istop,:)/100._wp,t(istart:istop,:), & - sh(istart:istop,:),(mdry/mo3)*o3(istart:istop,:)*1e6, & - (mdry/mco2)*co2*1e6,(mdry/mch4)*ch4*1e6,(mdry/mn2o)*n2o*1e6,& - (mdry/mco)*co*1e6,h_surf(istart:istop),u_surf(istart:istop),& - v_surf(istart:istop),t_skin(istart:istop), & - p_surf(istart:istop)/100.,t2m(istart:istop), & - sh_surf(istart:istop),lsmask(istart:istop), & - seaice(istart:istop),lat(istart:istop),lon(istart:istop), & - Tb(istart:istop,:)) - endif - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! All-sky brightness temperature - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - if (lallSky) then - ! Loop over all subcolumns - do subcol = 1, nSubCols - ! Call RTTOV - call cosp_rttov_mwscatt(nChannels,iChannel,surfem,nPoints,nlevels,platform, & - satellite,sensor,opts,coef_rttov, & -! satellite,sensor,opts,opts_scatt,coef_rttov, & ! JKS - remove opts_scatt - coef_scatt,zenang,p(istart:istop,:)/100._wp, & - ph(istart:istop,:)/100._wp,t(istart:istop, :), & - sh(istart:istop, :), & - (mdry/mo3)*o3(istart:istop,:)*1e6, & - clw(istart:istop,subcol,:), & - ciw(istart:istop,subcol,:),tca(istart:istop, :), & - totalice(istart:istop,:),snow(istart:istop,subcol,:),& - rain(istart:istop,subcol,:),(mdry/mco2)*co2*1e6, & - (mdry/mch4)*ch4*1e6,(mdry/mn2o)*n2o*1e6, & - (mdry/mco)*co*1e6,h_surf(istart:istop), & - u_surf(istart:istop),v_surf(istart:istop), & - t_skin(istart:istop), p_surf(istart:istop)/100., & - t2m(istart:istop),sh_surf(istart:istop), & - lsmask(istart:istop),seaice(istart:istop), & - lat(istart:istop),lon(istart:istop), use_totalice, & - mmr_snowrain,cfrac,Tbs(subcol,istart:istop,:)) - enddo - endif - enddo - - ! For all-sky calculation we need to average together all of the cloudy subcolumns. - if (lallSky) then - do subcol = 1, nSubCols - Tb = Tb + tbs(subcol,:,:) - enddo - Tb = Tb/nSubCols - endif - - ! Free up space - if (lCleanup) then - call rttov_dealloc_coefs(errorstatus,coef_rttov) - call rttov_deallocate_emis_atlas(coef_rttov) - if (lallSky) call rttov_dealloc_scattcoeffs(coef_scatt) - endif - end subroutine rttov_column - - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE rttov_simulate - JKS - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine rttov_simulate(nPoints,nLevels,nSubCols,q,p,t,o3,ph,h_surf,u_surf,v_surf, & - p_surf,t_skin,t2m,q2m,lsmask,lon,lat,seaice,co2,ch4,n2o,co, & - zenang,lCleanup, & - ! Outputs - Tb,error, & - ! Optional arguments for surface emissivity calculation. - surfem,month, & -! coef_rttov, & ! JKS added coef_rttov - ! Optional arguments for all-sky calculation. - tca,ciw,clw,rain,snow) - - - ! Inputs - integer,intent(in) :: & - nPoints, & ! Number of gridpoints - nLevels, & ! Number of vertical levels - nSubCols ! Number of subcolumns - real(wp),intent(in) :: & - co2, & ! CO2 mixing ratio (kg/kg) - ch4, & ! CH4 mixing ratio (kg/kg) - n2o, & ! N2O mixing ratio (kg/kg) - co, & ! CO mixing ratio (kg/kg) - zenang ! Satellite zenith angle - real(wp),dimension(nPoints),intent(in) :: & - h_surf, & ! Surface height (m) - u_surf, & ! Surface u-wind (m/s) - v_surf, & ! Surface v-wind (m/s) - p_surf, & ! Surface pressure (Pa) - t_skin, & ! Skin temperature (K) - t2m, & ! 2-meter temperature (K) - q2m, & ! 2-meter specific humidity (kg/kg) - lsmask, & ! Land/sea mask - lon, & ! Longitude (deg) - lat, & ! Latitude (deg) - seaice ! Seaice fraction (0-1) - real(wp),dimension(nPoints,nLevels),intent(in) :: & - q, & ! Specific humidity (kg/kg) - p, & ! Pressure(Pa) - t, & ! Temperature (K) - o3 ! Ozone - real(wp),dimension(nPoints,nLevels+1),intent(in) :: & - ph ! Pressure @ half-levels (Pa) - logical,intent(in) :: & - lCleanup ! Flag to determine whether to deallocate RTTOV types - - ! Cloud fields - real(wp),dimension(nPoints,nLevels),intent(in) :: & - tca ! Total column cloud amount (0-1) - real(wp),dimension(nPoints,nSubCols,nLevels),intent(in) :: & - ciw, & ! Cloud ice - clw, & ! Cloud liquid - rain, & ! Precipitation flux (kg/m2/s) - snow ! Precipitation flux (kg/m2/s) - - ! Optional inputs (Needed for surface emissivity calculation) - integer,optional :: & - month ! Month (needed to determine table to load) - real(wp),dimension(nChannels),optional :: & - surfem ! Surface emissivity for each RTTOV channel - - ! Optional inputs (Needed for all-sky calculation) -! real(wp),dimension(nPoints,nLevels),optional :: & -! tca ! Total column cloud amount (0-1) -! real(wp),dimension(nPoints,nSubCols,nLevels),optional :: & -! ciw, & ! Cloud ice -! clw, & ! Cloud liquid -! rain, & ! Precipitation flux (kg/m2/s) -! snow ! Precipitation flux (kg/m2/s) - - ! Outputs - real(wp),dimension(nPoints,nChannels) :: & - Tb ! RTTOV brightness temperature. - character(len=128) :: & - error ! Error messages (only populated if error encountered) - - ! Initialize some things - Tb(:,:) = 0._wp - error = '' - -! Current inputs: rttovIN,cospOUT%rttov_tbs(ij:ik,:),cosp_simulator(nError+1) - -! JKS new function end - end subroutine rttov_simulate - - - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE rttov_multprof - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine rttov_multprof( & - nch_in, & ! number of channels - ichan_in, & ! channel indices - surfem_in, & ! surface emissivity values - prf_num_in, & ! number of profiles to simulate - nlevels_in, & ! number of pressure levels - plat_in, & ! platform number - sat_in, & ! satellite number - sens_in, & ! instrument number - opts, & - coef_rttov, & - zenang_in, & ! zenith angle - p_in, & ! pressure [hpa] - t_in, & ! temperature [ k ] - q_in, & ! specific humidity [ ppmv ] - o3_in, & ! ozone vmr [ ppmv ] - co2_in, & ! co2 vmr [ ppmv ] *this is a single value* - ch4_in, & ! ch4 vmr [ ppmv ] *this is a single value* - n2o_in, & ! n2o vmr [ ppmv ] *this is a single value* - co_in, & ! co vmr [ ppmv ] *this is a single value* - h_surf, & ! surface height [ m ] - u_surf, & ! u wind at 10 m [ m/s ] - v_surf, & ! v wind at 10 m [ m/s ] - t_skin, & ! skin temperatre [ k ] - p_surf, & ! surface pressure - t_surf, & ! 1.5 m temperature [ k ] - q_surf, & ! 1.5 m specific humidity [ ppmv ] - lsmask, & ! land sea mask - seaice, & ! seaice fraction - latitude, & ! latitude [ deg north ] - longitude, & ! longitude [ deg east ] - tbs & ! brightness temperature [ k ] (output) - ) - - !------ input arguments. no rttov kinds should be used here ----------------- - integer, intent(in) :: nch_in ! number of channels to be computed - integer, intent(in) :: ichan_in(nch_in) ! indices of selected channels - real(wp), intent(in) :: surfem_in(nch_in) ! surface emissivities for the channels - integer, intent(in) :: prf_num_in - integer, intent(in) :: nlevels_in - integer, intent(in) :: plat_in ! satellite platform - integer, intent(in) :: sat_in ! satellite number - integer, intent(in) :: sens_in ! satellite sensor - real(wp), intent(in) :: zenang_in ! satellite zenith angle - - type(rttov_options) :: opts - type(rttov_coefs) :: coef_rttov - - real(wp), intent(in) :: p_in(prf_num_in, nlevels_in) ! pressure profiles - real(wp), intent(in) :: t_in(prf_num_in, nlevels_in) ! temperature profiles - real(wp), intent(in) :: q_in(prf_num_in, nlevels_in) ! humidity profiles - real(wp), intent(in) :: o3_in(prf_num_in, nlevels_in) ! ozone profiles - - ! the following trace gases contain constant values - real(wp), intent(in) :: co2_in ! carbon dioxide - real(wp), intent(in) :: ch4_in ! methane - real(wp), intent(in) :: n2o_in ! n2o - real(wp), intent(in) :: co_in ! carbon monoxide - real(wp), intent(in) :: h_surf(prf_num_in) ! surface height - real(wp), intent(in) :: u_surf(prf_num_in) ! u component of surface wind - real(wp), intent(in) :: v_surf(prf_num_in) ! v component of surface wind - real(wp), intent(in) :: t_skin(prf_num_in) ! surface skin temperature - real(wp), intent(in) :: p_surf(prf_num_in) ! surface pressure - real(wp), intent(in) :: t_surf(prf_num_in) ! 1.5 m temperature - real(wp), intent(in) :: q_surf(prf_num_in) ! 1.5 m specific humidity - real(wp), intent(in) :: lsmask(prf_num_in) ! land-sea mask - real(wp), intent(in) :: seaice(prf_num_in) ! sea-ice fraction - real(wp), intent(in) :: latitude(prf_num_in) ! latitude - real(wp), intent(in) :: longitude(prf_num_in) ! longitude - - real(wp), intent(inout) :: tbs(prf_num_in, nch_in) ! tbs (in the right format) - - !------ local variables. use only rttov kinds or derived types. - ! logical variables are declared with the same kind - ! as integers, as they are affected inthe same way by flags like -qintsize=8 - - ! type(rttov_options) :: opts ! options structure - ! type(rttov_coefs), allocatable :: coefs(:) ! coefficients structure - type(rttov_chanprof), allocatable :: chanprof(:) ! input channel/profile list - -! JKS this type doesn't exist in RTTOV v13 - KISS -! type(profile_type), allocatable :: profiles(:) ! input profiles - type(rttov_profile), allocatable :: profiles(:) ! input profiles (v13, JKS) - logical, allocatable :: calcemis(:) ! flag to indicate calculation of emissivity within rttov - type(rttov_emissivity), allocatable :: emissivity(:) ! input/output surface emissivity - -! JKS these types do not exist in RTTOV v13 - KISS -! type(transmission_type) :: transmission ! output transmittances -! type(radiance_type) :: radiance ! output radiances - type(rttov_transmission) :: transmission ! output transmittances (v13, JKS) - type(rttov_radiance) :: radiance ! output radiances (v13, JKS) - - integer, allocatable :: instrument(:,:) ! instrument id (3 x n_instruments) - integer, allocatable :: nchan(:) ! number of channels per instrument - integer, allocatable :: ichan(:,:) ! channel list per instrument - - integer :: asw - integer :: mxchn - integer :: nrttovid ! maximum number of instruments - integer :: no_id ! instrument loop index - integer :: i, j, jch - integer :: nprof ! number of calls to rttov - integer :: nch ! intermediate variable - integer :: errorstatus - integer :: ich, ich_temp, nchanprof, nchannels, chan - integer :: alloc_status(60) - - real(wp), allocatable :: input_emissivity (:) - - character (len=14) :: nameofroutine = 'rttov_multprof' - - logical :: refrac, solrad, laerosl, lclouds, lsun, all_channels - - ! local variables for input arguments that need type casting to avoid type-mismatch with - ! rttov kinds. this happens with some compiler flags (-qintsize=8). - integer :: prof_num - integer :: nlevels - - ! -------------------------------------------------------------------------- - ! 0. initialise cosp-specific things - ! -------------------------------------------------------------------------- - - ! type-casting of input arguments that need to be passed to rttov - prof_num = prf_num_in - nlevels = nlevels_in - nprof = prof_num - - ! currently we plan to calculate only 1 instrument per call - nrttovid = 1 - mxchn = nch_in - - errorstatus = 0 - alloc_status(:) = 0 - - ! allocate(coefs(nrttovid), stat = alloc_status(1)) - - ! allocate(instrument(3, nrttovid), stat = alloc_status(4)) - - !maximum number of channels allowed for one instrument is mxchn - ! allocate(surfem(nch_in, nrttovid), stat = alloc_status(11)) - allocate(ichan(nch_in, nrttovid), stat = alloc_status(12)) - call rttov_error('ichan mem allocation error for profile array' , lalloc = .true.) - - - do no_id = 1, nrttovid - ichan(:, no_id) = ichan_in - enddo - - asw = 1 ! switch for allocation passed into rttov subroutines - - ! allocate input profile arrays - allocate(profiles(nprof), stat = alloc_status(1)) - call rttov_error('Profile mem allocation error' , lalloc = .true.) - - call rttov_alloc_prof( & - errorstatus, & - nprof, & - profiles, & - nlevels, & - opts, & - asw, & - coefs = coef_rttov, & - init = .true.) - call rttov_error('Profile 2 mem allocation error' , lalloc = .true.) - ! -------------------------------------------------------------------------- - ! 5. store profile data in profile type - ! -------------------------------------------------------------------------- - do i = 1, nprof - profiles(i)%p(:) = p_in(i, :) - profiles(i)%t(:) = t_in(i, :) - profiles(i)%q(:) = q_in(i, :) - - where(profiles(i)%q(:) < 1e-4) - profiles(i)%q(:) = 1e-4 - end where - - profiles(i)%cfraction = 0. - profiles(i)%ctp = 500. - - ! 2m parameters - profiles(i)%s2m%p = p_surf(i) - profiles(i)%s2m%t = t_surf(i) - profiles(i)%s2m%q = q_surf(i) - profiles(i)%s2m%u = u_surf(i) ! dar: hard-coded at 2ms-1? - profiles(i)%s2m%v = v_surf(i) ! dar: hard-coded at 2ms-1? - profiles(i)%s2m%wfetc = 10000. ! dar: default? - - ! skin variables for emissivity calculations - profiles(i)%skin%t = t_skin(i) - - ! fastem coefficients - for mw calculations - profiles(i)%skin%fastem(1) = 3.0 - profiles(i)%skin%fastem(2) = 5.0 - profiles(i)%skin%fastem(3) = 15.0 - profiles(i)%skin%fastem(4) = 0.1 - profiles(i)%skin%fastem(5) = 0.3 - - profiles(i)%zenangle = zenang_in ! pass in from cosp - - profiles(i)%azangle = 0. ! hard-coded in rttov9 int - - profiles(i)%latitude = latitude(i) - profiles(i)%longitude = longitude(i) - profiles(i)%elevation = h_surf(i) - - profiles(i)%sunzenangle = 0. ! hard-coded in rttov9 int - profiles(i)%sunazangle = 0. ! hard-coded in rttov9 int - - ! surface type - ! land-sea mask indicates proportion of land in grid - if (lsmask(i) < 0.5) then - profiles(i)%skin%surftype = surftype_sea - else - profiles(i)%skin%surftype = surftype_land - endif - ! sea-ice fraction - if (seaice(i) >= 0.5) then - profiles(i)%skin%surftype = surftype_seaice - endif - - ! dar: hard-coded to 1 (=ocean water) in rttov 9 int - profiles(i)%skin%watertype = 1 - profiles(i) %idg = 0. - profiles(i) %ish = 0. - enddo - ! end of 5. - - ich_temp = 1 - nchannels = nch_in - do no_id = 1, nrttovid - - ! -------------------------------------------------------------------------- - ! 3. build the list of profile/channel indices in chanprof - ! -------------------------------------------------------------------------- - - allocate(nchan(nprof)) ! number of channels per profile - nchan(:) = size(ichan(:,no_id)) ! = nch_in - - ! size of chanprof array is total number of channels over all profiles - ! square in this case - here same channels done for all profiles - nchanprof = sum(nchan(:)) - - ! pack channels and input emissivity arrays - allocate(chanprof(nchanprof)) - ! allocate(emis(nchanprof)) - chanprof(:)%chan =0 - - nch = 0 - do j = 1, nprof - do jch = 1, nchan(j) - nch = nch + 1 - chanprof(nch)%prof = j - if(ichan(jch, no_id) < 1) then - errorstatus = errorstatus_fatal - call rttov_error('Sensor channel number must be 1 or greater' , lalloc = .true.) - else - chanprof(nch)%chan = ichan(jch, no_id) - endif - enddo - enddo - ! end of 3. - - ! allocate output radiance arrays - call rttov_alloc_rad( & - errorstatus, & - nchanprof, & - radiance, & - nlevels - 1, & ! nlayers - asw) - call rttov_error('allocation error for radiance arrays' , lalloc = .true.) - - ! allocate transmittance structure - call rttov_alloc_transmission( & - errorstatus, & - transmission, & - nlevels - 1, & - nchanprof, & - asw, & - init=.true.) - call rttov_error('allocation error for transmission arrays' , lalloc = .true.) - - ! allocate arrays for surface emissivity - allocate(calcemis(nchanprof), stat=alloc_status(1)) - allocate(emissivity(nchanprof), stat=alloc_status(2)) - call rttov_error('mem allocation error for emissivity arrays' , lalloc = .true.) - - call rttov_get_emis( & - & errorstatus, & - & opts, & - & chanprof, & - & profiles, & - & coef_rttov, & - !& resolution=resolution, & ! *** MW atlas native - ! resolution is 0.25 degree lat/lon; if you know better - ! value for satellite footprint (larger than this) then - ! you can specify it here - & emissivity=emissivity(:)%emis_in) - ! & emissivity(:)%emis_in) - - call rttov_error('Get emissivity error' , lalloc = .true.) - calcemis(:) = .false. - ! calculate emissivity for missing and ocean location (fastem) - where (emissivity(:)%emis_in <= 0.0) - calcemis(:) = .true. - endwhere - - call rttov_direct( & - errorstatus, &! out - chanprof, & - opts, & - profiles, &! in - coef_rttov, &! in - transmission, &! out - radiance, & - calcemis = calcemis, &! in - emissivity = emissivity) ! inout - call rttov_error('rttov_direct error', lalloc = .true.) - - tbs(1:prof_num , ich_temp:ich_temp + size(ichan(:,no_id)) - 1) = & - transpose(reshape(radiance%bt(1:nchanprof), (/ size(ichan(:,no_id)), prof_num/) )) - - ich_temp = ich_temp + size(ichan(:,no_id)) - - ! -------------------------------------------------------------------------- - ! 8. deallocate all rttov arrays and structures - ! -------------------------------------------------------------------------- - deallocate (nchan, stat=alloc_status(3)) - deallocate (chanprof, stat=alloc_status(4)) - deallocate (emissivity, stat=alloc_status(5)) - deallocate (calcemis, stat=alloc_status(6)) - call rttov_error('rttov array deallocation error', lalloc = .true.) - - asw = 0 ! switch for deallocation passed into rttov subroutines - - ! deallocate radiance arrays - call rttov_alloc_rad(errorstatus, nchannels, radiance, nlevels - 1, asw) - call rttov_error('radiance deallocation error', lalloc = .true.) - - ! deallocate transmission arrays - call rttov_alloc_transmission(errorstatus, transmission, nlevels - 1, nchannels, asw) - call rttov_error('transmission deallocation error', lalloc = .true.) - - enddo - - ! deallocate profile arrays - call rttov_alloc_prof(errorstatus, nprof, profiles, nlevels, opts, asw) - call rttov_error('profile deallocation error', lalloc = .true.) - - deallocate(profiles, stat=alloc_status(1)) - call rttov_error('mem deallocation error for profile array', lalloc= .true.) - - contains - - subroutine rttov_error(msg, lalloc) - character(*) :: msg - logical :: lalloc - - if(lalloc) then - if (any(alloc_status /= 0)) then - write(*,*) msg - errorstatus = 1 - call rttov_exit(errorstatus) - endif - else - if (errorstatus /= errorstatus_success) then - write(*,*) msg - call rttov_exit(errorstatus) - endif - endif - end subroutine rttov_error - - end subroutine rttov_multprof - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - !----------------- subroutine cosp_rttov_mwscatt --------------- - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - subroutine cosp_rttov_mwscatt(& - nch_in, & ! number of channels - ichan_in, & ! channel indices - surfem_in, & ! surface emissivity values - prf_num_in, & ! number of profiles to simulate - nlevels_in, & ! number of pressure levels - plat_in, & ! platform number - sat_in, & ! satellite number - sens_in, & ! instrument number - opts, & -! opts_scatt, & - coef_rttov, & - coef_scatt, & - zenang_in, & ! zenith angle - p_in, & ! pressure [hpa] - ph_in, & ! pressure on half levels [hpa] - t_in, & ! temperature [ k ] - q_in, & ! specific humidity [ ppmv ] - o3_in, & ! ozone vmr [ ppmv ] - clw_in, & ! cloud water [0-1] - ciw_in, & ! cloud ice [0-1] - cc_in, & ! effective cloud fraction [0-1] - totalice_in,& ! total ice, except snow [kg/kg] or [kg/m2/s] - sp_in, & ! solid precip with snow [kg/kg] or [kg/m2/s] - rain_in, & ! total liquid water [kg/kg] or [kg/m2/s] - co2_in, & ! co2 vmr [ ppmv ] *this is a single value* - ch4_in, & ! ch4 vmr [ ppmv ] *this is a single value* - n2o_in, & ! n2o vmr [ ppmv ] *this is a single value* - co_in, & ! co vmr [ ppmv ] *this is a single value* - h_surf, & ! surface height [ m ] - u_surf, & ! u wind at 10 m [ m/s ] - v_surf, & ! v wind at 10 m [ m/s ] - t_skin, & ! skin temperatre [ k ] - p_surf, & ! surface pressure - t_surf, & ! 1.5 m temperature [ k ] - q_surf, & ! 1.5 m specific humidity [ ppmv ] - lsmask, & ! land sea mask - seaice, & ! seaice fraction - latitude, & ! latitude [ deg north ] - longitude, & ! longitude [ deg east ] - use_totalice,& ! separate ice and snow, or total ice hydrometeor types - mmr_snowrain,& ! set units for snow and rain: if true units are kg/kg (the default) - cfrac, & ! opts_scatt%lusercfrac=true., supply the effective cloud fraction - tbs & ! brightness temperature [ k ] (output) - ) - - - - - - implicit none - - !------ input arguments. no rttov kinds should be used here ----------------- - integer, intent(in) :: nch_in ! number of channels to be computed - integer, intent(in) :: ichan_in(nch_in) ! indices of selected channels - real(wp), intent(in) :: surfem_in(nch_in) ! surface emissivities for the channels - integer, intent(in) :: prf_num_in - integer, intent(in) :: nlevels_in - integer, intent(in) :: plat_in ! satellite platform - integer, intent(in) :: sat_in ! satellite number - integer, intent(in) :: sens_in ! satellite sensor - real(wp), intent(in) :: zenang_in ! satellite zenith angle - - type(rttov_options) :: opts -! type(rttov_options_scatt) :: opts_scatt ! not in v13 JKS - KISS - type(rttov_coefs) :: coef_rttov -! type(rttov_scatt_coef) :: coef_scatt ! not in v13 JKS - KISS - - real(wp), intent(in) :: p_in(prf_num_in, nlevels_in) ! pressure profiles - real(wp), intent(in) :: t_in(prf_num_in, nlevels_in) ! temperature profiles - real(wp), intent(in) :: q_in(prf_num_in, nlevels_in) ! humidity profiles - real(wp), intent(in) :: o3_in(prf_num_in, nlevels_in) ! ozone profiles - real(wp), intent(in) :: clw_in(prf_num_in, nlevels_in) - real(wp), intent(in) :: ciw_in(prf_num_in, nlevels_in) - real(wp), intent(in) :: cc_in(prf_num_in, nlevels_in) - real(wp), intent(in) :: totalice_in(prf_num_in, nlevels_in) - real(wp), intent(in) :: sp_in(prf_num_in, nlevels_in) - real(wp), intent(in) :: rain_in(prf_num_in, nlevels_in) - real(wp), intent(in) :: ph_in(prf_num_in, nlevels_in+1) - - ! the following trace gases contain constant values - real(wp), intent(in) :: co2_in ! carbon dioxide - real(wp), intent(in) :: ch4_in ! methane - real(wp), intent(in) :: n2o_in ! n2o - real(wp), intent(in) :: co_in ! carbon monoxide - real(wp), intent(in) :: h_surf(prf_num_in) ! surface height - real(wp), intent(in) :: u_surf(prf_num_in) ! u component of surface wind - real(wp), intent(in) :: v_surf(prf_num_in) ! v component of surface wind - real(wp), intent(in) :: t_skin(prf_num_in) ! surface skin temperature - real(wp), intent(in) :: p_surf(prf_num_in) ! surface pressure - real(wp), intent(in) :: t_surf(prf_num_in) ! 1.5 m temperature - real(wp), intent(in) :: q_surf(prf_num_in) ! 1.5 m specific humidity - real(wp), intent(in) :: lsmask(prf_num_in) ! land-sea mask - real(wp), intent(in) :: seaice(prf_num_in) ! seaice fraction - real(wp), intent(in) :: latitude(prf_num_in) ! latitude - real(wp), intent(in) :: longitude(prf_num_in) ! longitude - logical, intent(in) :: cfrac, use_totalice, mmr_snowrain - - real(wp), intent(inout) :: tbs(prf_num_in, nch_in) ! tbs (in the right format) - !****************** local variables ********************************************** - logical , allocatable :: calcemis (:) - type(rttov_emissivity) , allocatable :: emissivity (:) - integer , allocatable :: frequencies (:) - type(rttov_chanprof) , allocatable :: chanprof (:) ! channel and profile indices - type(rttov_profile) , allocatable :: profiles (:) -! type(profile_type) , allocatable :: profiles (:) ! JKS - this type is not in v13 -! type(profile_cloud_type) , allocatable :: cld_profiles(:) ! JKS - KISS, v13 cloud types unclear - - integer, allocatable :: ichan(:,:) ! channel list per instrument - - integer :: errorstatus -! type (radiance_type) :: radiance ! JKS - this type is not in v13 - type (rttov_radiance) :: radiance ! JKS - ! type (rttov_options) :: opts ! defaults to everything optional switched off - ! type (rttov_options_scatt) :: opts_scatt - ! type (rttov_coefs) :: coef_rttov - ! type (rttov_scatt_coef) :: coef_scatt - - ! integer, allocatable :: instrument (:,:) - integer :: j,k,asw - integer :: nchanxnprof, ninstruments - real(wp) :: zenangle - character (len=256) :: outstring - integer :: alloc_status(60) - -#include "rttov_init_rad.interface" -#include "rttov_scatt_setupindex.interface" -#include "rttov_scatt.interface" -#include "rttov_alloc_rad.interface" -#include "rttov_alloc_prof.interface" -#include "rttov_alloc_scatt_prof.interface" -#include "rttov_get_emis.interface" -#include "rttov_boundaryconditions.interface" - - errorstatus = 0 - alloc_status(:) = 0 - ninstruments = 1 ! number of sensors or platforms - - allocate(ichan(nch_in, ninstruments), stat = alloc_status(3)) - - do j = 1, ninstruments - ichan(:, j) = ichan_in - enddo - - nchanxnprof = prf_num_in * nch_in ! total channels to simulate * profiles - - allocate (chanprof(nchanxnprof)) - allocate (frequencies(nchanxnprof)) - allocate (emissivity(nchanxnprof)) - allocate (calcemis(nchanxnprof)) - allocate (profiles(prf_num_in)) - allocate (cld_profiles(prf_num_in)) - - ! request rttov / fastem to calculate surface emissivity - calcemis = .true. - emissivity % emis_in = 0.0 - - ! setup indices - call rttov_scatt_setupindex ( & - & prf_num_in, & ! in - & nch_in, & ! in - & coef_rttov%coef, & ! in - & nchanxnprof, & ! in - & chanprof, & ! out - & frequencies) ! out - - ! allocate profiles (input) and radiance (output) structures - asw = 1 - call rttov_alloc_prof( errorstatus,prf_num_in,profiles,nlevels_in,opts,asw, init = .true.) - call rttov_alloc_scatt_prof(prf_num_in,cld_profiles, nlevels_in, .false., 1, init = .true.) - call rttov_alloc_rad(errorstatus,nchanxnprof,radiance,nlevels_in-1,asw) - - ! fill the profile structures with data - do j = 1, prf_num_in - profiles(j)%latitude = latitude(j) - profiles(j)%longitude = longitude(j) - profiles(j)%elevation = h_surf(j) - profiles(j)%sunzenangle = 0.0 ! hard-coded in rttov9 int - profiles(j)%sunazangle = 0.0 ! hard-coded in rttov9 int - profiles(j)%azangle = 0.0 - profiles(j)%zenangle = zenang_in - profiles(j)%s2m%t = t_surf(j) - profiles(j)%s2m%q = q_surf(j) - profiles(j)%s2m%u = u_surf(j) - profiles(j)%s2m%v = v_surf(j) - profiles(j)%s2m%wfetc = 10000. - profiles(j)%skin%t = t_skin(j) - profiles(j)%skin%watertype = 1 ! ocean water - if (lsmask(j) < 0.5) then - profiles(j)%skin%surftype = surftype_sea - else - profiles(j)%skin%surftype = surftype_land - endif - if (seaice(j) >= 0.5) then - profiles(j)%skin%surftype = surftype_seaice - endif - profiles(j)%skin%fastem(1) = 3.0 - profiles(j)%skin%fastem(2) = 5.0 - profiles(j)%skin%fastem(3) = 15.0 - profiles(j)%skin%fastem(4) = 0.1 - profiles(j)%skin%fastem(5) = 0.3 - profiles(j)%cfraction = 0.0 - profiles(j)%ctp = 500.0 ! not used but still required by rttov - profiles(j)%p(:) = p_in(j,:) - profiles(j)%t(:) = t_in(j,:) - profiles(j)%q(:) = q_in(j,:) - profiles(j)%idg = 0. - profiles(j)%ish = 0. - where(profiles(j)%q(:) < 1e-4) - profiles(j)%q(:) = 1e-4 - end where - cld_profiles(j)%ph(:) = ph_in(j,:) - cld_profiles(j)%cc(:) = cc_in(j,:) - cld_profiles(j)%clw(:) = clw_in(j,:) - cld_profiles(j)%ciw(:) = ciw_in(j,:) - cld_profiles(j)%rain(:) = rain_in(j,:) - cld_profiles(j)%sp(:) = sp_in(j,:) - profiles(j)%s2m%p = cld_profiles(j)%ph(nlevels_in+1) - enddo - - call rttov_get_emis( & - & errorstatus, & - & opts, & - & chanprof, & - & profiles, & - & coef_rttov, & - ! & resolution=resolution, & ! *** MW atlas native resolution is - ! 0.25 degree lat/lon; if you know better value for satellite - ! footprint (larger than this) then you can specify it here - & emissivity=emissivity(:)%emis_in) - if (errorstatus /= errorstatus_success) then - write(*,*) 'In COSP_RTTOV11: Error RTTOV_GET_EMIS!' - call rttov_exit(errorstatus) - endif - - calcemis(:) = .false. - where (emissivity(:)%emis_in <= 0.) - calcemis(:) = .true. - endwhere - -! OLD: Call RTTOV forward model -! call rttov_scatt (& -! & errorstatus, &! out -! & opts_scatt, &! in -! & nlevels_in, &! in -! & chanprof, &! in -! & frequencies, &! in -! & profiles, &! in -! & cld_profiles, &! in -! & coef_rttov, &! in -! & coef_scatt, &! in -! & calcemis, &! in -! & emissivity, &! in -! & radiance) ! out - -! if (errorstatus /= errorstatus_success) then -! write(*,*) 'In COSP_RTTOV11: Error RTTOV_SCATT!' -! call rttov_exit(errorstatus) -! endif -! END Old RTTOV Call - -! New rttov_direct Call (from example_aer_file_fwd) - if (nthreads <= 1) then - call rttov_direct( & - errorstatus, &! out error flag - chanprof, &! in channel and profile index structure - opts, &! in options structure - profiles, &! in profile array - coef_rttov, &! in coefficients structure - transmission, &! inout computed transmittances - radiance, &! inout computed radiances - calcemis = calcemis, &! in flag for internal emissivity calcs - emissivity = emissivity, &! inout input/output emissivities per channel - calcrefl = calcrefl, &! in flag for internal BRDF calcs - reflectance = reflectance) ! inout input/output BRDFs per channel - else - call rttov_parallel_direct( & - errorstatus, &! out error flag - chanprof, &! in channel and profile index structure - opts, &! in options structure - profiles, &! in profile array - coef_rttov, &! in coefficients structure - transmission, &! inout computed transmittances - radiance, &! inout computed radiances - calcemis = calcemis, &! in flag for internal emissivity calcs - emissivity = emissivity, &! inout input/output emissivities per channel - calcrefl = calcrefl, &! in flag for internal BRDF calcs - reflectance = reflectance,&! inout input/output BRDFs per channel - nthreads = nthreads) ! in number of threads to use - endif - - if (errorstatus /= errorstatus_success) then - write (*,*) 'rttov_direct error' - call rttov_exit(errorstatus) - endif -! END New RTTOV Call - - - !write(*,*) 'Checking emissivities: ', maxval(emissivity(:)%emis_out), \ - ! minval(emissivity(:)%emis_out) - tbs(1:prf_num_in,1:1+size(ichan(:,1))-1) = & - transpose(reshape(radiance%bt(1:nchanxnprof),(/ size(ichan(:,1)),prf_num_in/) )) - - ! deallocate all storage - asw = 0 - ! call rttov_dealloc_coefs(errorstatus,coef_rttov) - ! call rttov_dealloc_scattcoeffs(coef_scatt) - call rttov_alloc_prof(errorstatus,prf_num_in,profiles,nlevels_in,opts,asw) - call rttov_alloc_scatt_prof(prf_num_in,cld_profiles,nlevels_in,.false.,asw) - call rttov_alloc_rad(errorstatus,nchanxnprof,radiance,nlevels_in-1,asw) - deallocate(ichan,chanprof,frequencies,emissivity,calcemis) !instrument, - !*************************************************************************** - !-------- end section -------- - !*************************************************************************** - end subroutine cosp_rttov_mwscatt - function construct_rttov_coeffilename(platform,satellite,instrument) - ! Inputs - integer,intent(in) :: platform,satellite,instrument - ! Outputs - character(len=256) :: construct_rttov_coeffilename - ! Local variables - character(len=256) :: coef_file - integer :: error - - ! Initialize - error = 0 - - ! Platform - if (platform .eq. 1) coef_file = 'rtcoef_noaa_' - if (platform .eq. 10) coef_file = 'rtcoef_metop_' - if (platform .eq. 11) coef_file = 'rtcoef_envisat_' - if (platform .ne. 1 .and. platform .ne. 10 .and. platform .ne. 11) then - error=error+1 - write ( *,* ) 'Unsupported platform ID ',platform - return - endif - - ! Satellite - if (satellite .lt. 10) then - coef_file = trim(coef_file) // char(satellite+48) - else if (satellite .lt. 100) then - coef_file = trim(coef_file) // char(int(satellite/10)+48) - coef_file = trim(coef_file) // char(satellite-int(satellite/10)*10+48) - else - error=error+1 - write ( *,* ) 'Unsupported satellite number ',satellite - return - endif - - ! Sensor - if (sensor .eq. 3) coef_file = trim(coef_file) // '_amsua.dat' - if (sensor .eq. 5) coef_file = trim(coef_file) // '_avhrr.dat' - if (sensor .eq. 49) coef_file = trim(coef_file) // '_mwr.dat' - if (sensor .ne. 3 .and. sensor .ne. 5 .and. sensor .ne. 49) then - error=error+1 - write ( *,* ) 'Unsupported sensor number ', sensor - return - endif - - if (error .eq. 0) construct_rttov_coeffilename=coef_file - - end function construct_rttov_coeffilename - function construct_rttov_scatfilename(platform,satellite,instrument) - ! Inputs - integer,intent(in) :: platform,satellite,instrument - ! Outputs - character(len=256) :: construct_rttov_scatfilename - ! Local variables - character(len=256) :: coef_file - integer :: error - - ! Initialize - error = 0 - - ! Platform - if (platform .eq. 1) coef_file = 'sccldcoef_noaa_' - if (platform .eq. 10) coef_file = 'sccldcoef_metop_' - if (platform .eq. 11) coef_file = 'sccldcoef_envisat_' - if (platform .ne. 1 .and. platform .ne. 10 .and. platform .ne. 11) then - error=error+1 - write ( *,* ) 'Unsupported platform ID ',platform - return - endif - - ! Satellite - if (satellite .lt. 10) then - coef_file = trim(coef_file) // char(satellite+48) - else if (satellite .lt. 100) then - coef_file = trim(coef_file) // char(int(satellite/10)+48) - coef_file = trim(coef_file) // char(satellite-int(satellite/10)*10+48) - else - error=error+1 - write ( *,* ) 'Unsupported satellite number ',satellite - return - endif - - ! Sensor - if (sensor .eq. 3) coef_file = trim(coef_file) // '_amsua.dat' - if (sensor .eq. 5) coef_file = trim(coef_file) // '_avhrr.dat' - if (sensor .eq. 49) coef_file = trim(coef_file) // '_mwr.dat' - if (sensor .ne. 3 .and. sensor .ne. 5 .and. sensor .ne. 49) then - error=error+1 - write ( *,* ) 'Unsupported sensor number ', sensor - return - endif - - if (error .eq. 0) construct_rttov_scatfilename=coef_file - - end function construct_rttov_scatfilename - -end module mod_cosp_rttov From 6efc013dd0fb630f3e65c0c7852acdd3fb01cfb0 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 18 Jul 2023 15:57:30 -0600 Subject: [PATCH 068/159] Add CESM unitn I/O functionality --- src/cosp.F90 | 18 ++++++++---- src/simulator/cosp_rttov_interface_v13.F90 | 34 +++++++++++++++------- 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/cosp.F90 b/src/cosp.F90 index 60b088e5a7..cd4b3aa918 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -1819,7 +1819,7 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La cloudsat_radar_freq, cloudsat_k2, cloudsat_use_gas_abs, cloudsat_do_ray, & isccp_top_height, isccp_top_height_direction, surface_radar, rcfg, lusevgrid, & luseCSATvgrid, Nvgrid, Nlevels, cloudsat_micro_scheme, & - rttov_Ninstruments, rttov_instrument_namelists,rttov_configs) + rttov_Ninstruments, rttov_instrument_namelists,rttov_configs,unitn) ! INPUTS logical,intent(in) :: Lisccp,Lmodis,Lmisr,Lcloudsat,Lcalipso,LgrLidar532,Latlid,Lparasol @@ -1850,6 +1850,9 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La ! OUTPUTS type(radar_cfg) :: rcfg type(rttov_cfg), dimension(:), allocatable :: rttov_configs + + ! Optional args + integer,intent(in),Optional :: unitn ! Used for io limits ! Local variables integer :: i @@ -1899,10 +1902,15 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La ! Could print diagnostic on timing here. if (Lrttov) then call cpu_time(driver_time(1)) - call cosp_rttov_init(Lrttov,Nlevels,rttov_Ninstruments, & - rttov_instrument_namelists, & - rttov_configs) - + if (present(unitn)) then + call cosp_rttov_init(Lrttov,Nlevels,rttov_Ninstruments, & + rttov_instrument_namelists, & + rttov_configs,unitn=unitn) + else + call cosp_rttov_init(Lrttov,Nlevels,rttov_Ninstruments, & + rttov_instrument_namelists, & + rttov_configs) + end if call cpu_time(driver_time(2)) ! print*,'Time to run cosp_rttov_init: ',driver_time(2)-driver_time(1) endif diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 7f8d8973d8..f46073047e 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -123,14 +123,13 @@ MODULE MOD_COSP_RTTOV_INTERFACE rad_total_pc(:,:) end type rttov_output - CONTAINS !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_init !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SUBROUTINE COSP_RTTOV_INIT(Lrttov, Nlevels,Ninstruments,instrument_namelists, & - rttov_configs) + rttov_configs, unitn) logical,intent(in) :: & Lrttov @@ -141,6 +140,8 @@ SUBROUTINE COSP_RTTOV_INIT(Lrttov, Nlevels,Ninstruments,instrument_namelists, instrument_namelists ! Array of paths to RTTOV instrument namelists type(rttov_cfg), dimension(:), allocatable :: & ! intent(out)? rttov_configs + integer,intent(in),Optional :: unitn ! Used for io limits + ! Local variables integer :: & inst_idx ! iterator @@ -153,7 +154,11 @@ SUBROUTINE COSP_RTTOV_INIT(Lrttov, Nlevels,Ninstruments,instrument_namelists, ! print*,'instrument_namelists(inst_idx): ',instrument_namelists(inst_idx) ! print*,'kind(rttov_configs(inst_idx)): ',kind(rttov_configs(inst_idx)) ! print*,'rttov_configs(inst_idx): ',rttov_configs(inst_idx) - call cosp_rttov_init_s(Nlevels,instrument_namelists(inst_idx),rttov_configs(inst_idx)) + if (present(unitn)) then + call cosp_rttov_init_s(Nlevels,instrument_namelists(inst_idx),rttov_configs(inst_idx),unitn=unitn) + else + call cosp_rttov_init_s(Nlevels,instrument_namelists(inst_idx),rttov_configs(inst_idx)) + endif end do @@ -163,15 +168,17 @@ END SUBROUTINE COSP_RTTOV_INIT ! SUBROUTINE cosp_rttov_init !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & - rttov_config) + rttov_config, unitn) integer,intent(in) :: & Nlevels - character(len=128),intent(in) :: & + character(len=128),intent(in) :: & namelist_filepath ! Array of paths to RTTOV instrument namelists - type(rttov_cfg),intent(out) :: & ! intent(out)? + type(rttov_cfg),intent(out) :: & ! intent(out)? rttov_config - + + integer,intent(in),Optional :: unitn ! Used for io limits + ! Local variables character(len=256),target :: & channel_filepath, & @@ -239,9 +246,16 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Read in namelists !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - open(10,file=namelist_filepath,status='unknown') - read(10,nml=RTTOV_INPUT) - close(10) + ! Handle indices of files already opened (for CESM integration) + if (present(unitn)) then + open(unitn,file=namelist_filepath,status='unknown') + read(unitn,nml=RTTOV_INPUT) + close(unitn) + else + open(10,file=namelist_filepath,status='unknown') + read(10,nml=RTTOV_INPUT) + close(10) + endif ! Set logicals for RTTOV config rttov_config%Lrttov_bt = Lrttov_bt From 62c679603be2434513869a52c3f3b4c8d5ec11a4 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 18 Jul 2023 15:57:52 -0600 Subject: [PATCH 069/159] Old namelist clean-up for multifile namelist I/O --- driver/run/cosp2_input_rttov_nl.um_global.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/driver/run/cosp2_input_rttov_nl.um_global.txt b/driver/run/cosp2_input_rttov_nl.um_global.txt index bc0eadd1ae..a4ecf2914d 100644 --- a/driver/run/cosp2_input_rttov_nl.um_global.txt +++ b/driver/run/cosp2_input_rttov_nl.um_global.txt @@ -83,8 +83,7 @@ !-------------- RTTOV inputs !---------------------------------------------------------------------------------- rttov_Ninstruments=3, -! rttov_instrument_namelists = (/'test1','test2','test3'/), -! rttov_instrument_namelists(1:3) = (/'test1','test2','test3'/), + rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt', Lrttov_localtime=.false., ! May not be necessary at this level rttov_Nlocaltime=2, rttov_localtime=10.0,13.0, ! To implement local time From 87442f3759a7dd3f0d633323a14625e78af3cfdc Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 19 Jul 2023 11:52:32 -0600 Subject: [PATCH 070/159] Modify character length of instrument namelist objects and add print statements --- driver/src/cosp2_test.F90 | 4 +-- src/cosp.F90 | 3 ++- src/simulator/cosp_rttov_interfaceSTUB.F90 | 25 ++++++++--------- src/simulator/cosp_rttov_interface_v13.F90 | 31 ++++++++++++++++++---- 4 files changed, 43 insertions(+), 20 deletions(-) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 079fdda475..27638dce25 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -159,9 +159,9 @@ program cosp2_test dinput ! Directory where the input files are located character(len=600) :: & fileIN ! dinput+finput - character(len=128), dimension(50) :: & ! Arbitrary limit of 50 should be fine. + character(len=256), dimension(50) :: & ! Arbitrary limit of 50 should be fine. rttov_instrument_namelists ! Input of paths to RTTOV instrument namelists - character(len=128), allocatable :: & + character(len=256), allocatable :: & rttov_instrument_namelists_final(:) ! Array of paths to RTTOV instrument namelists namelist/COSP_INPUT/overlap, isccp_topheight, isccp_topheight_direction, npoints, & diff --git a/src/cosp.F90 b/src/cosp.F90 index cd4b3aa918..7955a93bc0 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -1844,7 +1844,7 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La cloudsat_micro_scheme ! Microphysical scheme used by CLOUDSAT real(wp),dimension(10) :: driver_time - type(character(len=128)), dimension(rttov_Ninstruments) :: & + type(character(len=256)), dimension(rttov_Ninstruments) :: & rttov_instrument_namelists ! Array of paths to RTTOV instrument namelists ! OUTPUTS @@ -1902,6 +1902,7 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La ! Could print diagnostic on timing here. if (Lrttov) then call cpu_time(driver_time(1)) + print*,'rttov_instrument_namelists: ',rttov_instrument_namelists ! JKS test if (present(unitn)) then call cosp_rttov_init(Lrttov,Nlevels,rttov_Ninstruments, & rttov_instrument_namelists, & diff --git a/src/simulator/cosp_rttov_interfaceSTUB.F90 b/src/simulator/cosp_rttov_interfaceSTUB.F90 index 4ee4760eae..5e1471be35 100644 --- a/src/simulator/cosp_rttov_interfaceSTUB.F90 +++ b/src/simulator/cosp_rttov_interfaceSTUB.F90 @@ -99,28 +99,28 @@ MODULE MOD_COSP_RTTOV_INTERFACE !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE cosp_rttov_ini2 + ! SUBROUTINE cosp_rttov_ini2 - JKS can I delete this?? !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_INI2(Nlevels,Ninstruments,instrument_namelists, & - rttov_config) +! SUBROUTINE COSP_RTTOV_INI2(Nlevels,Ninstruments,instrument_namelists, & +! rttov_config) - integer,intent(in) :: & - Nlevels, & - Ninstruments - type(character(len=256)), dimension(Ninstruments) :: & - instrument_namelists ! Array of paths to RTTOV instrument namelists - type(rttov_cfg), dimension(Ninstruments) :: & ! intent(out)? - rttov_config +! integer,intent(in) :: & +! Nlevels, & +! Ninstruments +! type(character(len=256)), dimension(Ninstruments) :: & +! instrument_namelists ! Array of paths to RTTOV instrument namelists +! type(rttov_cfg), dimension(Ninstruments) :: & ! intent(out)? +! rttov_config - END SUBROUTINE COSP_RTTOV_INI2 +! END SUBROUTINE COSP_RTTOV_INI2 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_init !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SUBROUTINE COSP_RTTOV_INIT(Lrttov,Nlevels,Ninstruments,instrument_namelists, & - rttov_configs) + rttov_configs,unitn) logical,intent(inout) :: & Lrttov @@ -131,6 +131,7 @@ SUBROUTINE COSP_RTTOV_INIT(Lrttov,Nlevels,Ninstruments,instrument_namelists, instrument_namelists ! Array of paths to RTTOV instrument namelists type(rttov_cfg), dimension(:), allocatable :: & ! intent(out)? rttov_configs + integer,intent(in),Optional :: unitn ! Used for io limits Lrttov = .false. diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index f46073047e..b6ddf32964 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -136,7 +136,7 @@ SUBROUTINE COSP_RTTOV_INIT(Lrttov, Nlevels,Ninstruments,instrument_namelists, integer,intent(in) :: & Nlevels, & Ninstruments - type(character(len=128)), dimension(Ninstruments) :: & + type(character(len=256)), dimension(Ninstruments) :: & instrument_namelists ! Array of paths to RTTOV instrument namelists type(rttov_cfg), dimension(:), allocatable :: & ! intent(out)? rttov_configs @@ -155,6 +155,7 @@ SUBROUTINE COSP_RTTOV_INIT(Lrttov, Nlevels,Ninstruments,instrument_namelists, ! print*,'kind(rttov_configs(inst_idx)): ',kind(rttov_configs(inst_idx)) ! print*,'rttov_configs(inst_idx): ',rttov_configs(inst_idx) if (present(unitn)) then + print*,'instrument_namelists(inst_idx): ',instrument_namelists(inst_idx) ! JKS check call cosp_rttov_init_s(Nlevels,instrument_namelists(inst_idx),rttov_configs(inst_idx),unitn=unitn) else call cosp_rttov_init_s(Nlevels,instrument_namelists(inst_idx),rttov_configs(inst_idx)) @@ -172,7 +173,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & integer,intent(in) :: & Nlevels - character(len=128),intent(in) :: & + character(len=256),intent(in) :: & namelist_filepath ! Array of paths to RTTOV instrument namelists type(rttov_cfg),intent(out) :: & ! intent(out)? rttov_config @@ -230,6 +231,10 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & ipcreg, & npcscores + ! JKS for checking errors in filenames. + character(len=256) :: imsg !<-- some suitable length, say XX=256 + integer :: erro + ! Read RTTOV namelist fields namelist/RTTOV_INPUT/Lrttov_bt,Lrttov_rad,Lrttov_refl,Lrttov_cld, & ! Logicals for RTTOV configuration Lrttov_aer,Lrttov_cldparam,Lrttov_aerparam, & ! @@ -246,13 +251,29 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Read in namelists !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Handle indices of files already opened (for CESM integration) + ! Handle indices of files already opened (for CESM integration) if (present(unitn)) then - open(unitn,file=namelist_filepath,status='unknown') + open(unitn,file=namelist_filepath,status='unknown',iostat=erro,iomsg=imsg) + if (erro > 0) then + print*,'Error reading in "namelist_filepath" in COSP_RTTOV_INIT_S' + print*,'erro: ', erro + print*,'imsg: ', imsg + print*,'namelist_filepath: ',namelist_filepath + errorstatus = 1 + call rttov_exit(errorstatus) + end if read(unitn,nml=RTTOV_INPUT) close(unitn) else - open(10,file=namelist_filepath,status='unknown') + open(10,file=namelist_filepath,status='unknown',iostat=erro,iomsg=imsg) + if (erro > 0) then + print*,'Error reading in "namelist_filepath" in COSP_RTTOV_INIT_S' + print*,'erro: ', erro + print*,'imsg: ', imsg + print*,'namelist_filepath: ',namelist_filepath + errorstatus = 1 + call rttov_exit(errorstatus) + end if read(10,nml=RTTOV_INPUT) close(10) endif From 36ab3037ed1e3137127e3c7d90bc594266fc824a Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 2 Aug 2023 16:20:12 -0600 Subject: [PATCH 071/159] Add namelist inputs for RTTOV instruments to control sampling time swath --- .../run/instrument_nls/cosp2_rttov_inst1.txt | 4 ++ driver/src/cosp2_test.F90 | 3 ++ src/cosp.F90 | 2 +- src/simulator/cosp_rttov_interfaceSTUB.F90 | 19 --------- src/simulator/cosp_rttov_interface_v13.F90 | 41 ++++++++++++++----- 5 files changed, 39 insertions(+), 30 deletions(-) diff --git a/driver/run/instrument_nls/cosp2_rttov_inst1.txt b/driver/run/instrument_nls/cosp2_rttov_inst1.txt index 6676db2ce3..6f94598644 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst1.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst1.txt @@ -73,4 +73,8 @@ ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel rttov_nthreads=16, rttov_ZenAng=0.0, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=2, ! Number of local times to sample at + rttov_localtime=0.75,13.5, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1.e2,5.6e3, ! Swath width (km) / diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 27638dce25..aca8d8d327 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -1429,6 +1429,9 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& print*,'rttov_configs(i) % Lrttov_cld: ',rttov_configs(i) % Lrttov_cld print*,'rttov_configs(i) % Lrttov_aer: ',rttov_configs(i) % Lrttov_aer print*,'rttov_configs(i) % Lrttov_pc: ',rttov_configs(i) % Lrttov_pc + print*,'rttov_configs(i) % rttov_Nlocaltime: ',rttov_configs(i) % rttov_Nlocaltime + print*,'rttov_configs(i) % rttov_localtime: ',rttov_configs(i) % rttov_localtime + print*,'rttov_configs(i) % rttov_localtime_width: ',rttov_configs(i) % rttov_localtime_width print*,'1.' x % rttov_outputs(i) % nchan_out = rttov_configs(i) % nchan_out diff --git a/src/cosp.F90 b/src/cosp.F90 index 7955a93bc0..5936e0d963 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -52,7 +52,7 @@ MODULE MOD_COSP cloudsat_preclvl,grLidar532_histBsct,atlid_histBsct USE MOD_COSP_MODIS_INTERFACE, ONLY: cosp_modis_init, modis_IN USE MOD_COSP_RTTOV_INTERFACE, ONLY: & - COSP_RTTOV_INIT, & + cosp_rttov_init, & cosp_rttov_simulate, & rttov_cfg, & rttov_output diff --git a/src/simulator/cosp_rttov_interfaceSTUB.F90 b/src/simulator/cosp_rttov_interfaceSTUB.F90 index 5e1471be35..a2059bfe8c 100644 --- a/src/simulator/cosp_rttov_interfaceSTUB.F90 +++ b/src/simulator/cosp_rttov_interfaceSTUB.F90 @@ -97,25 +97,6 @@ MODULE MOD_COSP_RTTOV_INTERFACE CONTAINS - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE cosp_rttov_ini2 - JKS can I delete this?? - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -! SUBROUTINE COSP_RTTOV_INI2(Nlevels,Ninstruments,instrument_namelists, & -! rttov_config) - -! integer,intent(in) :: & -! Nlevels, & -! Ninstruments -! type(character(len=256)), dimension(Ninstruments) :: & -! instrument_namelists ! Array of paths to RTTOV instrument namelists -! type(rttov_cfg), dimension(Ninstruments) :: & ! intent(out)? -! rttov_config - - -! END SUBROUTINE COSP_RTTOV_INI2 - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_init !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index b6ddf32964..556c5675a6 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -82,11 +82,11 @@ MODULE MOD_COSP_RTTOV_INTERFACE cld_coef_filepath, & PC_coef_filepath integer(KIND=jpim) :: & - nchanprof, & - rttov_direct_nthreads - integer(KIND=jpim) :: & - nchan_out, & - nchannels_rec + nchanprof, & + rttov_direct_nthreads, & + nchan_out, & + nchannels_rec, & + rttov_Nlocaltime real(wp) :: & CO2_mr, & CH4_mr, & @@ -98,8 +98,10 @@ MODULE MOD_COSP_RTTOV_INTERFACE iChannel(:), & ! Requested channel indices iChannel_out(:) ! Passing out the channel indices (actual output channels) real(kind=jprb),allocatable :: & - emisChannel(:), & ! RTTOV channel emissivity - reflChannel(:) ! RTTOV channel reflectivity + emisChannel(:), & ! RTTOV channel emissivity + reflChannel(:), & ! RTTOV channel reflectivity + rttov_localtime(:), & + rttov_localtime_width(:) type(rttov_options) :: & opts ! RTTOV options structure type(rttov_coefs) :: & @@ -155,7 +157,7 @@ SUBROUTINE COSP_RTTOV_INIT(Lrttov, Nlevels,Ninstruments,instrument_namelists, ! print*,'kind(rttov_configs(inst_idx)): ',kind(rttov_configs(inst_idx)) ! print*,'rttov_configs(inst_idx): ',rttov_configs(inst_idx) if (present(unitn)) then - print*,'instrument_namelists(inst_idx): ',instrument_namelists(inst_idx) ! JKS check +! print*,'instrument_namelists(inst_idx): ',instrument_namelists(inst_idx) ! JKS check call cosp_rttov_init_s(Nlevels,instrument_namelists(inst_idx),rttov_configs(inst_idx),unitn=unitn) else call cosp_rttov_init_s(Nlevels,instrument_namelists(inst_idx),rttov_configs(inst_idx)) @@ -230,6 +232,13 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & ipcbnd, & ipcreg, & npcscores + + ! JKS for orbital swathing + integer(kind=jpim) :: & + rttov_Nlocaltime ! Number of orbits + real(wp),dimension(20) :: & ! Reasonable but arbitrary limit at 10 local time orbits + rttov_localtime, & ! RTTOV subsetting by local time in hours [0,24] + rttov_localtime_width ! Width of satellite swath (km). ! JKS for checking errors in filenames. character(len=256) :: imsg !<-- some suitable length, say XX=256 @@ -246,8 +255,10 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & clw_data, & ! MW option CO2_mr,CH4_mr,CO_mr,N2O_mr,SO2_mr, & ! Mixing ratios ipcbnd,ipcreg,npcscores, & ! PC-RTTOV config values - rttov_nthreads,rttov_ZenAng - +! rttov_nthreads,rttov_ZenAng + rttov_nthreads,rttov_ZenAng,rttov_Nlocaltime, & + rttov_localtime,rttov_localtime_width + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Read in namelists !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -278,6 +289,16 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & close(10) endif + ! Set swath arrays correctly. + allocate(rttov_config%rttov_localtime(rttov_Nlocaltime),rttov_config%rttov_localtime_width(rttov_Nlocaltime)) + rttov_config%rttov_Nlocaltime = rttov_Nlocaltime + rttov_config%rttov_localtime(:) = rttov_localtime(1:rttov_Nlocaltime) + rttov_config%rttov_localtime_width(:) = rttov_localtime_width(1:rttov_Nlocaltime) + +! Old code that doesn't make sense... +! rttov_config%rttov_localtime(1:rttov_Nlocaltime) = rttov_localtime_in +! rttov_config%rttov_localtimewidth(1:rttov_Nlocaltime) = rttov_localtimewidth_in + ! Set logicals for RTTOV config rttov_config%Lrttov_bt = Lrttov_bt rttov_config%Lrttov_rad = Lrttov_rad From 3fed030138faa252bbc4cbff29fcc99660ffae04 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Thu, 3 Aug 2023 17:32:12 -0600 Subject: [PATCH 072/159] Initial interfacing of time and user input variables for orbit swath handling. Not functioning yet. --- driver/src/cosp2_io.f90 | 22 ++++++- driver/src/cosp2_test.F90 | 28 ++++++--- src/cosp.F90 | 4 +- src/simulator/cosp_rttov_interfaceSTUB.F90 | 16 ++--- src/simulator/cosp_rttov_interface_v13.F90 | 21 ++++--- src/simulator/rttov/cosp_rttovSTUB.F90 | 3 +- src/simulator/rttov/cosp_rttov_v13.F90 | 70 ++++++++++++++++++++-- 7 files changed, 131 insertions(+), 33 deletions(-) diff --git a/driver/src/cosp2_io.f90 b/driver/src/cosp2_io.f90 index 751ad74acd..4f6522e3fb 100644 --- a/driver/src/cosp2_io.f90 +++ b/driver/src/cosp2_io.f90 @@ -2137,7 +2137,7 @@ SUBROUTINE NC_READ_INPUT_FILE(fname,Npnts,Nl,Nhydro,lon,lat,p,ph,z,zh,T,qv,rh,tc mr_lsliq,mr_lsice,mr_ccliq,mr_ccice,fl_lsrain,fl_lssnow, & fl_lsgrpl,fl_ccrain,fl_ccsnow,Reff,dtau_s,dtau_c,dem_s, & dem_c,skt,landmask,mr_ozone,u_wind,v_wind,sunlit, & - emsfc_lw,mode,Nlon,Nlat,surfelev) + emsfc_lw,mode,Nlon,Nlat,surfelev,month,hour,minute) ! Arguments character(len=512),intent(in) :: fname ! File name @@ -2147,7 +2147,7 @@ SUBROUTINE NC_READ_INPUT_FILE(fname,Npnts,Nl,Nhydro,lon,lat,p,ph,z,zh,T,qv,rh,tc mr_lsliq,mr_lsice,mr_ccliq,mr_ccice,fl_lsrain,fl_lssnow,fl_lsgrpl, & fl_ccrain,fl_ccsnow,dtau_s,dtau_c,dem_s,dem_c,mr_ozone real(wp),dimension(Npnts,Nl,Nhydro),intent(out) :: Reff - real(wp),dimension(Npnts),intent(out) :: skt,landmask,u_wind,v_wind,sunlit,surfelev + real(wp),dimension(Npnts),intent(out) :: skt,landmask,u_wind,v_wind,sunlit,surfelev,minute,month,hour real(wp),intent(out) :: emsfc_lw integer,intent(out) :: mode,Nlon,Nlat @@ -2494,6 +2494,24 @@ SUBROUTINE NC_READ_INPUT_FILE(fname,Npnts,Nl,Nhydro,lon,lat,p,ph,z,zh,T,qv,rh,tc else call map_ll_to_point(Na,Nb,Npoints,x2=x2,y1=sunlit) endif + case ('month') + if (Lpoint) then + month(1:Npoints) = x1(1:Npoints) + else + call map_ll_to_point(Na,Nb,Npoints,x2=x2,y1=month) + endif + case ('hour') + if (Lpoint) then + hour(1:Npoints) = x1(1:Npoints) + else + call map_ll_to_point(Na,Nb,Npoints,x2=x2,y1=hour) + endif + case ('minute') + if (Lpoint) then + minute(1:Npoints) = x1(1:Npoints) + else + call map_ll_to_point(Na,Nb,Npoints,x2=x2,y1=minute) + endif end select ! Free memory if (vrank == 1) deallocate(x1) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index aca8d8d327..77d4767bd1 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -81,7 +81,7 @@ program cosp2_test Nlon,Nlat,geomode real(wp) :: & emsfc_lw - real(wp),dimension(:),allocatable,target:: & + real(wp),dimension(:),allocatable,target :: & lon, & ! Longitude (deg) lat, & ! Latitude (deg) skt, & ! Skin temperature (K) @@ -89,7 +89,11 @@ program cosp2_test landmask, & ! Land/sea mask (0/1) u_wind, & ! U-component of wind (m/s) v_wind, & ! V-component of wind (m/s) - sunlit ! Sunlit flag + sunlit ! Sunlit flag + real(wp),dimension(:),allocatable :: & + month, & ! Month [1,12] + hour, & ! Hour [0,24] + minute ! Minute [0,60] real(wp),dimension(:,:),allocatable,target :: & p, & ! Model pressure levels (pa) ph, & ! Moddel pressure @ half levels (pa) @@ -326,14 +330,15 @@ program cosp2_test dtau_s(Npoints,Nlevels),dtau_c(Npoints,Nlevels),dem_s(Npoints,Nlevels), & dem_c(Npoints,Nlevels),skt(Npoints),landmask(Npoints), & mr_ozone(Npoints,Nlevels),u_wind(Npoints),v_wind(Npoints),sunlit(Npoints), & - frac_out(Npoints,Ncolumns,Nlevels),surfelev(Npoints)) + frac_out(Npoints,Ncolumns,Nlevels),surfelev(Npoints),month(Npoints), & + hour(Npoints),minute(Npoints)) fileIN = trim(dinput)//trim(finput) call nc_read_input_file(fileIN,Npoints,Nlevels,N_HYDRO,lon,lat,p,ph,zlev,zlev_half, & T,sh,rh,tca,cca,mr_lsliq,mr_lsice,mr_ccliq,mr_ccice,fl_lsrain, & fl_lssnow,fl_lsgrpl,fl_ccrain,fl_ccsnow,Reff,dtau_s,dtau_c, & dem_s,dem_c,skt,landmask,mr_ozone,u_wind,v_wind,sunlit, & - emsfc_lw,geomode,Nlon,Nlat,surfelev) + emsfc_lw,geomode,Nlon,Nlat,surfelev,month,hour,minute) call cpu_time(driver_time(2)) !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -518,7 +523,8 @@ program cosp2_test ! Well-mixed gases are not in COSP offline input ! Moved user input of well-mixed gases to instrument namelists - ! Keeping these structures since gases could come from model input + ! Keeping these structures since gases could come from model input. + ! JKS should probably be 2-dimensional cospstateIN%co2(:) = 0._wp cospstateIN%ch4(:) = 0._wp cospstateIN%n2o(:) = 0._wp @@ -529,6 +535,11 @@ program cosp2_test ! cospstateIN%n2o = 0._wp ! cospstateIN%co = 0._wp + ! Time information + cospstateIN%month = month(start_idx:end_idx) + cospstateIN%time_frac = (60*hour(start_idx:end_idx) + minute(start_idx:end_idx)) / (24*60) ! Time (UTC) expressed as a fraction on [0,1] + deallocate(month,hour,minute) ! JKS - helpful? + ! From the data input file cospstateIN%u_sfc = u_wind(start_idx:end_idx) cospstateIN%v_sfc = v_wind(start_idx:end_idx) @@ -550,7 +561,6 @@ program cosp2_test ! Inputs not supplied in the UKMO test data cospstateIN%seaice(:) = 0._wp - cospstateIN%month = 0 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Generate subcolumns and compute optical inputs. @@ -1072,6 +1082,7 @@ subroutine construct_cospIN(npoints,ncolumns,nlevels,ninst_rttov,y) if (Lrttov) then allocate(y%cfg_rttov(ninst_rttov)) + ! JKS allocate localtime endif end subroutine construct_cospIN @@ -1093,7 +1104,9 @@ subroutine construct_cospstateIN(npoints,nlevels,y) ! y%emis_sfc(npoints,nchan),y%refl_sfc(npoints,nchan), & y%cloudIce(nPoints,nLevels),y%cloudLiq(nPoints,nLevels),y%surfelev(npoints),& y%fl_snow(nPoints,nLevels),y%fl_rain(nPoints,nLevels),y%seaice(npoints), & - y%tca(nPoints,nLevels),y%hgt_matrix_half(npoints,nlevels)) + y%tca(nPoints,nLevels),y%hgt_matrix_half(npoints,nlevels), & + y%month(nPoints),y%time_frac(nPoints)) +! y%tca(nPoints,nLevels),y%hgt_matrix_half(npoints,nlevels)) end subroutine construct_cospstateIN @@ -1530,6 +1543,7 @@ subroutine destroy_cospstateIN(y) if (allocated(y%hgt_matrix_half)) deallocate(y%hgt_matrix_half) if (allocated(y%surfelev)) deallocate(y%surfelev) if (allocated(y%month)) deallocate(y%month) + if (allocated(y%time_frac)) deallocate(y%time_frac) if (allocated(y%co2)) deallocate(y%co2) if (allocated(y%ch4)) deallocate(y%ch4) if (allocated(y%n2o)) deallocate(y%n2o) diff --git a/src/cosp.F90 b/src/cosp.F90 index 5936e0d963..991dd4ca47 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -110,7 +110,8 @@ MODULE MOD_COSP co2, & ! CO2 (kg/kg) ch4, & ! Methane (kg/kg) n2o, & ! N2O (kg/kg) - co ! CO (kg/kg) + co, & ! CO (kg/kg) + time_frac ! Time (UTC) expressed as a fraction on [0,1] real(wp),allocatable,dimension(:) :: & u_sfc, & ! Surface u-wind (m/s) v_sfc, & ! Surface v-wind (m/s) @@ -769,6 +770,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) rttovIN%o3 => cospgridIN%o3 ! Below only needed for all-sky RTTOV calculation rttovIN%month => cospgridIN%month + rttovIN%time_frac => cospgridIN%time_frac rttovIN%tca => cospgridIN%tca rttovIN%cldIce => cospgridIN%cloudIce rttovIN%cldLiq => cospgridIN%cloudLiq diff --git a/src/simulator/cosp_rttov_interfaceSTUB.F90 b/src/simulator/cosp_rttov_interfaceSTUB.F90 index a2059bfe8c..a2bc08a957 100644 --- a/src/simulator/cosp_rttov_interfaceSTUB.F90 +++ b/src/simulator/cosp_rttov_interfaceSTUB.F90 @@ -54,11 +54,11 @@ MODULE MOD_COSP_RTTOV_INTERFACE cld_coef_filepath, & PC_coef_filepath integer :: & - nchanprof, & - rttov_direct_nthreads - integer :: & - nchan_out, & - nchannels_rec + nchanprof, & + rttov_direct_nthreads, & + nchan_out, & + nchannels_rec, & + rttov_Nlocaltime real(wp) :: & CO2_mr, & CH4_mr, & @@ -70,8 +70,10 @@ MODULE MOD_COSP_RTTOV_INTERFACE iChannel(:), & ! Requested channel indices iChannel_out(:) ! Passing out the channel indices (actual output channels) real(kind=wp),allocatable :: & - emisChannel(:), & ! RTTOV channel emissivity - reflChannel(:) ! RTTOV channel reflectivity + emisChannel(:), & ! RTTOV channel emissivity + reflChannel(:), & ! RTTOV channel reflectivity + rttov_localtime(:), & ! RTTOV localtime + rttov_localtime_width(:) ! type(rttov_options) :: & ! opts ! RTTOV options structure ! type(rttov_coefs) :: & diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 556c5675a6..9f05931d48 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -235,7 +235,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & ! JKS for orbital swathing integer(kind=jpim) :: & - rttov_Nlocaltime ! Number of orbits + rttov_Nlocaltime = 0 ! Number of orbits real(wp),dimension(20) :: & ! Reasonable but arbitrary limit at 10 local time orbits rttov_localtime, & ! RTTOV subsetting by local time in hours [0,24] rttov_localtime_width ! Width of satellite swath (km). @@ -294,11 +294,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & rttov_config%rttov_Nlocaltime = rttov_Nlocaltime rttov_config%rttov_localtime(:) = rttov_localtime(1:rttov_Nlocaltime) rttov_config%rttov_localtime_width(:) = rttov_localtime_width(1:rttov_Nlocaltime) - -! Old code that doesn't make sense... -! rttov_config%rttov_localtime(1:rttov_Nlocaltime) = rttov_localtime_in -! rttov_config%rttov_localtimewidth(1:rttov_Nlocaltime) = rttov_localtimewidth_in - + ! Set logicals for RTTOV config rttov_config%Lrttov_bt = Lrttov_bt rttov_config%Lrttov_rad = Lrttov_rad @@ -629,11 +625,14 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, ! Run each step for running RTTOV from mod_cosp_rttov (and time them) call cpu_time(driver_time(1)) - call cosp_rttov_allocate(rttovIN, & - rttovConfig % nChannels_rec, & - rttovConfig % opts, & - rttovConfig % coefs, & - rttovConfig % iChannel, & + call cosp_rttov_allocate(rttovIN, & + rttovConfig % nChannels_rec, & + rttovConfig % opts, & + rttovConfig % coefs, & + rttovConfig % iChannel, & + rttovConfig % rttov_Nlocaltime, & + rttovConfig % rttov_localtime, & + rttovConfig % rttov_localtime_width, & rttovConfig % nchanprof) call cpu_time(driver_time(2)) diff --git a/src/simulator/rttov/cosp_rttovSTUB.F90 b/src/simulator/rttov/cosp_rttovSTUB.F90 index 5a52a97c7e..f099632606 100644 --- a/src/simulator/rttov/cosp_rttovSTUB.F90 +++ b/src/simulator/rttov/cosp_rttovSTUB.F90 @@ -63,7 +63,8 @@ MODULE MOD_COSP_RTTOV co2, & ! Carbon dioxide ch4, & ! Methane n2o, & ! n2o - co ! Carbon monoxide + co, & ! Carbon monoxide + time_frac ! real(wp),dimension(:),pointer :: & ! surfem ! Surface emissivities for the channels ! refl, & ! Surface reflectances for the channels diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index d1cb769d02..aa85dc5aa5 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -152,7 +152,8 @@ module mod_cosp_rttov co2, & ! Carbon dioxide ch4, & ! Methane n2o, & ! n2o - co ! Carbon monoxide + co, & ! Carbon monoxide + time_frac ! real(wp),dimension(:),pointer :: & ! surfem ! Surface emissivities for the channels ! refl, & ! Surface reflectances for the channels @@ -213,7 +214,9 @@ end subroutine rttov_error ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & - inst_coefs,inst_iChannel,inst_nchanprof) + inst_coefs,inst_iChannel,rttov_Nlocaltime, & + rttov_localtime,rttov_localtime_width, & + inst_nchanprof) type(rttov_in),intent(in) :: & rttovIN @@ -225,17 +228,76 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & inst_coefs integer(kind=jpim),dimension(inst_nChannels_rec),intent(in) :: & inst_iChannel + integer(KIND=jpim),intent(in) :: & + rttov_Nlocaltime + real(kind=jprb), dimension(rttov_Nlocaltime), intent(in) :: & + rttov_localtime, & + rttov_localtime_width integer(kind=jpim),intent(inout) :: & - inst_nchanprof + inst_nchanprof + + !---- Local variables ----! ! Loop variables integer(kind=jpim) :: j, jch, nch - + + real(kind=jprb),parameter :: & + pi = 4.D0*DATAN(1.D0), & ! yum + radius = 6371.0 ! Earth's radius in km (mean volumetric) + + logical(jplm),dimension(rttovIN % nPoints) :: & + swath_mask + + real(kind=jprb), dimension(rttov_Nlocaltime) :: & + sat_lon + + real(kind=jprb), dimension(rttovIN % nPoints,rttov_Nlocaltime) :: & + swath_mask_all, & ! Mask of reals over all local times + dlon, & ! distance to satellite longitude in degrees + dx ! distance to satellite longitude in km? + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 3. Allocate RTTOV input and output structures ! ------------------------------------------------------ ! Largely from RTTOV documentation. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + ! Handle swathing here. Initial code from Genevieve with minor changes. + if (rttov_Nlocaltime > 0) then + ! Calculate the longitude where it is the requested local time. 15 degrees lon. per hour. + sat_lon = 15.0 * (rttov_localtime - (rttovIN%time_frac * 24.0)) + ! frac_day will either be a scalar (one for all gridpoint) or a vector. Should broadcast ok. + + ! Iterate over local times + do j=1,rttov_Nlocaltime + ! Calculate distance (in degrees) from each grid cell to the satellite central long + dlon(:,j) = mod((rttovIN%longitude - sat_lon(j) + 180.0), 360.0) - 180.0 + ! calculate distance to satellite in km + dx(:,j) = dlon(:,j) * (pi/180.0) * COS(rttovIN%latitude) * radius + end do + + ! inside swath = 1, outside swath = 0 for "swath_mask_all" + swath_mask_all = 0 + do j=1,rttov_Nlocaltime + where (abs(dx(:,j))<(rttov_localtime_width(j)*0.5)) + swath_mask_all(:,j) = 1 + end where + end do + + ! Collapse along the Nlocaltimes dimension and shift to logicals + swath_mask(:) = .false. ! Initialize to false + do j = 1,rttovIN % nPoints + if ( ANY( swath_mask_all(j,:) .eq. 1) ) then + swath_mask(j) = .true. + end if + end do + else + swath_mask(:) = .true. ! Compute on all columns in no local times are passed. + end if + print*,'dlon: ',dlon + print*,'dx: ',dx + print*,'swath_mask: ',swath_mask + ! Determine the total number of radiances to simulate (nchanprof). inst_nchanprof = inst_nChannels_rec * rttovIN%nPoints ! RTTOV (non-PC) needs nchan_out? JKS potential bug From c291165a5f06e48ba5036fc4ae3c3e81e9415ebd Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Fri, 4 Aug 2023 14:23:27 -0600 Subject: [PATCH 073/159] cosp_rttov_allocate interface complete but functionality not added yet --- .../run/instrument_nls/cosp2_rttov_inst1.txt | 2 +- src/simulator/cosp_rttov_interface_v13.F90 | 17 +++-- src/simulator/rttov/cosp_rttov_v13.F90 | 62 ++++++++++++------- 3 files changed, 52 insertions(+), 29 deletions(-) diff --git a/driver/run/instrument_nls/cosp2_rttov_inst1.txt b/driver/run/instrument_nls/cosp2_rttov_inst1.txt index 6f94598644..9060c99613 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst1.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst1.txt @@ -76,5 +76,5 @@ ! Set local time sampling with swath widths rttov_Nlocaltime=2, ! Number of local times to sample at rttov_localtime=0.75,13.5, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1.e2,5.6e3, ! Swath width (km) + rttov_localtime_width=3.e3,5.6e3, ! Swath width (km) / diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 9f05931d48..e041fdf7f7 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -86,7 +86,8 @@ MODULE MOD_COSP_RTTOV_INTERFACE rttov_direct_nthreads, & nchan_out, & nchannels_rec, & - rttov_Nlocaltime + rttov_Nlocaltime, & + nprof real(wp) :: & CO2_mr, & CH4_mr, & @@ -97,7 +98,7 @@ MODULE MOD_COSP_RTTOV_INTERFACE integer(kind=jpim), allocatable :: & iChannel(:), & ! Requested channel indices iChannel_out(:) ! Passing out the channel indices (actual output channels) - real(kind=jprb),allocatable :: & + real(kind=jprb), allocatable :: & emisChannel(:), & ! RTTOV channel emissivity reflChannel(:), & ! RTTOV channel reflectivity rttov_localtime(:), & @@ -106,6 +107,8 @@ MODULE MOD_COSP_RTTOV_INTERFACE opts ! RTTOV options structure type(rttov_coefs) :: & coefs ! RTTOV coefficients structure + logical(KIND=jplm), allocatable :: & + swath_mask(:) end type rttov_cfg type rttov_output @@ -235,7 +238,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & ! JKS for orbital swathing integer(kind=jpim) :: & - rttov_Nlocaltime = 0 ! Number of orbits + rttov_Nlocaltime ! Number of orbits real(wp),dimension(20) :: & ! Reasonable but arbitrary limit at 10 local time orbits rttov_localtime, & ! RTTOV subsetting by local time in hours [0,24] rttov_localtime_width ! Width of satellite swath (km). @@ -244,6 +247,9 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & character(len=256) :: imsg !<-- some suitable length, say XX=256 integer :: erro + ! Init. local time variables for multiple instruments: + rttov_Nlocaltime = 0 + ! Read RTTOV namelist fields namelist/RTTOV_INPUT/Lrttov_bt,Lrttov_rad,Lrttov_refl,Lrttov_cld, & ! Logicals for RTTOV configuration Lrttov_aer,Lrttov_cldparam,Lrttov_aerparam, & ! @@ -625,6 +631,7 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, ! Run each step for running RTTOV from mod_cosp_rttov (and time them) call cpu_time(driver_time(1)) + allocate(rttovConfig % swath_mask(rttovIN % nPoints)) call cosp_rttov_allocate(rttovIN, & rttovConfig % nChannels_rec, & rttovConfig % opts, & @@ -633,7 +640,9 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % rttov_Nlocaltime, & rttovConfig % rttov_localtime, & rttovConfig % rttov_localtime_width, & - rttovConfig % nchanprof) + rttovConfig % nchanprof, & + rttovConfig % nprof, & + rttovConfig % swath_mask) call cpu_time(driver_time(2)) call cosp_rttov_construct_profiles(rttovIN, & diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index aa85dc5aa5..ec0195770f 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -166,8 +166,8 @@ module mod_cosp_rttov t2m, & ! 2 m Temperature q2m, & ! 2 m Specific humidity lsmask, & ! land-sea mask - latitude, & ! Latitude - longitude, & ! Longitude + latitude, & ! Latitude (degrees) + longitude, & ! Longitude (degrees) seaice ! Sea-ice? real(wp),dimension(:,:),pointer :: & p, & ! Pressure @ model levels @@ -216,7 +216,7 @@ end subroutine rttov_error subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & inst_coefs,inst_iChannel,rttov_Nlocaltime, & rttov_localtime,rttov_localtime_width, & - inst_nchanprof) + inst_nchanprof,inst_nprof,swath_mask) type(rttov_in),intent(in) :: & rttovIN @@ -234,8 +234,11 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & rttov_localtime, & rttov_localtime_width integer(kind=jpim),intent(inout) :: & - inst_nchanprof - + inst_nchanprof, & + inst_nprof ! Now accounting for orbits + logical(jplm),dimension(rttovIN % nPoints),intent(inout) :: & + swath_mask + !---- Local variables ----! ! Loop variables integer(kind=jpim) :: j, jch, nch @@ -244,13 +247,8 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & pi = 4.D0*DATAN(1.D0), & ! yum radius = 6371.0 ! Earth's radius in km (mean volumetric) - logical(jplm),dimension(rttovIN % nPoints) :: & - swath_mask - - real(kind=jprb), dimension(rttov_Nlocaltime) :: & - sat_lon - real(kind=jprb), dimension(rttovIN % nPoints,rttov_Nlocaltime) :: & + sat_lon, & ! Central longitude of the instrument. swath_mask_all, & ! Mask of reals over all local times dlon, & ! distance to satellite longitude in degrees dx ! distance to satellite longitude in km? @@ -263,16 +261,19 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & ! Handle swathing here. Initial code from Genevieve with minor changes. if (rttov_Nlocaltime > 0) then - ! Calculate the longitude where it is the requested local time. 15 degrees lon. per hour. - sat_lon = 15.0 * (rttov_localtime - (rttovIN%time_frac * 24.0)) - ! frac_day will either be a scalar (one for all gridpoint) or a vector. Should broadcast ok. - ! Iterate over local times do j=1,rttov_Nlocaltime + ! Calculate the central longitude for each gridcell and orbit + sat_lon(:,j) = 15.0 * (rttov_localtime(j) - (rttovIN%time_frac * 24.0)) ! Calculate distance (in degrees) from each grid cell to the satellite central long - dlon(:,j) = mod((rttovIN%longitude - sat_lon(j) + 180.0), 360.0) - 180.0 - ! calculate distance to satellite in km - dx(:,j) = dlon(:,j) * (pi/180.0) * COS(rttovIN%latitude) * radius + dlon(:,j) = mod((rttovIN%longitude - sat_lon(:,j) + 180.0), 360.0) - 180.0 + +! print*,'rttovIN%longitude(1:7): ',rttovIN%longitude(1:7) +! print*,'sat_lon(j): ',sat_lon(1:7,j) +! print*,'dlon(1:7,j): ',dlon(1:7,j) + + ! calculate distance to satellite in km. Remember to convert to radians for cos/sine calls + dx(:,j) = dlon(:,j) * (pi/180.0) * COS(rttovIN%latitude * pi / 180) * radius end do ! inside swath = 1, outside swath = 0 for "swath_mask_all" @@ -290,21 +291,34 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & swath_mask(j) = .true. end if end do + ! Determine the total number of radiances to simulate (nchanprof). + inst_nchanprof = inst_nChannels_rec * inst_nprof else - swath_mask(:) = .true. ! Compute on all columns in no local times are passed. + swath_mask(:) = .true. ! Compute on all columns in no local times are passed. + inst_nchanprof = inst_nChannels_rec * rttovIN%nPoints ! RTTOV (non-PC) needs nchan_out? JKS potential bug end if + inst_nprof = count(swath_mask) - print*,'dlon: ',dlon - print*,'dx: ',dx - print*,'swath_mask: ',swath_mask - - ! Determine the total number of radiances to simulate (nchanprof). + ! To keep functionality for the commit inst_nchanprof = inst_nChannels_rec * rttovIN%nPoints ! RTTOV (non-PC) needs nchan_out? JKS potential bug + + ! Set rttovIN%nPointsCalc ! the number of columns to actually operate on. + +! print*,'rttovIN%time_frac: ',rttovIN%time_frac(1:10) +! print*,'sat_lon: ',sat_lon(1:10,:) +! print*,'rttovIN%longitude: ',rttovIN%longitude(1:10) +! print*,'rttovIN%latitude: ',rttovIN%latitude(1:10) +! print*,'dlon: ',dlon(1:10,:) +! print*,'dx: ',dx(1:10,:) + print*,'swath_mask: ',swath_mask + print*,'count(swath_mask): ',count(swath_mask) + ! Allocate structures for rttov_direct call rttov_alloc_direct( & errorstatus, & 1_jpim, & ! 1 => allocate +! inst_nprof, & rttovIN%nPoints, & inst_nchanprof, & rttovIN%nLevels, & From f6e8d5d01084cfa986d6b7a35d37f131e6a433dd Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Fri, 4 Aug 2023 16:59:57 -0600 Subject: [PATCH 074/159] Swathing implemented in non-PC-RTTOV subroutines. PC subroutines underway. --- src/cosp.F90 | 13 +- src/simulator/cosp_rttov_interface_v13.F90 | 24 +- src/simulator/rttov/cosp_rttov_v13.F90 | 365 +++++++++++++-------- 3 files changed, 249 insertions(+), 153 deletions(-) diff --git a/src/cosp.F90 b/src/cosp.F90 index 991dd4ca47..2ae2742f57 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -1543,6 +1543,9 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (cospIN % cfg_rttov(i) % Lrttov_pc) then allocate(rttov_bt_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp allocate(rttov_rad_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky radiance + ! Init to R_UNDEF - JKS check + rttov_bt_clear(:,:) = R_UNDEF + rttov_rad_clear(:,:) = R_UNDEF else allocate(rttov_bt_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp allocate(rttov_bt_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! clear-sky brightness temp @@ -1550,7 +1553,15 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) allocate(rttov_rad_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! clear-sky brightness temp allocate(rttov_rad_cloudy(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! cloudy-sky brightness temp allocate(rttov_refl_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky Bi-directional reflectance factor - allocate(rttov_refl_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! clear-sky Bi-directional reflectance factor + allocate(rttov_refl_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! clear-sky Bi-directional reflectance factor + ! Init to R_UNDEF + rttov_bt_total(:,:) = R_UNDEF + rttov_bt_clear(:,:) = R_UNDEF + rttov_rad_total(:,:) = R_UNDEF + rttov_rad_clear(:,:) = R_UNDEF + rttov_rad_cloudy(:,:) = R_UNDEF + rttov_refl_total(:,:) = R_UNDEF + rttov_refl_clear(:,:) = R_UNDEF endif call cpu_time(driver_time(3)) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index e041fdf7f7..2fc05d69c5 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -593,7 +593,7 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & END SUBROUTINE COSP_RTTOV_SIMULATE !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE cosp_rttov_simulate - Call regular subroutines in mod_cosp_rttov to run RTTOV + ! SUBROUTINE cosp_reg_rttov_simulate - Call regular subroutines in mod_cosp_rttov to run RTTOV !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & ! Inputs bt_total,bt_clear, & ! Brightness Temp Outputs @@ -653,8 +653,10 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % CO_mr, & rttovConfig % N2O_mr, & rttovConfig % SO2_mr, & - rttovConfig % ZenAng) - + rttovConfig % ZenAng, & + rttovConfig % nprof, & + rttovConfig % swath_mask) + call cpu_time(driver_time(3)) call cosp_rttov_setup_emissivity_reflectance() ! Config agnostic after allocate step. call cpu_time(driver_time(4)) @@ -664,8 +666,9 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, call cpu_time(driver_time(5)) - call cosp_rttov_save_output(rttovIN, & + call cosp_rttov_save_output(rttovIN, & rttovConfig % nchan_out, & + rttovConfig % swath_mask, & rttovConfig % Lrttov_bt, & rttovConfig % Lrttov_rad, & rttovConfig % Lrttov_refl, & @@ -679,7 +682,8 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, call cosp_rttov_deallocate_profiles(rttovIN, & rttovConfig % opts, & rttovConfig % coefs, & - rttovConfig % nchanprof) + rttovConfig % nchanprof, & + rttovConfig % nprof) call cpu_time(driver_time(7)) ! print*,'Time to run "cosp_rttov_allocate": ', driver_time(2)-driver_time(1) @@ -740,8 +744,12 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % opts, & rttovConfig % nchannels_rec, & rttovConfig % iChannel, & + rttovConfig % rttov_Nlocaltime, & + rttovConfig % rttov_localtime, & + rttovConfig % rttov_localtime_width, & rttovConfig % nchanprof, & - rttovConfig % iChannel_out) + rttovConfig % iChannel_out, & + rttovConfig % swath_mask) call cpu_time(driver_time(2)) call cosp_rttov_construct_profiles(rttovIN, & rttovConfig % Lrttov_cld, & @@ -751,7 +759,9 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % CO_mr, & rttovConfig % N2O_mr, & rttovConfig % SO2_mr, & - rttovConfig % ZenAng) + rttovConfig % ZenAng, & + rttovConfig % nprof, & + rttovConfig % swath_mask) call cpu_time(driver_time(3)) call cosp_pc_rttov_setup_emissivity() call cpu_time(driver_time(4)) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index ec0195770f..fcea55fa93 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -292,34 +292,25 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & end if end do ! Determine the total number of radiances to simulate (nchanprof). - inst_nchanprof = inst_nChannels_rec * inst_nprof else swath_mask(:) = .true. ! Compute on all columns in no local times are passed. - inst_nchanprof = inst_nChannels_rec * rttovIN%nPoints ! RTTOV (non-PC) needs nchan_out? JKS potential bug end if + ! Determine the total number of radiances to simulate (nchanprof). inst_nprof = count(swath_mask) + inst_nchanprof = inst_nChannels_rec * inst_nprof - ! To keep functionality for the commit - inst_nchanprof = inst_nChannels_rec * rttovIN%nPoints ! RTTOV (non-PC) needs nchan_out? JKS potential bug - - - ! Set rttovIN%nPointsCalc ! the number of columns to actually operate on. - -! print*,'rttovIN%time_frac: ',rttovIN%time_frac(1:10) -! print*,'sat_lon: ',sat_lon(1:10,:) -! print*,'rttovIN%longitude: ',rttovIN%longitude(1:10) -! print*,'rttovIN%latitude: ',rttovIN%latitude(1:10) -! print*,'dlon: ',dlon(1:10,:) -! print*,'dx: ',dx(1:10,:) print*,'swath_mask: ',swath_mask print*,'count(swath_mask): ',count(swath_mask) + print*,'inst_nprof: ',inst_nprof + print*,'inst_nChannels_rec: ',inst_nChannels_rec + print*,'inst_nchanprof: ',inst_nchanprof ! Allocate structures for rttov_direct call rttov_alloc_direct( & errorstatus, & 1_jpim, & ! 1 => allocate -! inst_nprof, & - rttovIN%nPoints, & + inst_nprof, & +! rttovIN%nPoints, & inst_nchanprof, & rttovIN%nLevels, & chanprof, & @@ -342,14 +333,15 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% nch = 0_jpim - do j = 1, rttovIN%nPoints +! do j = 1, rttovIN%nPoints + do j = 1, inst_nprof do jch = 1, inst_nChannels_rec ! nChannels -! do jch = 1, rttovIN%nChannels ! nChannels nch = nch + 1_jpim chanprof(nch)%prof = j chanprof(nch)%chan = inst_iChannel(jch) ! Example code used channel_list end do end do + print*,'Done with "cosp_rttov_allocate"' end subroutine cosp_rttov_allocate @@ -361,9 +353,10 @@ end subroutine cosp_rttov_allocate ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, & !inst_npcscores, & - inst_coefs,inst_opts, & - inst_nchannels_rec,inst_iChannel_in, & - inst_nchanprof, inst_iChannel_out) !,inst_predictindex) + inst_coefs,inst_opts, & + inst_nchannels_rec,inst_iChannel_in, & + rttov_Nlocaltime,rttov_localtime,rttov_localtime_width, & + inst_nchanprof,inst_iChannel_out,swath_mask) !,inst_predictindex) type(rttov_in),intent(in) :: & rttovIN @@ -376,11 +369,18 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, & !inst_npcscor integer(kind=jpim),intent(inout) :: & inst_nchannels_rec integer(kind=jpim),intent(in),dimension(inst_nchannels_rec) :: & - inst_iChannel_in ! Channel indices the user initially requests. + inst_iChannel_in ! Channel indices the user initially requests. + integer(KIND=jpim),intent(in) :: & + rttov_Nlocaltime + real(kind=jprb), dimension(rttov_Nlocaltime), intent(in) :: & + rttov_localtime, & + rttov_localtime_width integer(kind=jpim),intent(inout) :: & inst_nchanprof integer(kind=jpim),intent(inout),allocatable :: & inst_iChannel_out(:) ! Passing out the channel indices + logical(jplm),dimension(rttovIN % nPoints),intent(inout) :: & + swath_mask ! Loop variables integer(kind=jpim) :: j, jch, nch @@ -479,7 +479,9 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & inst_co_mr, & inst_n2o_mr, & inst_so2_mr, & - inst_zenang) + inst_zenang, & + inst_nprof, & + inst_swath_mask) type(rttov_in),intent(in) :: & ! What is the best way to do this? Should rttovIN be a module-wide DDT? Yes. rttovIN @@ -493,9 +495,13 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & inst_n2o_mr, & inst_so2_mr, & inst_zenang + integer(kind=jpim),intent(in) :: & + inst_nprof + logical(kind=jplm),dimension(rttovIN % nPoints),intent(in) :: & + inst_swath_mask ! Loop variables - integer(kind=jpim) :: i, j ! Use i to iterate over profile, j for levels. + integer(kind=jpim) :: i, j ! Use i to iterate over profile, j for swath_mask. ! Store profile data from rttovIN in profile type. ! See RTTOV user guide pg 163 for description of "profiles" type @@ -508,82 +514,88 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & profiles(:)%gas_units = 1 ! kg/kg over moist air (default) + ! Iterate over all columns + j = 0 ! Initialize input do i = 1, rttovIN%nPoints - ! Initialize trace gas concentrations from user input - ! These gases are not in COSP input files but might be in the future - - profiles(i)%co2(:) = inst_co2_mr - profiles(i)%n2o(:) = inst_n2o_mr - profiles(i)%co(:) = inst_co_mr - profiles(i)%ch4(:) = inst_ch4_mr - profiles(i)%so2 = inst_so2_mr ! syntax slightly different? - -! For when trace gas columns are supplied -! profiles(i)%co2(:) = rttovIN%co2 -! profiles(i)%n2o(:) = rttovIN%n2o -! profiles(i)%co(:) = rttovIN%co -! profiles(i)%ch4(:) = rttovIN%ch4 - - ! Initialize column pressure, temperature, and humidity - profiles(i)%p(:) = rttovIN%p(i, :) * 1e-2 ! convert Pa to hPa - profiles(i)%t(:) = rttovIN%t(i, :) - profiles(i)%q(:) = rttovIN%q(i, :) - - ! q coefficient limit is 0.1e-10 - where(profiles(i)%q(:) < 0.1e-10) - profiles(i)%q(:) = 0.11e-10 - end where + if (inst_swath_mask(i)) then ! only added masked columns to profiles + j = j + 1 ! Increment first - ! Gas profiles - profiles(i)%o3 = rttovIN%o3(i, :) - - ! 2m parameters - profiles(i)%s2m%p = rttovIN%p_surf(i) * 1e-2 ! convert Pa to hPa - profiles(i)%s2m%t = rttovIN%t2m(i) - profiles(i)%s2m%q = rttovIN%q2m(i) ! Should be the same as gas units (kg/kg) - profiles(i)%s2m%u = rttovIN%u_surf(i) - profiles(i)%s2m%v = rttovIN%v_surf(i) - profiles(i)%s2m%wfetc = 10000. ! only used by sea surface solar BRDF model. - - ! skin variables for emissivity calculations - profiles(i)%skin%t = rttovIN%t_skin(i) - - ! fastem coefficients - for mw calculations - profiles(i)%skin%fastem(1) = 3.0 - profiles(i)%skin%fastem(2) = 5.0 - profiles(i)%skin%fastem(3) = 15.0 - profiles(i)%skin%fastem(4) = 0.1 - profiles(i)%skin%fastem(5) = 0.3 - - ! Viewing angles - profiles(i)%zenangle = inst_zenang ! pass in from cosp - profiles(i)%azangle = 0. ! hard-coded in rttov9 int JKS-? - - profiles(i)%latitude = rttovIN%latitude(i) - profiles(i)%longitude = rttovIN%longitude(i) - profiles(i)%elevation = rttovIN%h_surf(i) * 1e-3 ! Convert m to km - - ! Solar angles. JKS - get this from COSP/CESM? Doesn't seem to be passed in. - profiles(i)%sunzenangle = 0. ! hard-coded in rttov9 int - profiles(i)%sunazangle = 0. ! hard-coded in rttov9 int - - ! surface type - ! land-sea mask (lsmask) indicates proportion of land in grid - if (rttovIN%lsmask(i) < 0.5) then - profiles(i)%skin%surftype = surftype_sea - else - profiles(i)%skin%surftype = surftype_land - endif - ! sea-ice fraction - if (rttovIN%seaice(i) >= 0.5) then - profiles(i)%skin%surftype = surftype_seaice - endif - - ! dar: hard-coded to 1 (=ocean water) in rttov 9 int - profiles(i)%skin%watertype = 1 - !profiles(i) %idg = 0. ! Depreciated? - !profiles(i) %ish = 0. ! Depreciated? + ! Initialize trace gas concentrations from user input + ! These gases are not in COSP input files but might be in the future + + profiles(j)%co2(:) = inst_co2_mr + profiles(j)%n2o(:) = inst_n2o_mr + profiles(j)%co(:) = inst_co_mr + profiles(j)%ch4(:) = inst_ch4_mr + profiles(j)%so2 = inst_so2_mr ! syntax slightly different? + + ! For when trace gas columns are supplied + ! profiles(j)%co2(:) = rttovIN%co2 + ! profiles(j)%n2o(:) = rttovIN%n2o + ! profiles(j)%co(:) = rttovIN%co + ! profiles(j)%ch4(:) = rttovIN%ch4 + + ! Initialize column pressure, temperature, and humidity + profiles(j)%p(:) = rttovIN%p(i, :) * 1e-2 ! convert Pa to hPa + profiles(j)%t(:) = rttovIN%t(i, :) + profiles(j)%q(:) = rttovIN%q(i, :) + + ! q coefficient limit is 0.1e-10 + where(profiles(j)%q(:) < 0.1e-10) + profiles(j)%q(:) = 0.11e-10 + end where + + ! Gas profiles + profiles(j)%o3 = rttovIN%o3(i, :) + + ! 2m parameters + profiles(j)%s2m%p = rttovIN%p_surf(i) * 1e-2 ! convert Pa to hPa + profiles(j)%s2m%t = rttovIN%t2m(i) + profiles(j)%s2m%q = rttovIN%q2m(i) ! Should be the same as gas units (kg/kg) + profiles(j)%s2m%u = rttovIN%u_surf(i) + profiles(j)%s2m%v = rttovIN%v_surf(i) + profiles(j)%s2m%wfetc = 10000. ! only used by sea surface solar BRDF model. + + ! skin variables for emissivity calculations + profiles(j)%skin%t = rttovIN%t_skin(i) + + ! fastem coefficients - for mw calculations + profiles(j)%skin%fastem(1) = 3.0 + profiles(j)%skin%fastem(2) = 5.0 + profiles(j)%skin%fastem(3) = 15.0 + profiles(j)%skin%fastem(4) = 0.1 + profiles(j)%skin%fastem(5) = 0.3 + + ! Viewing angles + profiles(j)%zenangle = inst_zenang ! pass in from cosp + profiles(j)%azangle = 0. ! hard-coded in rttov9 int JKS-? + + profiles(j)%latitude = rttovIN%latitude(i) + profiles(j)%longitude = rttovIN%longitude(i) + profiles(j)%elevation = rttovIN%h_surf(i) * 1e-3 ! Convert m to km + + ! Solar angles. JKS - get this from COSP/CESM? Doesn't seem to be passed in. + profiles(j)%sunzenangle = 0. ! hard-coded in rttov9 int + profiles(j)%sunazangle = 0. ! hard-coded in rttov9 int + + ! surface type + ! land-sea mask (lsmask) indicates proportion of land in grid + if (rttovIN%lsmask(i) < 0.5) then + profiles(j)%skin%surftype = surftype_sea + else + profiles(j)%skin%surftype = surftype_land + endif + ! sea-ice fraction + if (rttovIN%seaice(i) >= 0.5) then + profiles(j)%skin%surftype = surftype_seaice + endif + + ! dar: hard-coded to 1 (=ocean water) in rttov 9 int + profiles(j)%skin%watertype = 1 + !profiles(j) %idg = 0. ! Depreciated? + !profiles(j) %ish = 0. ! Depreciated? + end if end do ! JKS - nothing to check here, this will never trigger. @@ -607,27 +619,33 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & profiles(:)%ice_scheme = 1 !1:Baum 2:Baran(2014) 3:Baran(2018) profiles(:)%icede_param = 2 ! 2:Wyser(recommended). Only used if ice effective diameter not input - do i = 1, rttovIN%nPoints - ! Cloud scheme stuff - profiles(i)%cfrac(:) = rttovIN%tca(i,:) ! Cloud fraction for each layer - profiles(i)%cloud(1,:) = rttovIN%cldLiq(i,:) ! Cloud water mixing ratio (all in the first type for Deff) - profiles(i)%cloud(6,:) = rttovIN%cldIce(i,:) ! Cloud ice mixing ratio (1 type). See pg 74. + j = 0 ! Initialize input + do i = 1,rttovIN%nPoints + + if (inst_swath_mask(i)) then ! only added masked columns to profiles + j = j + 1 ! Increment profile counter + + ! Cloud scheme stuff + profiles(j)%cfrac(:) = rttovIN%tca(i,:) ! Cloud fraction for each layer + profiles(j)%cloud(1,:) = rttovIN%cldLiq(i,:) ! Cloud water mixing ratio (all in the first type for Deff) + profiles(j)%cloud(6,:) = rttovIN%cldIce(i,:) ! Cloud ice mixing ratio (1 type). See pg 74. ! Example UKMO input has effective radii for multiple cloud types, making identification of a single ! liquid droplet or ice crystal effective diameter difficult. ! I opt to let RTTOV decide on the effective radius values, but more complex implementation ! could do a more thorough conversion between UKMO output and RTTOV input - ! profiles(i)%clwde = ! Cloud water effective diameter - ! profiles(i)%icede = ! Cloud ice effective diameter + ! profiles(j)%clwde = ! Cloud water effective diameter + ! profiles(j)%icede = ! Cloud ice effective diameter ! Old code for simple cloud schemes only - ! profiles(i)%cfraction = 0. - ! profiles(i)%ctp = 500. + ! profiles(j)%cfraction = 0. + ! profiles(j)%ctp = 500. ! Other options not implemented -! profiles(i)%clw = ! Cloud liquid water (kg/kg) – MW only, +! profiles(j)%clw = ! Cloud liquid water (kg/kg) – MW only, + end if end do - endif + end if ! JKS - nothing to check here, this will never trigger. call rttov_error('error in cloud profile initialization' , lalloc = .false.) @@ -712,8 +730,10 @@ subroutine cosp_rttov_call_direct(inst_nthreads, & type(rttov_coefs),intent(in) :: & inst_coefs -! print*,'shape(chanprof%prof): ',shape(chanprof%prof) -! print*,'shape(chanprof%chan): ',shape(chanprof%chan) + print*,'shape(chanprof%prof): ',shape(chanprof%prof) + print*,'shape(chanprof%chan): ',shape(chanprof%chan) + print*,'shape(profiles): ',shape(profiles) +! print*,'shape(profiles(:)%q): ',shape(profiles(:)%q) ! print*,'shape(bt_total): ',shape(bt_total) if (inst_nthreads <= 1) then @@ -812,16 +832,18 @@ end subroutine cosp_pc_rttov_call_direct ! ------------------------------------------------------ ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_rttov_save_output(rttovIN,inst_nchan_out, & ! Inputs - Lrttov_bt,Lrttov_rad,Lrttov_refl, & - Lrttov_cld,Lrttov_aer, & - bt_total,bt_clear, & - rad_total,rad_clear,rad_cloudy, & + subroutine cosp_rttov_save_output(rttovIN,inst_nchan_out,inst_swath_mask, & ! Inputs + Lrttov_bt,Lrttov_rad,Lrttov_refl, & + Lrttov_cld,Lrttov_aer, & + bt_total,bt_clear, & + rad_total,rad_clear,rad_cloudy, & refl_total,refl_clear) type(rttov_in),intent(in) :: & rttovIN integer,intent(in) :: & inst_nchan_out + logical,dimension(rttovIN%nPoints),intent(in) :: & + inst_swath_mask logical,intent(in) :: & Lrttov_bt, & Lrttov_rad, & @@ -837,38 +859,88 @@ subroutine cosp_rttov_save_output(rttovIN,inst_nchan_out, & ! Inputs rad_cloudy, & refl_total, & refl_clear + + ! Local iterators. i is the gridcell index. j is the swath cells index. + integer :: i, j ! Documentation for RTTOV radiance structure in RTTOV User Guide pg 166 + ! Initialize all fields to undefined +! bt_total(:,:) = R_UNDEF +! bt_clear(:,:) = +! rad_total(:,:) = +! rad_clear(:,:) = +! rad_cloudy(:,:) = +! refl_total(:,:) = +! refl_clear(:,:) = + ! Only save output if appropriate - if (Lrttov_bt) then - bt_total(1:rttovIN%nPoints, 1:inst_nchan_out) = & - transpose(reshape(radiance%bt(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) - endif - if (Lrttov_bt .and. (Lrttov_cld .or. Lrttov_aer)) then - bt_clear(1:rttovIN%nPoints, 1:inst_nchan_out) = & - transpose(reshape(radiance%bt_clear(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) - endif + if (count(inst_swath_mask) .eq. rttovIN%nPoints) then ! No swathing, save all output + if (Lrttov_bt) then + bt_total(1:rttovIN%nPoints, 1:inst_nchan_out) = & + transpose(reshape(radiance%bt(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) + end if + if (Lrttov_bt .and. (Lrttov_cld .or. Lrttov_aer)) then + bt_clear(1:rttovIN%nPoints, 1:inst_nchan_out) = & + transpose(reshape(radiance%bt_clear(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) + end if + + if (Lrttov_rad) then + rad_total(1:rttovIN%nPoints, 1:inst_nchan_out) = & + transpose(reshape(radiance%total(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) + end if + if (Lrttov_rad .and. (Lrttov_cld .or. Lrttov_aer)) then + rad_clear(1:rttovIN%nPoints, 1:inst_nchan_out) = & + transpose(reshape(radiance%clear(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) + rad_cloudy(1:rttovIN%nPoints, 1:inst_nchan_out) = & + transpose(reshape(radiance%cloudy(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) + end if + + if (Lrttov_refl) then + refl_total(1:rttovIN%nPoints, 1:inst_nchan_out) = & + transpose(reshape(radiance%refl(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) + end if + if (Lrttov_refl .and. (Lrttov_cld .or. Lrttov_aer)) then + refl_clear(1:rttovIN%nPoints, 1:inst_nchan_out) = & + transpose(reshape(radiance%refl_clear(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) + end if +! else if (count(inst_swath_mask) .eq. 0) then ! No gridcells included in the swath, set everything as undefined. +! bt_total(:,:) = +! bt_clear(:,:) = +! rad_total(:,:) = +! rad_clear(:,:) = +! rad_cloudy(:,:) = +! refl_total(:,:) = +! refl_clear(:,:) = + else ! If swathing is occurring, assign the outputs appropriately + j = 0 + do i=1,rttovIN%nPoints + if (inst_swath_mask(i)) then ! only added masked columns to profiles + if (Lrttov_bt) then + bt_total(i, 1:inst_nchan_out) = radiance%bt(1 + (j * inst_nchan_out):(j+1) * inst_nchan_out) + end if + if (Lrttov_bt .and. (Lrttov_cld .or. Lrttov_aer)) then + bt_clear(i, 1:inst_nchan_out) = radiance%bt_clear(1 + (j * inst_nchan_out):(j+1) * inst_nchan_out) + end if + if (Lrttov_rad) then + rad_total(i, 1:inst_nchan_out) = radiance%total(1 + (j * inst_nchan_out):(j+1) * inst_nchan_out) + end if + if (Lrttov_rad .and. (Lrttov_cld .or. Lrttov_aer)) then + rad_clear(i, 1:inst_nchan_out) = radiance%clear(1 + (j * inst_nchan_out):(j+1) * inst_nchan_out) + rad_cloudy(i, 1:inst_nchan_out) = radiance%cloudy(1 + (j * inst_nchan_out):(j+1) * inst_nchan_out) + end if + if (Lrttov_refl) then + refl_total(i, 1:inst_nchan_out) = radiance%refl(1 + (j * inst_nchan_out):(j+1) * inst_nchan_out) + end if + if (Lrttov_refl .and. (Lrttov_cld .or. Lrttov_aer)) then + refl_clear(i, 1:inst_nchan_out) = radiance%refl_clear(1 + (j * inst_nchan_out):(j+1) * inst_nchan_out) + end if + j = j + 1 ! Increment profile counter afterwards + end if + end do + end if + - if (Lrttov_rad) then - rad_total(1:rttovIN%nPoints, 1:inst_nchan_out) = & - transpose(reshape(radiance%total(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) - endif - if (Lrttov_rad .and. (Lrttov_cld .or. Lrttov_aer)) then - rad_clear(1:rttovIN%nPoints, 1:inst_nchan_out) = & - transpose(reshape(radiance%clear(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) - rad_cloudy(1:rttovIN%nPoints, 1:inst_nchan_out) = & - transpose(reshape(radiance%cloudy(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) - endif - - if (Lrttov_refl) then - refl_total(1:rttovIN%nPoints, 1:inst_nchan_out) = & - transpose(reshape(radiance%refl(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) - endif - if (Lrttov_refl .and. (Lrttov_cld .or. Lrttov_aer)) then - bt_clear(1:rttovIN%nPoints, 1:inst_nchan_out) = & - transpose(reshape(radiance%refl_clear(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) - endif end subroutine cosp_rttov_save_output @@ -930,7 +1002,8 @@ end subroutine cosp_pc_rttov_save_output subroutine cosp_rttov_deallocate_profiles(rttovIN, & inst_opts, & inst_coefs, & - inst_nchanprof) + inst_nchanprof, & + inst_nprof) type(rttov_in),intent(in) :: & rttovIN @@ -941,13 +1014,15 @@ subroutine cosp_rttov_deallocate_profiles(rttovIN, & type(rttov_coefs),intent(in) :: & inst_coefs integer(kind=jpim),intent(in) :: & - inst_nchanprof + inst_nchanprof, & + inst_nprof ! Deallocate structures for rttov_direct call rttov_alloc_direct( & errorstatus, & 0_jpim, & ! 0 => deallocate - rttovIN%nPoints, & + inst_nprof, & +! rttovIN%nPoints, & inst_nchanprof, & rttovIN%nLevels, & chanprof, & ! JKS From 8582da4d2c87ad3405fb30e93afbc56dd3727bac Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Mon, 7 Aug 2023 09:10:36 -0600 Subject: [PATCH 075/159] Swathing implementation done! In both standard an PC RTM calls. Non-observed output is masked/naned. --- .../run/instrument_nls/cosp2_rttov_inst2.txt | 6 +- .../run/instrument_nls/cosp2_rttov_inst3.txt | 4 + driver/src/cosp2_test.F90 | 2 - src/simulator/cosp_rttov_interface_v13.F90 | 6 +- src/simulator/rttov/cosp_rttov_v13.F90 | 128 ++++++++++++++---- 5 files changed, 112 insertions(+), 34 deletions(-) diff --git a/driver/run/instrument_nls/cosp2_rttov_inst2.txt b/driver/run/instrument_nls/cosp2_rttov_inst2.txt index 6b4bd64c3a..aaf75e2c80 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst2.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst2.txt @@ -71,5 +71,9 @@ !-------------- RTTOV Other --------------- ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel rttov_nthreads=16, - rttov_ZenAng=0.0, ! Satellite Zenith Angle + rttov_ZenAng=0.0, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=2, ! Number of local times to sample at + rttov_localtime=0.75,13.5, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=2.e3,5.6e3, ! Swath width (km) / diff --git a/driver/run/instrument_nls/cosp2_rttov_inst3.txt b/driver/run/instrument_nls/cosp2_rttov_inst3.txt index 05b417a0d5..a4519108e5 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst3.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst3.txt @@ -69,4 +69,8 @@ ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel rttov_nthreads=16, rttov_ZenAng=0.0, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=2, ! Number of local times to sample at + rttov_localtime=0.75,13.5, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=2.e3,5.6e3, ! Swath width (km) / diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 77d4767bd1..c8411ca4db 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -313,8 +313,6 @@ program cosp2_test ! Shift the namelists read in into a shorter array for cosp_init: allocate(rttov_instrument_namelists_final(rttov_Ninstruments)) rttov_instrument_namelists_final(:) = rttov_instrument_namelists(1:rttov_Ninstruments) - - print*,'rttov_instrument_namelists_final: ',rttov_instrument_namelists_final !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Read in sample input data. diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 2fc05d69c5..f48608947e 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -738,6 +738,7 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, ! Run each step for running RTTOV from mod_cosp_rttov (and time them) call cpu_time(driver_time(1)) + allocate(rttovConfig % swath_mask(rttovIN % nPoints)) call cosp_pc_rttov_allocate(rttovIN, & rttovConfig % PC_coef_filepath, & rttovConfig % coefs, & @@ -748,6 +749,7 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % rttov_localtime, & rttovConfig % rttov_localtime_width, & rttovConfig % nchanprof, & + rttovConfig % nprof, & rttovConfig % iChannel_out, & rttovConfig % swath_mask) call cpu_time(driver_time(2)) @@ -774,6 +776,7 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, call cpu_time(driver_time(5)) call cosp_pc_rttov_save_output(rttovIN%nPoints, & rttovConfig%nchannels_rec, & + rttovConfig%swath_mask, & rttovConfig%Lrttov_bt, & rttovConfig%Lrttov_rad, & bt_clear, & @@ -784,7 +787,8 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % nChannels_rec, & rttovConfig % opts, & rttovConfig % coefs, & - rttovConfig % nchanprof) + rttovConfig % nchanprof, & + rttovConfig % nprof) call cpu_time(driver_time(7)) ! print*,'Time to run "cosp_pc_rttov_allocate": ', driver_time(2)-driver_time(1) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index fcea55fa93..756112718d 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -299,8 +299,6 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & inst_nprof = count(swath_mask) inst_nchanprof = inst_nChannels_rec * inst_nprof - print*,'swath_mask: ',swath_mask - print*,'count(swath_mask): ',count(swath_mask) print*,'inst_nprof: ',inst_nprof print*,'inst_nChannels_rec: ',inst_nChannels_rec print*,'inst_nchanprof: ',inst_nchanprof @@ -352,11 +350,11 @@ end subroutine cosp_rttov_allocate ! 4. Build the list of profile/channel indices in chanprof ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, & !inst_npcscores, & + subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, & inst_coefs,inst_opts, & inst_nchannels_rec,inst_iChannel_in, & rttov_Nlocaltime,rttov_localtime,rttov_localtime_width, & - inst_nchanprof,inst_iChannel_out,swath_mask) !,inst_predictindex) + inst_nchanprof,inst_nprof,inst_iChannel_out,swath_mask) type(rttov_in),intent(in) :: & rttovIN @@ -376,7 +374,8 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, & !inst_npcscor rttov_localtime, & rttov_localtime_width integer(kind=jpim),intent(inout) :: & - inst_nchanprof + inst_nchanprof, & + inst_nprof integer(kind=jpim),intent(inout),allocatable :: & inst_iChannel_out(:) ! Passing out the channel indices logical(jplm),dimension(rttovIN % nPoints),intent(inout) :: & @@ -388,7 +387,17 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, & !inst_npcscor ! Local variables integer(kind=jpim) :: inst_npred_pc - + + real(kind=jprb),parameter :: & + pi = 4.D0*DATAN(1.D0), & ! yum + radius = 6371.0 ! Earth's radius in km (mean volumetric) + + real(kind=jprb), dimension(rttovIN % nPoints,rttov_Nlocaltime) :: & + sat_lon, & ! Central longitude of the instrument. + swath_mask_all, & ! Mask of reals over all local times + dlon, & ! distance to satellite longitude in degrees + dx ! distance to satellite longitude in km? + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 3. Allocate RTTOV input and output structures ! ------------------------------------------------------ @@ -399,10 +408,49 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, & !inst_npcscor call rttov_get_pc_predictindex(errorstatus, inst_opts, predictindex, file_pccoef=inst_PC_coef_filepath) call rttov_error('rttov_get_pc_predictindex fatal error' , lalloc = .false.) + ! Handle swathing here. Initial code from Genevieve with minor changes. + if (rttov_Nlocaltime > 0) then + ! Iterate over local times + do j=1,rttov_Nlocaltime + ! Calculate the central longitude for each gridcell and orbit + sat_lon(:,j) = 15.0 * (rttov_localtime(j) - (rttovIN%time_frac * 24.0)) + ! Calculate distance (in degrees) from each grid cell to the satellite central long + dlon(:,j) = mod((rttovIN%longitude - sat_lon(:,j) + 180.0), 360.0) - 180.0 + ! calculate distance to satellite in km. Remember to convert to radians for cos/sine calls + dx(:,j) = dlon(:,j) * (pi/180.0) * COS(rttovIN%latitude * pi / 180) * radius + end do + + ! inside swath = 1, outside swath = 0 for "swath_mask_all" + swath_mask_all = 0 + do j=1,rttov_Nlocaltime + where (abs(dx(:,j))<(rttov_localtime_width(j)*0.5)) + swath_mask_all(:,j) = 1 + end where + end do + + ! Collapse along the Nlocaltimes dimension and shift to logicals + swath_mask(:) = .false. ! Initialize to false + do j = 1,rttovIN % nPoints + if ( ANY( swath_mask_all(j,:) .eq. 1) ) then + swath_mask(j) = .true. + end if + end do + ! Determine the total number of radiances to simulate (nchanprof). + else + swath_mask(:) = .true. ! Compute on all columns in no local times are passed. + end if + ! Determine the total number of radiances to simulate (nchanprof). + inst_nprof = count(swath_mask) + ! npred_pc is only used in the pc_rttov_allocate step so I can remove the global definition later inst_npred_pc = SIZE(predictindex) - inst_nchanprof = inst_npred_pc * rttovIN%nPoints ! Size of chanprof array is total number of predictors over all profiles - + inst_nchanprof = inst_npred_pc * inst_nprof +! inst_nchanprof = inst_npred_pc * rttovIN%nPoints ! Size of chanprof array is total number of predictors over all profiles + + print*,'inst_nprof: ',inst_nprof + print*,'inst_nChannels_rec: ',inst_nChannels_rec + print*,'inst_nchanprof: ',inst_nchanprof + ! Determine the number of reconstructed radiances per profile (nchannels_rec) if (allocated(inst_iChannel_out)) deallocate(inst_iChannel_out) ! Reset because this variable is internal and used by multiple instruments. ! JKS if (inst_opts % rt_ir % pc % addradrec) then @@ -431,7 +479,7 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, & !inst_npcscor CALL rttov_alloc_direct( & errorstatus, & 1_jpim, & ! 1 => allocate - rttovIN%nPoints, & + inst_nprof, & inst_nchanprof, & rttovIN%nLevels, & chanprof, & ! Make this instrument-specific? The rttov_config DDT would then be assigned to this value. Allocation difficulties? @@ -442,9 +490,9 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, & !inst_npcscor radiance, & calcemis=calcemis, & emissivity=emissivity, & - npcscores=inst_opts%rt_ir%pc%npcscores * rttovIN%nPoints, & - nchannels_rec=inst_nchannels_rec * rttovIN%nPoints, & - pccomp=pccomp, & + npcscores=inst_opts%rt_ir%pc%npcscores * inst_nprof, & + nchannels_rec=inst_nchannels_rec * inst_nprof, & + pccomp=pccomp, & init=.TRUE._jplm) call rttov_error('allocation error for rttov_direct structures (PC-RTTOV)' , lalloc = .true.) @@ -455,7 +503,7 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, & !inst_npcscor ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Populate chanprof using the channel list obtained above in predictindex(:) - do j = 1, rttovIN%nPoints + do j = 1, inst_nprof lo = (j - 1) * inst_npred_pc + 1 hi = lo + inst_npred_pc - 1 chanprof(lo:hi)%prof = j @@ -824,7 +872,6 @@ subroutine cosp_pc_rttov_call_direct(inst_nthreads, & nthreads = inst_nthreads) ! in number of threads to use endif call rttov_error('rttov_direct error (PC-RTTOV)', lalloc = .true.) - end subroutine cosp_pc_rttov_call_direct ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -939,8 +986,6 @@ subroutine cosp_rttov_save_output(rttovIN,inst_nchan_out,inst_swath_mask, & ! In end if end do end if - - end subroutine cosp_rttov_save_output @@ -953,6 +998,7 @@ end subroutine cosp_rttov_save_output subroutine cosp_pc_rttov_save_output(nPoints, & inst_nchannels_rec, & + inst_swath_mask, & Lrttov_bt, & Lrttov_rad, & bt_clear, & @@ -961,12 +1007,18 @@ subroutine cosp_pc_rttov_save_output(nPoints, & integer,intent(in) :: & nPoints, & inst_nchannels_rec + logical,dimension(nPoints),intent(in) :: & + inst_swath_mask logical,intent(in) :: & Lrttov_bt, & Lrttov_rad real(wp),dimension(nPoints,inst_nchannels_rec),intent(inout) :: & ! Can I do this? I guess so! bt_clear, & rad_clear + + ! Local iterators. i is the gridcell index. j is the swath cells index. + integer :: i, j + ! print*,'shape(bt_total): ',shape(bt_total) ! print*,'shape(rad_total): ',shape(rad_total) @@ -981,15 +1033,29 @@ subroutine cosp_pc_rttov_save_output(nPoints, & ! Documentation for RTTOV radiance structure in RTTOV User Guide pg 166 ! Only save output if appropriate - if (Lrttov_bt) then - bt_clear(1:nPoints, 1:inst_nchannels_rec) = & - transpose(reshape(pccomp%bt_pccomp(1:(inst_nchannels_rec * nPoints)), (/ inst_nchannels_rec, nPoints/) )) - endif - - if (Lrttov_rad) then - rad_clear(1:nPoints, 1:inst_nchannels_rec) = & - transpose(reshape(pccomp%total_pccomp(1:(inst_nchannels_rec * nPoints)), (/ inst_nchannels_rec, nPoints/) )) - endif + if (count(inst_swath_mask) .eq. nPoints) then ! No swathing, save all output + if (Lrttov_bt) then + bt_clear(1:nPoints, 1:inst_nchannels_rec) = & + transpose(reshape(pccomp%bt_pccomp(1:(inst_nchannels_rec * nPoints)), (/ inst_nchannels_rec, nPoints/) )) + end if + if (Lrttov_rad) then + rad_clear(1:nPoints, 1:inst_nchannels_rec) = & + transpose(reshape(pccomp%total_pccomp(1:(inst_nchannels_rec * nPoints)), (/ inst_nchannels_rec, nPoints/) )) + end if + else ! If swathing is occurring, assign the outputs appropriately + j = 0 + do i=1,nPoints + if (inst_swath_mask(i)) then ! only added masked columns to profiles + if (Lrttov_bt) then + bt_clear(i, 1:inst_nchannels_rec) = pccomp%bt_pccomp(1 + (j * inst_nchannels_rec):(j+1) * inst_nchannels_rec) + end if + if (Lrttov_rad) then + rad_clear(i, 1:inst_nchannels_rec) = pccomp%total_pccomp(1 + (j * inst_nchannels_rec):(j+1) * inst_nchannels_rec) + end if + j = j + 1 ! Increment profile counter afterwards + end if + end do + end if end subroutine cosp_pc_rttov_save_output @@ -1049,7 +1115,8 @@ subroutine cosp_pc_rttov_deallocate_profiles(rttovIN, & inst_nChannels_rec, & inst_opts, & inst_coefs, & - inst_nchanprof) + inst_nchanprof, & + inst_nprof) type(rttov_in),intent(in) :: & rttovIN @@ -1060,7 +1127,8 @@ subroutine cosp_pc_rttov_deallocate_profiles(rttovIN, & type(rttov_coefs),intent(in) :: & inst_coefs integer(kind=jpim),intent(in) :: & - inst_nchanprof + inst_nchanprof, & + inst_nprof if (ASSOCIATED(predictindex)) deallocate (predictindex, stat=alloc_status(10)) call rttov_error('mem dellocation error for "predictindex"', lalloc = .true.) @@ -1072,7 +1140,7 @@ subroutine cosp_pc_rttov_deallocate_profiles(rttovIN, & call rttov_alloc_direct( & errorstatus, & 0_jpim, & ! 0 => deallocate - rttovIN%nPoints, & + inst_nprof, & inst_nchanprof, & rttovIN%nLevels, & chanprof, & @@ -1083,8 +1151,8 @@ subroutine cosp_pc_rttov_deallocate_profiles(rttovIN, & radiance, & calcemis=calcemis, & emissivity=emissivity, & - npcscores=inst_opts%rt_ir%pc%npcscores * rttovIN%nPoints, & - nchannels_rec=inst_nChannels_rec * rttovIN%nPoints, & + npcscores=inst_opts%rt_ir%pc%npcscores * inst_nprof, & + nchannels_rec=inst_nChannels_rec * inst_nprof, & pccomp=pccomp) call rttov_error('deallocation error for rttov_direct structures (PC-RTTOV)', lalloc = .true.) From 70d9061ac72cfb7f6b9bd2473931d1b7b7aab07f Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Mon, 7 Aug 2023 09:49:57 -0600 Subject: [PATCH 076/159] Subroutine clean-up and simplifying --- src/simulator/cosp_rttov_interface_v13.F90 | 35 ++++--- src/simulator/rttov/cosp_rttov_v13.F90 | 115 ++++++++------------- 2 files changed, 61 insertions(+), 89 deletions(-) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index f48608947e..f528fb2fea 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -666,7 +666,7 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, call cpu_time(driver_time(5)) - call cosp_rttov_save_output(rttovIN, & + call cosp_rttov_save_output(rttovIN % nPoints, & rttovConfig % nchan_out, & rttovConfig % swath_mask, & rttovConfig % Lrttov_bt, & @@ -678,12 +678,12 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rad_total,rad_clear,rad_cloudy, & refl_total,refl_clear) - call cpu_time(driver_time(6)) - call cosp_rttov_deallocate_profiles(rttovIN, & - rttovConfig % opts, & - rttovConfig % coefs, & + call cpu_time(driver_time(6)) + call cosp_rttov_deallocate_profiles(rttovConfig % nprof, & rttovConfig % nchanprof, & - rttovConfig % nprof) + rttovIN % nLevels, & + rttovConfig % opts, & + rttovConfig % coefs) call cpu_time(driver_time(7)) ! print*,'Time to run "cosp_rttov_allocate": ', driver_time(2)-driver_time(1) @@ -774,21 +774,22 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % iChannel_out) ! iChannel_out should have been updated call cpu_time(driver_time(5)) - call cosp_pc_rttov_save_output(rttovIN%nPoints, & - rttovConfig%nchannels_rec, & - rttovConfig%swath_mask, & - rttovConfig%Lrttov_bt, & - rttovConfig%Lrttov_rad, & - bt_clear, & + call cosp_pc_rttov_save_output(rttovIN % nPoints, & + rttovConfig % nchannels_rec, & + rttovConfig % swath_mask, & + rttovConfig % Lrttov_bt, & + rttovConfig % Lrttov_rad, & + bt_clear, & rad_clear) - call cpu_time(driver_time(6)) - call cosp_pc_rttov_deallocate_profiles(rttovIN, & + call cpu_time(driver_time(6)) + call cosp_pc_rttov_deallocate_profiles(rttovConfig % nprof, & + rttovConfig % nchanprof, & + rttovIN % nlevels, & rttovConfig % nChannels_rec, & rttovConfig % opts, & - rttovConfig % coefs, & - rttovConfig % nchanprof, & - rttovConfig % nprof) + rttovConfig % coefs) + call cpu_time(driver_time(7)) ! print*,'Time to run "cosp_pc_rttov_allocate": ', driver_time(2)-driver_time(1) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 756112718d..28921f3518 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -308,7 +308,6 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & errorstatus, & 1_jpim, & ! 1 => allocate inst_nprof, & -! rttovIN%nPoints, & inst_nchanprof, & rttovIN%nLevels, & chanprof, & @@ -331,7 +330,6 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% nch = 0_jpim -! do j = 1, rttovIN%nPoints do j = 1, inst_nprof do jch = 1, inst_nChannels_rec ! nChannels nch = nch + 1_jpim @@ -444,8 +442,7 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, ! npred_pc is only used in the pc_rttov_allocate step so I can remove the global definition later inst_npred_pc = SIZE(predictindex) - inst_nchanprof = inst_npred_pc * inst_nprof -! inst_nchanprof = inst_npred_pc * rttovIN%nPoints ! Size of chanprof array is total number of predictors over all profiles + inst_nchanprof = inst_npred_pc * inst_nprof ! Size of chanprof array is total number of predictors over all profiles print*,'inst_nprof: ',inst_nprof print*,'inst_nChannels_rec: ',inst_nChannels_rec @@ -879,17 +876,16 @@ end subroutine cosp_pc_rttov_call_direct ! ------------------------------------------------------ ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_rttov_save_output(rttovIN,inst_nchan_out,inst_swath_mask, & ! Inputs + subroutine cosp_rttov_save_output(nPoints,inst_nchan_out,inst_swath_mask, & Lrttov_bt,Lrttov_rad,Lrttov_refl, & Lrttov_cld,Lrttov_aer, & bt_total,bt_clear, & rad_total,rad_clear,rad_cloudy, & refl_total,refl_clear) - type(rttov_in),intent(in) :: & - rttovIN integer,intent(in) :: & + nPoints, & inst_nchan_out - logical,dimension(rttovIN%nPoints),intent(in) :: & + logical,dimension(nPoints),intent(in) :: & inst_swath_mask logical,intent(in) :: & Lrttov_bt, & @@ -897,8 +893,7 @@ subroutine cosp_rttov_save_output(rttovIN,inst_nchan_out,inst_swath_mask, & ! In Lrttov_refl, & Lrttov_cld, & Lrttov_aer - - real(wp),dimension(rttovIN%nPoints,inst_nchan_out),intent(inout) :: & ! Can I do this? I guess so! + real(wp),dimension(nPoints,inst_nchan_out),intent(inout) :: & bt_total, & bt_clear, & rad_total, & @@ -912,56 +907,39 @@ subroutine cosp_rttov_save_output(rttovIN,inst_nchan_out,inst_swath_mask, & ! In ! Documentation for RTTOV radiance structure in RTTOV User Guide pg 166 - ! Initialize all fields to undefined -! bt_total(:,:) = R_UNDEF -! bt_clear(:,:) = -! rad_total(:,:) = -! rad_clear(:,:) = -! rad_cloudy(:,:) = -! refl_total(:,:) = -! refl_clear(:,:) = - ! Only save output if appropriate - if (count(inst_swath_mask) .eq. rttovIN%nPoints) then ! No swathing, save all output + if (count(inst_swath_mask) .eq. nPoints) then ! No swathing, save all output if (Lrttov_bt) then - bt_total(1:rttovIN%nPoints, 1:inst_nchan_out) = & - transpose(reshape(radiance%bt(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) + bt_total(1:nPoints, 1:inst_nchan_out) = & + transpose(reshape(radiance%bt(1:inst_nchan_out * nPoints), (/ inst_nchan_out, nPoints/) )) end if if (Lrttov_bt .and. (Lrttov_cld .or. Lrttov_aer)) then - bt_clear(1:rttovIN%nPoints, 1:inst_nchan_out) = & - transpose(reshape(radiance%bt_clear(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) + bt_clear(1:nPoints, 1:inst_nchan_out) = & + transpose(reshape(radiance%bt_clear(1:inst_nchan_out * nPoints), (/ inst_nchan_out, nPoints/) )) end if if (Lrttov_rad) then - rad_total(1:rttovIN%nPoints, 1:inst_nchan_out) = & - transpose(reshape(radiance%total(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) + rad_total(1:nPoints, 1:inst_nchan_out) = & + transpose(reshape(radiance%total(1:inst_nchan_out * nPoints), (/ inst_nchan_out, nPoints/) )) end if if (Lrttov_rad .and. (Lrttov_cld .or. Lrttov_aer)) then - rad_clear(1:rttovIN%nPoints, 1:inst_nchan_out) = & - transpose(reshape(radiance%clear(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) - rad_cloudy(1:rttovIN%nPoints, 1:inst_nchan_out) = & - transpose(reshape(radiance%cloudy(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) + rad_clear(1:nPoints, 1:inst_nchan_out) = & + transpose(reshape(radiance%clear(1:inst_nchan_out * nPoints), (/ inst_nchan_out, nPoints/) )) + rad_cloudy(1:nPoints, 1:inst_nchan_out) = & + transpose(reshape(radiance%cloudy(1:inst_nchan_out * nPoints), (/ inst_nchan_out, nPoints/) )) end if if (Lrttov_refl) then - refl_total(1:rttovIN%nPoints, 1:inst_nchan_out) = & - transpose(reshape(radiance%refl(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) + refl_total(1:nPoints, 1:inst_nchan_out) = & + transpose(reshape(radiance%refl(1:inst_nchan_out * nPoints), (/ inst_nchan_out, nPoints/) )) end if if (Lrttov_refl .and. (Lrttov_cld .or. Lrttov_aer)) then - refl_clear(1:rttovIN%nPoints, 1:inst_nchan_out) = & - transpose(reshape(radiance%refl_clear(1:inst_nchan_out * rttovIN%nPoints), (/ inst_nchan_out, rttovIN%nPoints/) )) + refl_clear(1:nPoints, 1:inst_nchan_out) = & + transpose(reshape(radiance%refl_clear(1:inst_nchan_out * nPoints), (/ inst_nchan_out, nPoints/) )) end if -! else if (count(inst_swath_mask) .eq. 0) then ! No gridcells included in the swath, set everything as undefined. -! bt_total(:,:) = -! bt_clear(:,:) = -! rad_total(:,:) = -! rad_clear(:,:) = -! rad_cloudy(:,:) = -! refl_total(:,:) = -! refl_clear(:,:) = else ! If swathing is occurring, assign the outputs appropriately j = 0 - do i=1,rttovIN%nPoints + do i=1,nPoints if (inst_swath_mask(i)) then ! only added masked columns to profiles if (Lrttov_bt) then bt_total(i, 1:inst_nchan_out) = radiance%bt(1 + (j * inst_nchan_out):(j+1) * inst_nchan_out) @@ -1019,17 +997,15 @@ subroutine cosp_pc_rttov_save_output(nPoints, & ! Local iterators. i is the gridcell index. j is the swath cells index. integer :: i, j - ! print*,'shape(bt_total): ',shape(bt_total) ! print*,'shape(rad_total): ',shape(rad_total) -! print*,'rttovIN%nPoints: ',rttovIN%nPoints -! print*,'rttovIN%nChannels: ',rttovIN%nChannels +! print*,'nPoints: ',nPoints +! print*,'inst_nchannels_rec: ',inst_nchannels_rec ! print*,'nchanprof: ',nchanprof ! This is the number of predictors so not the reconstructed channel dimension ! print*,'size(pccomp%bt_pccomp): ',size(pccomp%bt_pccomp) ! print*,'size(pccomp%total_pccomp): ',size(pccomp%total_pccomp) -! print*,'nchannels_rec * rttovIN%nPoints: ',nchannels_rec * rttovIN%nPoints +! print*,'inst_nchannels_rec * nPoints: ',inst_nchannels_rec * nPoints - ! JKS why not just pass in rttovIN%nPoints and use nchannels_rec here? TO-DO? ! Documentation for RTTOV radiance structure in RTTOV User Guide pg 166 ! Only save output if appropriate @@ -1065,32 +1041,29 @@ end subroutine cosp_pc_rttov_save_output ! From RTTOV example files. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_rttov_deallocate_profiles(rttovIN, & - inst_opts, & - inst_coefs, & + subroutine cosp_rttov_deallocate_profiles(inst_nprof, & inst_nchanprof, & - inst_nprof) + nLevels, & + inst_opts, & + inst_coefs) - type(rttov_in),intent(in) :: & - rttovIN -! integer(kind=jpim),intent(in) :: & -! inst_nChannels_rec + integer(kind=jpim),intent(in) :: & + inst_nprof, & + inst_nchanprof, & + nLevels type(rttov_options),intent(in) :: & inst_opts type(rttov_coefs),intent(in) :: & inst_coefs - integer(kind=jpim),intent(in) :: & - inst_nchanprof, & - inst_nprof + ! Deallocate structures for rttov_direct call rttov_alloc_direct( & errorstatus, & 0_jpim, & ! 0 => deallocate inst_nprof, & -! rttovIN%nPoints, & inst_nchanprof, & - rttovIN%nLevels, & + nLevels, & chanprof, & ! JKS inst_opts, & profiles, & @@ -1111,24 +1084,22 @@ end subroutine cosp_rttov_deallocate_profiles ! From RTTOV example files. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_pc_rttov_deallocate_profiles(rttovIN, & + subroutine cosp_pc_rttov_deallocate_profiles(inst_nprof, & + inst_nchanprof, & + nlevels, & inst_nChannels_rec, & inst_opts, & - inst_coefs, & - inst_nchanprof, & - inst_nprof) - - type(rttov_in),intent(in) :: & - rttovIN + inst_coefs) + integer(kind=jpim),intent(in) :: & + inst_nprof, & + inst_nchanprof, & + nlevels, & inst_nChannels_rec type(rttov_options),intent(in) :: & inst_opts type(rttov_coefs),intent(in) :: & inst_coefs - integer(kind=jpim),intent(in) :: & - inst_nchanprof, & - inst_nprof if (ASSOCIATED(predictindex)) deallocate (predictindex, stat=alloc_status(10)) call rttov_error('mem dellocation error for "predictindex"', lalloc = .true.) @@ -1142,7 +1113,7 @@ subroutine cosp_pc_rttov_deallocate_profiles(rttovIN, & 0_jpim, & ! 0 => deallocate inst_nprof, & inst_nchanprof, & - rttovIN%nLevels, & + nLevels, & chanprof, & inst_opts, & profiles, & From e2ed648648a30415228f497bc0fb6a5d03458b30 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Mon, 7 Aug 2023 14:38:50 -0600 Subject: [PATCH 077/159] Updates for chunked functionality. --- driver/src/cosp2_test.F90 | 6 ++---- src/simulator/cosp_rttov_interface_v13.F90 | 12 ++++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index c8411ca4db..786efb6e56 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -536,7 +536,7 @@ program cosp2_test ! Time information cospstateIN%month = month(start_idx:end_idx) cospstateIN%time_frac = (60*hour(start_idx:end_idx) + minute(start_idx:end_idx)) / (24*60) ! Time (UTC) expressed as a fraction on [0,1] - deallocate(month,hour,minute) ! JKS - helpful? + !deallocate(month,hour,minute) ! JKS - helpful? ! From the data input file cospstateIN%u_sfc = u_wind(start_idx:end_idx) @@ -580,12 +580,10 @@ program cosp2_test !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Call COSP !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - cosp_status = COSP_SIMULATOR(cospIN, cospstateIN, cospOUT,start_idx,end_idx,.false.) do ij=1,size(cosp_status,1) if (cosp_status(ij) .ne. '') print*,trim(cosp_status(ij)) end do - print*,'COSP_SIMULATOR successful' ! jks call cpu_time(driver_time(7)) end do @@ -612,7 +610,6 @@ program cosp2_test call destroy_cospIN(cospIN) call destroy_cospstateIN(cospstateIN) call cosp_cleanUp() - ! Getting a segmentation fault here? Why? JKS contains !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1559,6 +1556,7 @@ subroutine destroy_cospstateIN(y) if (allocated(y%fl_rain)) deallocate(y%fl_rain) if (allocated(y%fl_snow)) deallocate(y%fl_snow) if (allocated(y%tca)) deallocate(y%tca) + if (allocated(y%time_frac)) deallocate(y%time_frac) end subroutine destroy_cospstateIN diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index f528fb2fea..21bbb2099f 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -575,17 +575,15 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & ! Check options to determine if the principal component approach should be run if (rttovConfig % opts % rt_ir % pc % addpc) then -! print*,'Running COSP_PC_RTTOV_SIMULATE in multi-inst. set-up' call COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & bt_clear,rad_clear, & error) else -! print*,'Running COSP_REG_RTTOV_SIMULATE in multi-inst. set-up' - call COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & - bt_total,bt_clear, & - rad_total,rad_clear,rad_cloudy, & - refl_total,refl_clear, & + call COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & + bt_total,bt_clear, & + rad_total,rad_clear,rad_cloudy, & + refl_total,refl_clear, & error) endif @@ -631,6 +629,7 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, ! Run each step for running RTTOV from mod_cosp_rttov (and time them) call cpu_time(driver_time(1)) + if (allocated(rttovConfig % swath_mask)) deallocate(rttovConfig % swath_mask) allocate(rttovConfig % swath_mask(rttovIN % nPoints)) call cosp_rttov_allocate(rttovIN, & rttovConfig % nChannels_rec, & @@ -738,6 +737,7 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, ! Run each step for running RTTOV from mod_cosp_rttov (and time them) call cpu_time(driver_time(1)) + if (allocated(rttovConfig % swath_mask)) deallocate(rttovConfig % swath_mask) allocate(rttovConfig % swath_mask(rttovIN % nPoints)) call cosp_pc_rttov_allocate(rttovIN, & rttovConfig % PC_coef_filepath, & From b5c9c06dd16d9e227bb6ef303574b1d829d4bf17 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 9 Aug 2023 14:41:44 -0600 Subject: [PATCH 078/159] Comment out sfc_emis and sfc_refl variables. Enable trace gas columns. Running with the global inputs isn't killing a login node too! --- .../run/instrument_nls/cosp2_rttov_inst1.txt | 1 + driver/src/cosp2_test.F90 | 24 ++--- src/cosp.F90 | 92 +++++++++---------- src/simulator/cosp_rttov_interface_v13.F90 | 73 ++++++++++----- src/simulator/rttov/cosp_rttov_v13.F90 | 55 ++++++----- 5 files changed, 135 insertions(+), 110 deletions(-) diff --git a/driver/run/instrument_nls/cosp2_rttov_inst1.txt b/driver/run/instrument_nls/cosp2_rttov_inst1.txt index 9060c99613..ed3fce4655 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst1.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst1.txt @@ -60,6 +60,7 @@ ! -------------- RTTOV Trace Gas Concentrations ! -------------- Specify units in RTTOV options set-up ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.true., ! Have RTTOV use the trace gas concentrations below CO2_mr=5.241e-04, CH4_mr=9.139e-07, CO_mr=2.098e-07, diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 786efb6e56..e7e4ebec84 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -519,19 +519,14 @@ program cosp2_test cospstateIN%emis_sfc = 0._wp cospstateIN%refl_sfc = 0._wp - ! Well-mixed gases are not in COSP offline input - ! Moved user input of well-mixed gases to instrument namelists - ! Keeping these structures since gases could come from model input. - ! JKS should probably be 2-dimensional - cospstateIN%co2(:) = 0._wp - cospstateIN%ch4(:) = 0._wp - cospstateIN%n2o(:) = 0._wp - cospstateIN%co(:) = 0._wp - -! cospstateIN%co2 = 0._wp -! cospstateIN%ch4 = 0._wp -! cospstateIN%n2o = 0._wp -! cospstateIN%co = 0._wp + ! Well-mixed gases are not provided in COSP offline input, so hardcoding them in. + ! Units are kg/kg over moist air. + ! Note: user_tracegas_input should be true in instrument namelists for the COSP offline driver + cospstateIN%co2(:,:) = 5.241e-04 + cospstateIN%ch4(:,:) = 9.139e-07 + cospstateIN%n2o(:,:) = 4.665e-07 + cospstateIN%co(:,:) = 2.098e-07 + cospstateIN%so2(:,:) = 2.0e-11 ! Time information cospstateIN%month = month(start_idx:end_idx) @@ -1096,12 +1091,13 @@ subroutine construct_cospstateIN(npoints,nlevels,y) y%pfull(npoints,nlevels),y%phalf(npoints,nlevels+1),y%qv(npoints,nlevels), & y%o3(npoints,nlevels),y%hgt_matrix(npoints,nlevels),y%u_sfc(npoints), & y%v_sfc(npoints),y%lat(npoints),y%lon(nPoints), & + y%co(npoints,nlevels),y%n2o(npoints,nlevels),y%ch4(npoints,nlevels), & + y%co2(npoints,nlevels), & ! y%emis_sfc(npoints,nchan),y%refl_sfc(npoints,nchan), & y%cloudIce(nPoints,nLevels),y%cloudLiq(nPoints,nLevels),y%surfelev(npoints),& y%fl_snow(nPoints,nLevels),y%fl_rain(nPoints,nLevels),y%seaice(npoints), & y%tca(nPoints,nLevels),y%hgt_matrix_half(npoints,nlevels), & y%month(nPoints),y%time_frac(nPoints)) -! y%tca(nPoints,nLevels),y%hgt_matrix_half(npoints,nlevels)) end subroutine construct_cospstateIN diff --git a/src/cosp.F90 b/src/cosp.F90 index 2ae2742f57..6319eaa2e3 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -94,6 +94,11 @@ MODULE MOD_COSP pfull, & ! Pressure (Pa) phalf, & ! Pressure at half-levels (Pa) qv, & ! Specific humidity (kg/kg) + co2, & ! CO2 (kg/kg) + ch4, & ! Methane (kg/kg) + n2o, & ! N2O (kg/kg) + co, & ! CO (kg/kg) + so2, & ! SO2 (kg/kg) hgt_matrix, & ! Height of atmosphere layer (km) hgt_matrix_half ! Height of bottom interface of atm layer(km) ! First level contains the bottom of the top layer. @@ -106,18 +111,13 @@ MODULE MOD_COSP ! Fields used ONLY by RTTOV integer,allocatable,dimension(:) :: & month ! Month for surface emissivty atlas (1-12) - real(wp),allocatable,dimension(:) :: & - co2, & ! CO2 (kg/kg) - ch4, & ! Methane (kg/kg) - n2o, & ! N2O (kg/kg) - co, & ! CO (kg/kg) - time_frac ! Time (UTC) expressed as a fraction on [0,1] real(wp),allocatable,dimension(:) :: & u_sfc, & ! Surface u-wind (m/s) v_sfc, & ! Surface v-wind (m/s) seaice, & ! Sea-ice fraction (0-1) - lat, & ! Latitude (deg) - lon ! Longitude (deg) + lat, & ! Latitude (deg) + lon, & ! Longitude (deg) + time_frac ! Time (UTC) expressed as a fraction on [0,1] real(wp),allocatable,dimension(:,:) :: & emis_sfc, & ! Surface emissivity (1) refl_sfc, & ! Surface reflectance (1) @@ -3268,44 +3268,44 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, end do end if endif - if (any(cospgridIN%emis_sfc .lt. 0. .OR. cospgridIN%emis_sfc .gt. 1)) then - nError=nError+1 - errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%emis_sfc contains values out of range' - Lrttov_column = .false. - if (associated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument - if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 - if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF - end do - end if - endif - if (any(cospgridIN%refl_sfc .lt. 0. .OR. cospgridIN%refl_sfc .gt. 1)) then - nError=nError+1 - errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%refl_sfc contains values out of range' - Lrttov_column = .false. - if (associated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument - if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 - if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF - end do - end if - endif +! if (any(cospgridIN%emis_sfc .lt. 0. .OR. cospgridIN%emis_sfc .gt. 1)) then +! nError=nError+1 +! errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%emis_sfc contains values out of range' +! Lrttov_column = .false. +! if (associated(cospOUT%rttov_outputs)) then +! do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument +! if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 +! if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF +! if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF +! if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF +! if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF +! if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF +! if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF +! if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF +! if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF +! if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF +! end do +! end if +! endif +! if (any(cospgridIN%refl_sfc .lt. 0. .OR. cospgridIN%refl_sfc .gt. 1)) then +! nError=nError+1 +! errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%refl_sfc contains values out of range' +! Lrttov_column = .false. +! if (associated(cospOUT%rttov_outputs)) then +! do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument +! if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 +! if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF +! if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF +! if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF +! if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF +! if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF +! if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF +! if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF +! if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF +! if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF +! end do +! end if +! endif if (any(cospgridIN%u_sfc .lt. -100. .OR. cospgridIN%u_sfc .gt. 100.)) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospIN%u_sfc contains values out of range' diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 21bbb2099f..df7149e111 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -73,7 +73,8 @@ MODULE MOD_COSP_RTTOV_INTERFACE Lrttov_refl, & Lrttov_cld, & Lrttov_aer, & - Lrttov_pc + Lrttov_pc, & + user_tracegas_input character(len=256) :: & rttov_srcDir, & rttov_coefDir, & @@ -204,24 +205,23 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & rttov_ZenAng ! Declare RTTOV namelist fields - logical :: Lrttov_bt = .false. - logical :: Lrttov_rad = .false. - logical :: Lrttov_refl = .false. - logical :: Lrttov_cld = .false. - logical :: Lrttov_aer = .false. - logical :: Lrttov_cldparam = .false. - logical :: Lrttov_aerparam = .false. - logical :: Lrttov_pc = .false. - - logical :: Lchannel_filepath = .false. - - logical :: SO2_data = .false. - logical :: N2O_data = .false. - logical :: CO_data = .false. - logical :: CO2_data = .false. - logical :: CH4_data = .false. - logical :: ozone_data = .false. - logical :: clw_data = .false. + logical :: Lrttov_bt + logical :: Lrttov_rad + logical :: Lrttov_refl + logical :: Lrttov_cld + logical :: Lrttov_aer + logical :: Lrttov_cldparam + logical :: Lrttov_aerparam + logical :: Lrttov_pc + logical :: Lchannel_filepath + logical :: user_tracegas_input + logical :: SO2_data + logical :: N2O_data + logical :: CO_data + logical :: CO2_data + logical :: CH4_data + logical :: ozone_data + logical :: clw_data character(len=256) :: cosp_status integer :: & @@ -247,18 +247,36 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & character(len=256) :: imsg !<-- some suitable length, say XX=256 integer :: erro - ! Init. local time variables for multiple instruments: - rttov_Nlocaltime = 0 + ! Init. variables to false. + rttov_Nlocaltime = 0 + Lrttov_bt = .false. + Lrttov_rad = .false. + Lrttov_refl = .false. + Lrttov_cld = .false. + Lrttov_aer = .false. + Lrttov_cldparam = .false. + Lrttov_aerparam = .false. + Lrttov_pc = .false. + Lchannel_filepath = .false. + SO2_data = .false. + N2O_data = .false. + CO_data = .false. + CO2_data = .false. + CH4_data = .false. + ozone_data = .false. + clw_data = .false. + user_tracegas_input = .false. ! Read RTTOV namelist fields namelist/RTTOV_INPUT/Lrttov_bt,Lrttov_rad,Lrttov_refl,Lrttov_cld, & ! Logicals for RTTOV configuration Lrttov_aer,Lrttov_cldparam,Lrttov_aerparam, & ! - Lrttov_pc,nchannels_rec,Lchannel_filepath, & + Lrttov_pc,nchannels_rec,Lchannel_filepath, & channel_filepath,rttov_srcDir,rttov_coefDir, & OD_coef_filepath,aer_coef_filepath,cld_coef_filepath, & PC_coef_filepath, & CO2_data,CH4_data,CO_data,N2O_data,SO2_data,ozone_data, & ! User-supplied trace gas concentrations clw_data, & ! MW option + user_tracegas_input, & CO2_mr,CH4_mr,CO_mr,N2O_mr,SO2_mr, & ! Mixing ratios ipcbnd,ipcreg,npcscores, & ! PC-RTTOV config values ! rttov_nthreads,rttov_ZenAng @@ -320,6 +338,9 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & ! Set other RTTOV config variables rttov_config%rttov_direct_nthreads = rttov_nthreads + ! Set to false in namelist if model supplies trace profiles + rttov_config%user_tracegas_input = user_tracegas_input + rttov_config%SO2_mr = SO2_mr rttov_config%N2O_mr = N2O_mr rttov_config%CO_mr = CO_mr @@ -626,11 +647,13 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, error ! Error messages (only populated if error encountered) real(wp),dimension(10) :: driver_time + logical :: verbose = .false. ! Run each step for running RTTOV from mod_cosp_rttov (and time them) call cpu_time(driver_time(1)) if (allocated(rttovConfig % swath_mask)) deallocate(rttovConfig % swath_mask) allocate(rttovConfig % swath_mask(rttovIN % nPoints)) + if (verbose) print*,'Beginning "cosp_rttov_allocate".' call cosp_rttov_allocate(rttovIN, & rttovConfig % nChannels_rec, & rttovConfig % opts, & @@ -644,9 +667,11 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % swath_mask) call cpu_time(driver_time(2)) + if (verbose) print*,'Beginning "cosp_rttov_construct_profiles".' call cosp_rttov_construct_profiles(rttovIN, & rttovConfig % Lrttov_cld, & rttovConfig % Lrttov_aer, & + rttovConfig % user_tracegas_input, & rttovConfig % CO2_mr, & rttovConfig % CH4_mr, & rttovConfig % CO_mr, & @@ -657,6 +682,7 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % swath_mask) call cpu_time(driver_time(3)) + if (verbose) print*,'Beginning "cosp_rttov_setup_emissivity_reflectance".' call cosp_rttov_setup_emissivity_reflectance() ! Config agnostic after allocate step. call cpu_time(driver_time(4)) call cosp_rttov_call_direct(rttovConfig % rttov_direct_nthreads, & @@ -665,6 +691,7 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, call cpu_time(driver_time(5)) + if (verbose) print*,'Beginning "cosp_rttov_save_output".' call cosp_rttov_save_output(rttovIN % nPoints, & rttovConfig % nchan_out, & rttovConfig % swath_mask, & @@ -678,6 +705,7 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, refl_total,refl_clear) call cpu_time(driver_time(6)) + if (verbose) print*,'Beginning "cosp_rttov_deallocate_profiles".' call cosp_rttov_deallocate_profiles(rttovConfig % nprof, & rttovConfig % nchanprof, & rttovIN % nLevels, & @@ -756,6 +784,7 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, call cosp_rttov_construct_profiles(rttovIN, & rttovConfig % Lrttov_cld, & rttovConfig % Lrttov_aer, & + rttovConfig % user_tracegas_input, & rttovConfig % CO2_mr, & rttovConfig % CH4_mr, & rttovConfig % CO_mr, & diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 28921f3518..8e2eb974c1 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -148,12 +148,6 @@ module mod_cosp_rttov nSubCols ! Number of subcolumns integer(kind=jpim),dimension(:),pointer :: & month - real(wp),dimension(:),pointer :: & ! Could change the dimensionality of these in the future - co2, & ! Carbon dioxide - ch4, & ! Methane - n2o, & ! n2o - co, & ! Carbon monoxide - time_frac ! real(wp),dimension(:),pointer :: & ! surfem ! Surface emissivities for the channels ! refl, & ! Surface reflectances for the channels @@ -168,13 +162,19 @@ module mod_cosp_rttov lsmask, & ! land-sea mask latitude, & ! Latitude (degrees) longitude, & ! Longitude (degrees) - seaice ! Sea-ice? + seaice, & ! Sea-ice? + time_frac ! Fractional UTC time [0-1] real(wp),dimension(:,:),pointer :: & p, & ! Pressure @ model levels ph, & ! Pressure @ model half levels t, & ! Temperature q, & ! Specific humidity - o3 ! Ozone + o3, & ! Ozone + co2, & ! Carbon dioxide + ch4, & ! Methane + n2o, & ! n2o + co, & ! Carbon monoxide + so2 ! Sulfur dioxide ! These fields below are needed ONLY for the RTTOV all-sky brightness temperature real(wp),dimension(:,:),pointer :: & tca, & ! Cloud fraction @@ -266,12 +266,7 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & ! Calculate the central longitude for each gridcell and orbit sat_lon(:,j) = 15.0 * (rttov_localtime(j) - (rttovIN%time_frac * 24.0)) ! Calculate distance (in degrees) from each grid cell to the satellite central long - dlon(:,j) = mod((rttovIN%longitude - sat_lon(:,j) + 180.0), 360.0) - 180.0 - -! print*,'rttovIN%longitude(1:7): ',rttovIN%longitude(1:7) -! print*,'sat_lon(j): ',sat_lon(1:7,j) -! print*,'dlon(1:7,j): ',dlon(1:7,j) - + dlon(:,j) = mod((rttovIN%longitude - sat_lon(:,j) + 180.0), 360.0) - 180.0 ! calculate distance to satellite in km. Remember to convert to radians for cos/sine calls dx(:,j) = dlon(:,j) * (pi/180.0) * COS(rttovIN%latitude * pi / 180) * radius end do @@ -519,6 +514,7 @@ end subroutine cosp_pc_rttov_allocate subroutine cosp_rttov_construct_profiles(rttovIN, & Lrttov_cld, & Lrttov_aer, & + Luser_tracegas, & inst_co2_mr, & inst_ch4_mr, & inst_co_mr, & @@ -532,7 +528,8 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & rttovIN logical,intent(in) :: & Lrttov_cld, & - Lrttov_aer + Lrttov_aer, & + Luser_tracegas ! Use user-supplied trace gas columns from instrument namelists. real(wp),intent(in) :: & inst_co2_mr, & inst_ch4_mr, & @@ -568,19 +565,21 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & ! Initialize trace gas concentrations from user input ! These gases are not in COSP input files but might be in the future - - profiles(j)%co2(:) = inst_co2_mr - profiles(j)%n2o(:) = inst_n2o_mr - profiles(j)%co(:) = inst_co_mr - profiles(j)%ch4(:) = inst_ch4_mr - profiles(j)%so2 = inst_so2_mr ! syntax slightly different? - - ! For when trace gas columns are supplied - ! profiles(j)%co2(:) = rttovIN%co2 - ! profiles(j)%n2o(:) = rttovIN%n2o - ! profiles(j)%co(:) = rttovIN%co - ! profiles(j)%ch4(:) = rttovIN%ch4 - + if (Luser_tracegas) then + profiles(j)%co2(:) = inst_co2_mr + profiles(j)%n2o(:) = inst_n2o_mr + profiles(j)%co(:) = inst_co_mr + profiles(j)%ch4(:) = inst_ch4_mr + profiles(j)%so2(:) = inst_so2_mr ! syntax slightly different? + else + ! For when trace gas columns are supplied by the model. Units must match (kg/kg over moist air) + profiles(j)%co2(:) = rttovIN%co2(i,:) + profiles(j)%n2o(:) = rttovIN%n2o(i,:) + profiles(j)%co(:) = rttovIN%co(i,:) + profiles(j)%ch4(:) = rttovIN%ch4(i,:) + profiles(j)%so2(:) = rttovIN%so2(i,:) + end if + ! Initialize column pressure, temperature, and humidity profiles(j)%p(:) = rttovIN%p(i, :) * 1e-2 ! convert Pa to hPa profiles(j)%t(:) = rttovIN%t(i, :) From 985529240893023a6895db957398e8139f907d80 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Fri, 11 Aug 2023 09:01:20 -0600 Subject: [PATCH 079/159] Add deallocate RTTOV Config DDT function and integration. --- driver/src/cosp2_test.F90 | 16 +++++++++-- src/cosp.F90 | 3 +-- src/simulator/cosp_rttov_interfaceSTUB.F90 | 31 ++++++++++++++++------ src/simulator/cosp_rttov_interface_v13.F90 | 19 +++++++++++-- src/simulator/rttov/cosp_rttovSTUB.F90 | 20 +++++++------- src/simulator/rttov/cosp_rttov_v13.F90 | 14 +--------- 6 files changed, 66 insertions(+), 37 deletions(-) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index e7e4ebec84..1245365d93 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -603,6 +603,7 @@ program cosp2_test !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% call destroy_cosp_outputs(cospOUT) call destroy_cospIN(cospIN) + deallocate(rttov_configs) call destroy_cospstateIN(cospstateIN) call cosp_cleanUp() @@ -1487,7 +1488,11 @@ end subroutine construct_cosp_outputs ! SUBROUTINE destroy_cospIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine destroy_cospIN(y) + use MOD_COSP_RTTOV_INTERFACE, only: DESTROY_RTTOV_CONFIG + type(cosp_optical_inputs),intent(inout) :: y + integer :: i + if (allocated(y%tau_067)) deallocate(y%tau_067) if (allocated(y%emiss_11)) deallocate(y%emiss_11) if (allocated(y%frac_out)) deallocate(y%frac_out) @@ -1516,11 +1521,18 @@ subroutine destroy_cospIN(y) if (allocated(y%tau_mol_atlid)) deallocate(y%tau_mol_atlid) if (allocated(y%tautot_atlid)) deallocate(y%tautot_atlid) if (allocated(y%fracPrecipIce)) deallocate(y%fracPrecipIce) + + if (size(y%cfg_rttov) .gt. 0) then + do i=1,y%Ninst_rttov + call destroy_rttov_config(y%cfg_rttov(i)) + end do + end if + end subroutine destroy_cospIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE destroy_cospstateIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine destroy_cospstateIN(y) + subroutine destroy_cospstateIN(y) type(cosp_column_inputs),intent(inout) :: y if (allocated(y%sunlit)) deallocate(y%sunlit) @@ -1559,7 +1571,7 @@ end subroutine destroy_cospstateIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE destroy_cosp_outputs !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine destroy_cosp_outputs(y) + subroutine destroy_cosp_outputs(y) type(cosp_outputs),intent(inout) :: y integer :: i ! Local iterator for RTTOV instruments diff --git a/src/cosp.F90 b/src/cosp.F90 index 6319eaa2e3..b1c6967a44 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -139,7 +139,6 @@ MODULE MOD_COSP Nlevels, & ! Number of levels. Npart, & ! Number of cloud meteors for LIDAR simulators. Nrefl, & ! Number of reflectances for PARASOL simulator -! nChannels_rttov, & ! Number of RTTOV channels Ninst_rttov ! Number of RTTOV instruments real(wp) :: & emsfc_lw ! Surface emissivity @ 11micron @@ -1862,7 +1861,7 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La ! OUTPUTS type(radar_cfg) :: rcfg - type(rttov_cfg), dimension(:), allocatable :: rttov_configs + type(rttov_cfg), dimension(:), allocatable,intent(inout) :: rttov_configs ! Optional args integer,intent(in),Optional :: unitn ! Used for io limits diff --git a/src/simulator/cosp_rttov_interfaceSTUB.F90 b/src/simulator/cosp_rttov_interfaceSTUB.F90 index a2bc08a957..c3bd27371e 100644 --- a/src/simulator/cosp_rttov_interfaceSTUB.F90 +++ b/src/simulator/cosp_rttov_interfaceSTUB.F90 @@ -32,7 +32,6 @@ ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MODULE MOD_COSP_RTTOV_INTERFACE USE COSP_KINDS, ONLY: wp -! USE MOD_COSP_CONFIG, ONLY: RTTOV_MAX_CHANNELS,rttovDir USE MOD_COSP_RTTOV, ONLY: rttov_IN IMPLICIT NONE @@ -74,10 +73,8 @@ MODULE MOD_COSP_RTTOV_INTERFACE reflChannel(:), & ! RTTOV channel reflectivity rttov_localtime(:), & ! RTTOV localtime rttov_localtime_width(:) -! type(rttov_options) :: & -! opts ! RTTOV options structure -! type(rttov_coefs) :: & -! coefs ! RTTOV coefficients structure + logical, allocatable :: & + swath_mask(:) end type rttov_cfg type rttov_output @@ -112,16 +109,35 @@ SUBROUTINE COSP_RTTOV_INIT(Lrttov,Nlevels,Ninstruments,instrument_namelists, Ninstruments type(character(len=128)), dimension(Ninstruments) :: & instrument_namelists ! Array of paths to RTTOV instrument namelists - type(rttov_cfg), dimension(:), allocatable :: & ! intent(out)? + type(rttov_cfg), dimension(:), intent(out), allocatable :: & ! intent(out)? rttov_configs integer,intent(in),Optional :: unitn ! Used for io limits Lrttov = .false. - + allocate(rttov_configs(Ninstruments)) + print*,'Running COSP_RTTOV_INIT from STUB files.', & 'To run RTTOV, compile COSP after setting environmental variable "RTTOV"' END SUBROUTINE COSP_RTTOV_INIT + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE DESTROY_RTTOV_CONFIG + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE DESTROY_RTTOV_CONFIG(rttovConfig) + + type(rttov_cfg),intent(inout) :: & + rttovConfig + + if (allocated(rttovConfig % iChannel)) deallocate(rttovConfig % iChannel) + if (allocated(rttovConfig % iChannel_out)) deallocate(rttovConfig % iChannel_out) + if (allocated(rttovConfig % emisChannel)) deallocate(rttovConfig % emisChannel) + if (allocated(rttovConfig % reflChannel)) deallocate(rttovConfig % reflChannel) + if (allocated(rttovConfig % rttov_localtime)) deallocate(rttovConfig % rttov_localtime) + if (allocated(rttovConfig % rttov_localtime_width)) deallocate(rttovConfig % rttov_localtime_width) + if (allocated(rttovConfig % swath_mask)) deallocate(rttovConfig % swath_mask) + + END SUBROUTINE DESTROY_RTTOV_CONFIG !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_simulate @@ -180,7 +196,6 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, END SUBROUTINE COSP_PC_RTTOV_SIMULATE - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! END MODULE ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index df7149e111..4f70d1feeb 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -144,7 +144,7 @@ SUBROUTINE COSP_RTTOV_INIT(Lrttov, Nlevels,Ninstruments,instrument_namelists, Ninstruments type(character(len=256)), dimension(Ninstruments) :: & instrument_namelists ! Array of paths to RTTOV instrument namelists - type(rttov_cfg), dimension(:), allocatable :: & ! intent(out)? + type(rttov_cfg), dimension(:), intent(out), allocatable :: & ! intent(out)? rttov_configs integer,intent(in),Optional :: unitn ! Used for io limits @@ -566,7 +566,22 @@ subroutine rttov_error(msg, lalloc) end subroutine rttov_error END SUBROUTINE COSP_RTTOV_INIT_S - + + + SUBROUTINE DESTROY_RTTOV_CONFIG(rttovConfig) + + type(rttov_cfg),intent(inout) :: & + rttovConfig + + if (allocated(rttovConfig % iChannel)) deallocate(rttovConfig % iChannel) + if (allocated(rttovConfig % iChannel_out)) deallocate(rttovConfig % iChannel_out) + if (allocated(rttovConfig % emisChannel)) deallocate(rttovConfig % emisChannel) + if (allocated(rttovConfig % reflChannel)) deallocate(rttovConfig % reflChannel) + if (allocated(rttovConfig % rttov_localtime)) deallocate(rttovConfig % rttov_localtime) + if (allocated(rttovConfig % rttov_localtime_width)) deallocate(rttovConfig % rttov_localtime_width) + if (allocated(rttovConfig % swath_mask)) deallocate(rttovConfig % swath_mask) + + END SUBROUTINE DESTROY_RTTOV_CONFIG !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_simulate - Call subroutines in mod_cosp_rttov to run RTTOV diff --git a/src/simulator/rttov/cosp_rttovSTUB.F90 b/src/simulator/rttov/cosp_rttovSTUB.F90 index f099632606..0b1171fe1e 100644 --- a/src/simulator/rttov/cosp_rttovSTUB.F90 +++ b/src/simulator/rttov/cosp_rttovSTUB.F90 @@ -59,12 +59,6 @@ MODULE MOD_COSP_RTTOV nSubCols ! Number of subcolumns integer,dimension(:),pointer :: & month - real(wp),dimension(:),pointer :: & ! Could change the dimensionality of these in the future - co2, & ! Carbon dioxide - ch4, & ! Methane - n2o, & ! n2o - co, & ! Carbon monoxide - time_frac ! real(wp),dimension(:),pointer :: & ! surfem ! Surface emissivities for the channels ! refl, & ! Surface reflectances for the channels @@ -77,15 +71,21 @@ MODULE MOD_COSP_RTTOV t2m, & ! 2 m Temperature q2m, & ! 2 m Specific humidity lsmask, & ! land-sea mask - latitude, & ! Latitude - longitude, & ! Longitude - seaice ! Sea-ice? + latitude, & ! Latitude (degrees) + longitude, & ! Longitude (degrees) + seaice, & ! Sea-ice? + time_frac ! Fractional UTC time [0-1] real(wp),dimension(:,:),pointer :: & p, & ! Pressure @ model levels ph, & ! Pressure @ model half levels t, & ! Temperature q, & ! Specific humidity - o3 ! Ozone + o3, & ! Ozone + co2, & ! Carbon dioxide + ch4, & ! Methane + n2o, & ! n2o + co, & ! Carbon monoxide + so2 ! Sulfur dioxide ! These fields below are needed ONLY for the RTTOV all-sky brightness temperature real(wp),dimension(:,:),pointer :: & tca, & ! Cloud fraction diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 8e2eb974c1..2b397f2d62 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -95,18 +95,6 @@ module mod_cosp_rttov real(wp),parameter :: eps = 0.622 ! Initialization parameters - - ! Number of channels to reconstruct (-1: None, 1:All, otherwise the actual number) - INTEGER(kind=jpim) :: nchannels_rec - - integer(kind=jpim) :: & ! Parallelization is default off - rttov_direct_nthreads = 1_jpim - integer(kind=jpim),allocatable :: & - iChannel(:), & ! RTTOV channel indices - iChannel_out(:) ! Passing out the channel indices - real(kind=jplm),allocatable :: & - emisChannel(:), & ! RTTOV channel emissivity - reflChannel(:) ! RTTOV channel reflectivity ! Scattering coefficients (read in once during initialization) ! JKS - KISS @@ -444,7 +432,7 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, print*,'inst_nchanprof: ',inst_nchanprof ! Determine the number of reconstructed radiances per profile (nchannels_rec) - if (allocated(inst_iChannel_out)) deallocate(inst_iChannel_out) ! Reset because this variable is internal and used by multiple instruments. ! JKS + if (allocated(inst_iChannel_out)) deallocate(inst_iChannel_out) ! Reset because this variable is internal and used by multiple instruments. if (inst_opts % rt_ir % pc % addradrec) then if (inst_nchannels_rec < 0) then ! If the number of channels is negative, don't reconstruct radiances at all From b2c3c45e08e0172c286f0af9664810e4f3fdd452 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Mon, 14 Aug 2023 15:17:08 -0600 Subject: [PATCH 080/159] Add debugging functionality in profile set-up for CESM --- driver/run/instrument_nls/cosp2_rttov_inst1.txt | 2 +- driver/run/instrument_nls/cosp2_rttov_inst2.txt | 1 + driver/run/instrument_nls/cosp2_rttov_inst3.txt | 1 + src/cosp.F90 | 7 ++++--- src/simulator/cosp_rttov_interface_v13.F90 | 9 ++++++--- src/simulator/rttov/cosp_rttov_v13.F90 | 15 ++++++++++++--- 6 files changed, 25 insertions(+), 10 deletions(-) diff --git a/driver/run/instrument_nls/cosp2_rttov_inst1.txt b/driver/run/instrument_nls/cosp2_rttov_inst1.txt index ed3fce4655..507b18f4a8 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst1.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst1.txt @@ -60,7 +60,7 @@ ! -------------- RTTOV Trace Gas Concentrations ! -------------- Specify units in RTTOV options set-up ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.true., ! Have RTTOV use the trace gas concentrations below + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below CO2_mr=5.241e-04, CH4_mr=9.139e-07, CO_mr=2.098e-07, diff --git a/driver/run/instrument_nls/cosp2_rttov_inst2.txt b/driver/run/instrument_nls/cosp2_rttov_inst2.txt index aaf75e2c80..e97960a366 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst2.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst2.txt @@ -59,6 +59,7 @@ ! -------------- RTTOV Trace Gas Concentrations ! -------------- Specify units in RTTOV options set-up ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below CO2_mr=5.241e-04, CH4_mr=9.139e-07, CO_mr=2.098e-07, diff --git a/driver/run/instrument_nls/cosp2_rttov_inst3.txt b/driver/run/instrument_nls/cosp2_rttov_inst3.txt index a4519108e5..9fab30f0c8 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst3.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst3.txt @@ -56,6 +56,7 @@ ! -------------- RTTOV Trace Gas Concentrations ! -------------- Specify units in RTTOV options set-up ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below CO2_mr=5.241e-04, CH4_mr=9.139e-07, CO_mr=2.098e-07, diff --git a/src/cosp.F90 b/src/cosp.F90 index b1c6967a44..a1d28646e1 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -751,7 +751,8 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) rttovIN%co => cospgridIN%co ! rttovIN%surfem => cospgridIN%emis_sfc ! rttovIN%refl_sfc => cospgridIN%refl_sfc - rttovIN%h_surf => cospgridIN%hgt_matrix_half(:,cospIN%Nlevels) +! rttovIN%h_surf => cospgridIN%hgt_matrix_half(:,cospIN%Nlevels) + rttovIN%h_surf => cospgridIN%surfelev rttovIN%u_surf => cospgridIN%u_sfc rttovIN%v_surf => cospgridIN%v_sfc rttovIN%t_skin => cospgridIN%skt @@ -4168,11 +4169,11 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, size(cospgridIN%at,2) .ne. cospIN%Nlevels .OR. & size(cospgridIN%qv,2) .ne. cospIN%Nlevels .OR. & size(cospgridIN%hgt_matrix_half,2) .ne. cospIN%Nlevels .OR. & - size(cospgridIN%phalf,2) .ne. cospIN%Nlevels+1 .OR. & - size(cospgridIN%qv,2) .ne. cospIN%Nlevels) then + size(cospgridIN%phalf,2) .ne. cospIN%Nlevels+1) then Lrttov_column = .false. nError=nError+1 errorMessage(nError) = 'ERROR(rttov_simulator): The number of levels in the input fields are inconsistent' + endif endif end subroutine cosp_errorCheck diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 4f70d1feeb..ead4f3da6f 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -662,7 +662,7 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, error ! Error messages (only populated if error encountered) real(wp),dimension(10) :: driver_time - logical :: verbose = .false. + logical :: verbose = .true. ! Run each step for running RTTOV from mod_cosp_rttov (and time them) call cpu_time(driver_time(1)) @@ -694,7 +694,8 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % SO2_mr, & rttovConfig % ZenAng, & rttovConfig % nprof, & - rttovConfig % swath_mask) + rttovConfig % swath_mask, & + verbose) call cpu_time(driver_time(3)) if (verbose) print*,'Beginning "cosp_rttov_setup_emissivity_reflectance".' @@ -777,6 +778,7 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, error ! Error messages (only populated if error encountered) real(wp),dimension(10) :: driver_time + logical :: verbose = .true. ! Run each step for running RTTOV from mod_cosp_rttov (and time them) call cpu_time(driver_time(1)) @@ -807,7 +809,8 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % SO2_mr, & rttovConfig % ZenAng, & rttovConfig % nprof, & - rttovConfig % swath_mask) + rttovConfig % swath_mask, & + verbose) call cpu_time(driver_time(3)) call cosp_pc_rttov_setup_emissivity() call cpu_time(driver_time(4)) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 2b397f2d62..b846994ce9 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -510,14 +510,16 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & inst_so2_mr, & inst_zenang, & inst_nprof, & - inst_swath_mask) + inst_swath_mask,& + verbose) type(rttov_in),intent(in) :: & ! What is the best way to do this? Should rttovIN be a module-wide DDT? Yes. rttovIN logical,intent(in) :: & Lrttov_cld, & Lrttov_aer, & - Luser_tracegas ! Use user-supplied trace gas columns from instrument namelists. + Luser_tracegas, & ! Use user-supplied trace gas columns from instrument namelists. + verbose real(wp),intent(in) :: & inst_co2_mr, & inst_ch4_mr, & @@ -532,7 +534,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & ! Loop variables integer(kind=jpim) :: i, j ! Use i to iterate over profile, j for swath_mask. - + ! Store profile data from rttovIN in profile type. ! See RTTOV user guide pg 163 for description of "profiles" type @@ -544,6 +546,13 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & profiles(:)%gas_units = 1 ! kg/kg over moist air (default) + if (verbose) then + print*,'shape(rttovIN%co2): ',shape(rttovIN%co2) + print*,'shape(rttovIN%n2o): ',shape(rttovIN%n2o) + print*,'rttovIN%co2(1,:): ',rttovIN%co2(1,1:10) + print*,'rttovIN%n2o(1,:): ',rttovIN%n2o(1,1:10) + end if + ! Iterate over all columns j = 0 ! Initialize input do i = 1, rttovIN%nPoints From d4cc126e212a6f5e497e86d325608531385a7d62 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 15 Aug 2023 09:52:33 -0600 Subject: [PATCH 081/159] Only assign trace gas profiles if specified in instrument namelist to avoid errors. --- src/simulator/cosp_rttov_interface_v13.F90 | 17 +++++++- src/simulator/rttov/cosp_rttov_v13.F90 | 49 ++++++++++++++-------- 2 files changed, 46 insertions(+), 20 deletions(-) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index ead4f3da6f..a42199b3cb 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -683,10 +683,17 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, call cpu_time(driver_time(2)) if (verbose) print*,'Beginning "cosp_rttov_construct_profiles".' - call cosp_rttov_construct_profiles(rttovIN, & + + call cosp_rttov_construct_profiles(rttovIN, & rttovConfig % Lrttov_cld, & rttovConfig % Lrttov_aer, & rttovConfig % user_tracegas_input, & + rttovConfig % opts % rt_all % CO2_data, & + rttovConfig % opts % rt_all % CH4_data, & + rttovConfig % opts % rt_all % CO_data, & + rttovConfig % opts % rt_all % N2O_data, & + rttovConfig % opts % rt_all % SO2_data, & + rttovConfig % opts % rt_all % ozone_data, & rttovConfig % CO2_mr, & rttovConfig % CH4_mr, & rttovConfig % CO_mr, & @@ -798,10 +805,16 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % iChannel_out, & rttovConfig % swath_mask) call cpu_time(driver_time(2)) - call cosp_rttov_construct_profiles(rttovIN, & + call cosp_rttov_construct_profiles(rttovIN, & rttovConfig % Lrttov_cld, & rttovConfig % Lrttov_aer, & rttovConfig % user_tracegas_input, & + rttovConfig % opts % rt_all % CO2_data, & + rttovConfig % opts % rt_all % CH4_data, & + rttovConfig % opts % rt_all % CO_data, & + rttovConfig % opts % rt_all % N2O_data, & + rttovConfig % opts % rt_all % SO2_data, & + rttovConfig % opts % rt_all % ozone_data, & rttovConfig % CO2_mr, & rttovConfig % CH4_mr, & rttovConfig % CO_mr, & diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index b846994ce9..509cefb063 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -503,6 +503,12 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & Lrttov_cld, & Lrttov_aer, & Luser_tracegas, & + Ldo_co2, & + Ldo_ch4, & + Ldo_co, & + Ldo_n2o, & + Ldo_so2, & + Ldo_o3, & inst_co2_mr, & inst_ch4_mr, & inst_co_mr, & @@ -519,6 +525,12 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & Lrttov_cld, & Lrttov_aer, & Luser_tracegas, & ! Use user-supplied trace gas columns from instrument namelists. + Ldo_co2, & + Ldo_ch4, & + Ldo_co, & + Ldo_n2o, & + Ldo_so2, & + Ldo_o3, & verbose real(wp),intent(in) :: & inst_co2_mr, & @@ -546,12 +558,12 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & profiles(:)%gas_units = 1 ! kg/kg over moist air (default) - if (verbose) then - print*,'shape(rttovIN%co2): ',shape(rttovIN%co2) - print*,'shape(rttovIN%n2o): ',shape(rttovIN%n2o) - print*,'rttovIN%co2(1,:): ',rttovIN%co2(1,1:10) - print*,'rttovIN%n2o(1,:): ',rttovIN%n2o(1,1:10) - end if +! if (verbose) then +! print*,'shape(rttovIN%co2): ',shape(rttovIN%co2) +! print*,'shape(rttovIN%n2o): ',shape(rttovIN%n2o) +! print*,'rttovIN%co2(1,:): ',rttovIN%co2(1,1:10) +! print*,'rttovIN%n2o(1,:): ',rttovIN%n2o(1,1:10) +! end if ! Iterate over all columns j = 0 ! Initialize input @@ -560,21 +572,22 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & if (inst_swath_mask(i)) then ! only added masked columns to profiles j = j + 1 ! Increment first - ! Initialize trace gas concentrations from user input - ! These gases are not in COSP input files but might be in the future + ! Initialize trace gas concentrations from user input. if (Luser_tracegas) then - profiles(j)%co2(:) = inst_co2_mr - profiles(j)%n2o(:) = inst_n2o_mr - profiles(j)%co(:) = inst_co_mr - profiles(j)%ch4(:) = inst_ch4_mr - profiles(j)%so2(:) = inst_so2_mr ! syntax slightly different? + if (Ldo_co2) profiles(j)%co2(:) = inst_co2_mr + if (Ldo_n2o) profiles(j)%n2o(:) = inst_n2o_mr + if (Ldo_co) profiles(j)%co(:) = inst_co_mr + if (Ldo_ch4) profiles(j)%ch4(:) = inst_ch4_mr + if (Ldo_so2) profiles(j)%so2(:) = inst_so2_mr + if (Ldo_o3) profiles(j)%o3(:) = rttovIN%o3(i, :) ! no O3 user input set up else ! For when trace gas columns are supplied by the model. Units must match (kg/kg over moist air) - profiles(j)%co2(:) = rttovIN%co2(i,:) - profiles(j)%n2o(:) = rttovIN%n2o(i,:) - profiles(j)%co(:) = rttovIN%co(i,:) - profiles(j)%ch4(:) = rttovIN%ch4(i,:) - profiles(j)%so2(:) = rttovIN%so2(i,:) + if (Ldo_co2) profiles(j)%co2(:) = rttovIN%co2(i,:) + if (Ldo_n2o) profiles(j)%n2o(:) = rttovIN%n2o(i,:) + if (Ldo_co) profiles(j)%co(:) = rttovIN%co(i,:) + if (Ldo_ch4) profiles(j)%ch4(:) = rttovIN%ch4(i,:) + if (Ldo_so2) profiles(j)%so2(:) = rttovIN%so2(i,:) + if (Ldo_o3) profiles(j)%o3(:) = rttovIN%o3(i, :) end if ! Initialize column pressure, temperature, and humidity From b44d2e3150260fca8c7d5b140c77c6ed0c4edf3b Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 15 Aug 2023 11:25:43 -0600 Subject: [PATCH 082/159] reorganize COSP_RTTOV_SIMULATE to not require all outputs --- src/cosp.F90 | 29 ++++++++++++++-------- src/simulator/cosp_rttov_interface_v13.F90 | 11 ++++---- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/cosp.F90 b/src/cosp.F90 index a1d28646e1..1c1cb28520 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -1546,6 +1546,13 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Init to R_UNDEF - JKS check rttov_bt_clear(:,:) = R_UNDEF rttov_rad_clear(:,:) = R_UNDEF + ! Run simulator + call cpu_time(driver_time(3)) + call cosp_rttov_simulate(rttovIN,cospIN%cfg_rttov(i),Lrttov_cleanUp, & ! Inputs + cosp_simulator(nError+1), & ! Error message holder + bt_clear=rttov_bt_clear, & ! Clear-sky BT + rad_clear=rttov_rad_clear) ! Clear-sky radiance + call cpu_time(driver_time(4)) else allocate(rttov_bt_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp allocate(rttov_bt_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! clear-sky brightness temp @@ -1562,17 +1569,19 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) rttov_rad_cloudy(:,:) = R_UNDEF rttov_refl_total(:,:) = R_UNDEF rttov_refl_clear(:,:) = R_UNDEF + ! Run simulator + call cpu_time(driver_time(3)) + call cosp_rttov_simulate(rttovIN,cospIN%cfg_rttov(i),Lrttov_cleanUp, & ! Inputs + cosp_simulator(nError+1), & ! Error message holder + bt_total=rttov_bt_total, & ! Brightness Temp Outputs + bt_clear=rttov_bt_clear, & + rad_total=rttov_rad_total, & ! Radiance Outputs + rad_clear=rttov_rad_clear, & + rad_cloudy=rttov_rad_cloudy, & + refl_total=rttov_refl_total, & ! Reflectance Outputs + refl_clear=rttov_refl_clear) + call cpu_time(driver_time(4)) endif - - call cpu_time(driver_time(3)) - ! Run simulator - call cosp_rttov_simulate(rttovIN,cospIN%cfg_rttov(i),Lrttov_cleanUp, & ! Inputs - rttov_bt_total,rttov_bt_clear, & ! Brightness Temp Outputs - rttov_rad_total,rttov_rad_clear,rttov_rad_cloudy, & ! Radiance Outputs - rttov_refl_total,rttov_refl_clear, & ! Reflectance Outputs - cosp_simulator(nError+1)) - call cpu_time(driver_time(4)) -! print*,'Time to run RTTOV: ',driver_time(4)-driver_time(3) ! JKS ! Write to cospOUT if (associated(cospOUT % rttov_outputs(i) % channel_indices)) & diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index a42199b3cb..4360077dfb 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -586,11 +586,10 @@ END SUBROUTINE DESTROY_RTTOV_CONFIG !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_simulate - Call subroutines in mod_cosp_rttov to run RTTOV !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & ! Inputs + SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup,error, & ! Inputs bt_total,bt_clear, & ! Brightness Temp Outputs rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs - refl_total,refl_clear, & ! Reflectance Outputs - error) + refl_total,refl_clear) ! Reflectance Outputs type(rttov_in),intent(in) :: & rttovIN @@ -598,7 +597,9 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & rttovConfig logical,intent(in) :: & lCleanup ! Flag to determine whether to deallocate RTTOV types - real(wp),intent(inout),dimension(rttovIN%nPoints,rttovConfig%nchan_out) :: & ! Can I do this? I guess so! + character(len=128),intent(inout) :: & + error ! Error messages (only populated if error encountered) + real(wp),intent(inout),dimension(rttovIN%nPoints,rttovConfig%nchan_out),optional :: & ! Can I do this? I guess so! bt_total, & ! All-sky bt_clear, & ! Clear-sky rad_total, & ! All-sky @@ -606,8 +607,6 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & rad_cloudy, & ! Cloudy-sky refl_total, & ! All-sky refl_clear ! Clear-sky - character(len=128) :: & - error ! Error messages (only populated if error encountered) ! Check options to determine if the principal component approach should be run if (rttovConfig % opts % rt_ir % pc % addpc) then From 4d3e13af652ea61143f9b726d49265a5b65b66f0 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 15 Aug 2023 13:48:53 -0600 Subject: [PATCH 083/159] Add tca (cloud fraction) to the error check subroutine --- src/cosp.F90 | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/cosp.F90 b/src/cosp.F90 index 1c1cb28520..062514ebab 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -3372,6 +3372,26 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, end do end if endif + if (any(cospgridIN%tca .lt. 0 .OR. cospgridIN%tca .gt. 1)) then ! tca on [0,1] + nError=nError+1 + errorMessage(nError) = 'ERROR: COSP input variable: cospIN%tca contains values out of range' + print*,'cospgridIN%tca: ',cospgridIN%tca + Lrttov_column = .false. + if (associated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if + endif endif ! COSP_INPUTS From e427b8c23f794e51dfc51388d9808f27f0357e38 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Thu, 17 Aug 2023 17:07:37 -0600 Subject: [PATCH 084/159] Added functional print statement via the namelist option rttov_verbose --- driver/run/cosp2_input_rttov_nl.txt | 7 +- driver/run/cosp2_input_rttov_nl.um_global.txt | 7 +- driver/src/cosp2_test.F90 | 79 +++++----- src/cosp.F90 | 47 +++--- src/simulator/cosp_rttov_interface_v13.F90 | 76 ++++++---- src/simulator/rttov/cosp_rttov_v13.F90 | 143 +++++++++++------- 6 files changed, 212 insertions(+), 147 deletions(-) diff --git a/driver/run/cosp2_input_rttov_nl.txt b/driver/run/cosp2_input_rttov_nl.txt index 207f9ed86d..61a6b75fc6 100644 --- a/driver/run/cosp2_input_rttov_nl.txt +++ b/driver/run/cosp2_input_rttov_nl.txt @@ -84,8 +84,7 @@ !---------------------------------------------------------------------------------- rttov_Ninstruments=3, rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt', - Lrttov_localtime=.false., ! May not be necessary at this level - rttov_Nlocaltime=2, - rttov_localtime=10.0,13.0, ! To implement local time - rttov_localtimewindow=1.0,1.0, ! To implement local time width +! rttov_Ninstruments=1, +! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt', + rttov_verbose=.false. / diff --git a/driver/run/cosp2_input_rttov_nl.um_global.txt b/driver/run/cosp2_input_rttov_nl.um_global.txt index a4ecf2914d..3d7c7d2ad3 100644 --- a/driver/run/cosp2_input_rttov_nl.um_global.txt +++ b/driver/run/cosp2_input_rttov_nl.um_global.txt @@ -84,8 +84,7 @@ !---------------------------------------------------------------------------------- rttov_Ninstruments=3, rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt', - Lrttov_localtime=.false., ! May not be necessary at this level - rttov_Nlocaltime=2, - rttov_localtime=10.0,13.0, ! To implement local time - rttov_localtimewindow=1.0,1.0, ! To implement local time width +! rttov_Ninstruments=1, +! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt', + rttov_verbose=.true. / diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 1245365d93..1a2b444222 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -53,7 +53,6 @@ program cosp2_test grLidar532_histBsct,atlid_histBsct,vgrid_zu,vgrid_zl, & Nlvgrid_local => Nlvgrid, & vgrid_z,cloudsat_preclvl -! RTTOV_MAX_LOCALTIMES,RTTOV_MAX_CHANNELS use cosp_phys_constants, only: amw,amd,amO3,amCO2,amCH4,amN2O,amCO use mod_cosp_io, only: nc_read_input_file,write_cosp2_output USE mod_quickbeam_optics,only: size_distribution,hydro_class_init,quickbeam_optics, & @@ -138,8 +137,7 @@ program cosp2_test ! (0=ice-spheres/1=ice-non-spherical) overlap, & ! Overlap type: 1=max, 2=rand, 3=max/rand isccp_topheight, & ! ISCCP cloud top height - isccp_topheight_direction, & ! ISCCP cloud top height direction - rttov_Nlocaltime ! RTTOV: Number of local times to be computed + isccp_topheight_direction ! ISCCP cloud top height direction integer :: rttov_Ninstruments = 0 real(wp) :: & ! cloudsat_radar_freq, & ! CloudSat radar frequency (GHz) @@ -149,10 +147,6 @@ program cosp2_test csat_vgrid, & ! CloudSat vertical grid? use_precipitation_fluxes ! True if precipitation fluxes are input to the ! algorithm - logical :: Lrttov_localtime = .false. - real(wp),dimension(10) :: & ! JKS - reasonable limit at 10 - rttov_localtime, & ! RTTOV subsetting by local time in hours [0,24] - rttov_localtimewindow ! Width of local time window (hrs). character(len=64) :: & cloudsat_micro_scheme ! Microphysical scheme used in cloudsat radar simulator character(len=64) :: & @@ -172,8 +166,7 @@ program cosp2_test npoints_it, ncolumns, nlevels, use_vgrid, Nlvgrid, csat_vgrid, dinput, finput, & foutput, cloudsat_radar_freq, surface_radar, cloudsat_use_gas_abs,cloudsat_do_ray,& cloudsat_k2, cloudsat_micro_scheme, lidar_ice_type, use_precipitation_fluxes, & - rttov_Ninstruments, rttov_instrument_namelists, & - Lrttov_localtime, rttov_Nlocaltime, rttov_localtime, rttov_localtimewindow + rttov_Ninstruments, rttov_instrument_namelists, rttov_verbose ! Output namelist logical :: Lcfaddbze94,Ldbze94,Latb532,LcfadLidarsr532,Lclcalipso,Lclhcalipso, & @@ -199,6 +192,7 @@ program cosp2_test Lptradarflag9,Lradarpia, & Lwr_occfreq,Lcfodd logical :: Lrttov_run = .false. + logical :: rttov_verbose = .false. namelist/COSP_OUTPUT/Lcfaddbze94,Ldbze94,Latb532,LcfadLidarsr532,Lclcalipso, & Lclhcalipso,Lcllcalipso,Lclmcalipso,Lcltcalipso,LparasolRefl, & Lclcalipsoliq,Lclcalipsoice,Lclcalipsoun,Lclcalipsotmp, & @@ -307,6 +301,7 @@ program cosp2_test close(10) ! Jonah namelist checking area + print*,'rttov_verbose: ',rttov_verbose print*,'Lrttov_run: ',Lrttov_run print*,'rttov_Ninstruments: ',rttov_Ninstruments @@ -420,7 +415,8 @@ program cosp2_test 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, & - rttov_Ninstruments, rttov_instrument_namelists_final, rttov_configs) + rttov_Ninstruments, rttov_instrument_namelists_final, rttov_configs, & + debug=rttov_verbose) call cpu_time(driver_time(3)) !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -463,6 +459,7 @@ program cosp2_test !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Determine indices for "chunking" (again, if necessary) !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + if (nChunks .eq. 1) then start_idx = 1 end_idx = nPoints @@ -495,9 +492,11 @@ program cosp2_test ! surface-2-TOA, whereas COSP expects all fields to be ordered from TOA-2-SFC. So the ! vertical fields are flipped prior to storing to COSP input type. !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + cospIN%emsfc_lw = emsfc_lw cospIN%rcfg_cloudsat = rcfg_cloudsat cospIN%cfg_rttov => rttov_configs ! JKS - Not sure why the cloudsat isn't a pointer. The config files for RTTOV are large and I don't want them duplicated in memory + cospstateIN%hgt_matrix = zlev(start_idx:end_idx,Nlevels:1:-1) ! km cospstateIN%sunlit = sunlit(start_idx:end_idx) ! 0-1 cospstateIN%skt = skt(start_idx:end_idx) ! K @@ -516,8 +515,8 @@ program cosp2_test ! Assign RTTOV values ! Keeping these structures since refl and emis could come from model input - cospstateIN%emis_sfc = 0._wp - cospstateIN%refl_sfc = 0._wp + cospstateIN%emis_sfc(:,:) = 0._wp + cospstateIN%refl_sfc(:,:) = 0._wp ! Well-mixed gases are not provided in COSP offline input, so hardcoding them in. ! Units are kg/kg over moist air. @@ -575,7 +574,7 @@ program cosp2_test !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Call COSP !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - cosp_status = COSP_SIMULATOR(cospIN, cospstateIN, cospOUT,start_idx,end_idx,.false.) + cosp_status = COSP_SIMULATOR(cospIN, cospstateIN, cospOUT,start_idx,end_idx,rttov_verbose) do ij=1,size(cosp_status,1) if (cosp_status(ij) .ne. '') print*,trim(cosp_status(ij)) end do @@ -601,11 +600,17 @@ program cosp2_test !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Free up memory !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + if (rttov_verbose) print*,'Calling "destroy_cosp_outputs".' call destroy_cosp_outputs(cospOUT) + if (rttov_verbose) print*,'Calling "rttov_cleanup".' + call rttov_cleanup(cospIN) + if (rttov_verbose) print*,'Calling "destroy_cospIN".' call destroy_cospIN(cospIN) - deallocate(rttov_configs) + if (rttov_verbose) print*,'Calling "destroy_cospstateIN".' call destroy_cospstateIN(cospstateIN) + if (rttov_verbose) print*,'Calling "cosp_cleanUp".' call cosp_cleanUp() + if (rttov_verbose) print*,'all done.' contains !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1426,22 +1431,8 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& x % N_rttov_instruments = N_rttov_instruments allocate(x % rttov_outputs(N_rttov_instruments)) ! Need to allocate a pointer? do i=1,N_rttov_instruments - print*,'i: ',i - print*,'rttov_configs(i) % nchan_out: ',rttov_configs(i) % nchan_out - print*,'rttov_configs(i) % Lrttov_bt: ',rttov_configs(i) % Lrttov_bt - print*,'rttov_configs(i) % Lrttov_rad: ',rttov_configs(i) % Lrttov_rad - print*,'rttov_configs(i) % Lrttov_refl: ',rttov_configs(i) % Lrttov_refl - print*,'rttov_configs(i) % Lrttov_cld: ',rttov_configs(i) % Lrttov_cld - print*,'rttov_configs(i) % Lrttov_aer: ',rttov_configs(i) % Lrttov_aer - print*,'rttov_configs(i) % Lrttov_pc: ',rttov_configs(i) % Lrttov_pc - print*,'rttov_configs(i) % rttov_Nlocaltime: ',rttov_configs(i) % rttov_Nlocaltime - print*,'rttov_configs(i) % rttov_localtime: ',rttov_configs(i) % rttov_localtime - print*,'rttov_configs(i) % rttov_localtime_width: ',rttov_configs(i) % rttov_localtime_width - - print*,'1.' x % rttov_outputs(i) % nchan_out = rttov_configs(i) % nchan_out if (rttov_configs(i) % Lrttov_pc) then ! Treat PC-RTTOV fields as clear-sky only for now - print*,'2a.' allocate(x % rttov_outputs(i) % channel_indices(rttov_configs(i) % nchan_out)) if (rttov_configs(i) % Lrttov_bt) then ! Brightness temp allocate(x % rttov_outputs(i) % bt_total_pc(Npoints,rttov_configs(i) % nchan_out)) @@ -1453,7 +1444,6 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& ! if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_rad_cloudy(Npoints,Nchan)) end if else - print*,'3a.' allocate(x % rttov_outputs(i) % channel_indices(rttov_configs(i) % nchan_out)) if (rttov_configs(i) % Lrttov_bt) then ! Brightness temp allocate(x % rttov_outputs(i) % bt_total(Npoints,rttov_configs(i) % nchan_out)) @@ -1487,11 +1477,8 @@ end subroutine construct_cosp_outputs !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE destroy_cospIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine destroy_cospIN(y) - use MOD_COSP_RTTOV_INTERFACE, only: DESTROY_RTTOV_CONFIG - + subroutine destroy_cospIN(y) type(cosp_optical_inputs),intent(inout) :: y - integer :: i if (allocated(y%tau_067)) deallocate(y%tau_067) if (allocated(y%emiss_11)) deallocate(y%emiss_11) @@ -1522,12 +1509,6 @@ subroutine destroy_cospIN(y) if (allocated(y%tautot_atlid)) deallocate(y%tautot_atlid) if (allocated(y%fracPrecipIce)) deallocate(y%fracPrecipIce) - if (size(y%cfg_rttov) .gt. 0) then - do i=1,y%Ninst_rttov - call destroy_rttov_config(y%cfg_rttov(i)) - end do - end if - end subroutine destroy_cospIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE destroy_cospstateIN @@ -1934,6 +1915,24 @@ subroutine destroy_cosp_outputs(y) end if end subroutine destroy_cosp_outputs - + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE destroy_cospIN + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine rttov_cleanup(y) + use MOD_COSP_RTTOV_INTERFACE, only: DESTROY_RTTOV_CONFIG + + type(cosp_optical_inputs),intent(inout) :: y + integer :: i + + if (size(y%cfg_rttov) .gt. 0) then + do i=1,y%Ninst_rttov + call destroy_rttov_config(y%cfg_rttov(i)) + end do + end if +! deallocate(y%cfg_rttov) + + end subroutine rttov_cleanup + end program cosp2_test diff --git a/src/cosp.F90 b/src/cosp.F90 index 062514ebab..f1f7c69954 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -328,11 +328,13 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) type(cloudsat_IN) :: cloudsatIN ! Input to the CLOUDSAT radar simulator type(modis_IN) :: modisIN ! Input to the MODIS simulator type(rttov_IN) :: rttovIN ! Input to the RTTOV simulator - integer,optional :: start_idx,stop_idx - logical,optional :: debug ! Outputs from the simulators (nested simulator output structure) type(cosp_outputs), intent(inout) :: cospOUT + + integer,optional :: start_idx,stop_idx + logical,optional :: debug + character(len=256),dimension(100) :: cosp_simulator ! Local variables @@ -366,10 +368,11 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) Llidar_only_freq_cloud, & ! On/Off switch from joint Calipso/Cloudsat product Lcloudsat_modis_wr ! On/Off switch from joint CloudSat/MODIS warm rain product logical :: & - ok_lidar_cfad = .false., & + ok_lidar_cfad = .false., & ok_lidar_cfad_grLidar532 = .false., & - ok_lidar_cfad_atlid = .false., & - lrttov_cleanUp = .false. + ok_lidar_cfad_atlid = .false., & + lrttov_cleanUp = .false., & + verbose = .false. real(wp),dimension(10) :: driver_time integer, dimension(:),allocatable :: & rttov_Ichannel @@ -408,6 +411,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Initialize error reporting for output cosp_simulator(:)='' + if (present(debug)) verbose = debug !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 1) Determine if using full inputs or subset @@ -775,7 +779,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) rttovIN%cldIce => cospgridIN%cloudIce rttovIN%cldLiq => cospgridIN%cloudLiq rttovIN%fl_rain => cospgridIN%fl_rain ! JKS remove? - rttovIN%fl_snow => cospgridIN%fl_snow ! JKS remove? + rttovIN%fl_snow => cospgridIN%fl_snow ! JKS remove? endif !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1538,7 +1542,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) do i=1,cospIN%Ninst_rttov ! Allocate memory for the outputs - I won't need all of these in every situation. ! Only allocate clear-sky memory when PC-RTTOV is run. -! print*,'cospIN % cfg_rttov(i) % nchan_out: ',cospIN % cfg_rttov(i) % nchan_out ! JKS allocate(rttov_Ichannel(cospIN % cfg_rttov(i) % nchan_out)) ! Channel indices if (cospIN % cfg_rttov(i) % Lrttov_pc) then allocate(rttov_bt_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp @@ -1579,7 +1582,8 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) rad_clear=rttov_rad_clear, & rad_cloudy=rttov_rad_cloudy, & refl_total=rttov_refl_total, & ! Reflectance Outputs - refl_clear=rttov_refl_clear) + refl_clear=rttov_refl_clear, & + debug=verbose) call cpu_time(driver_time(4)) endif @@ -1604,6 +1608,11 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospOUT % rttov_outputs(i) % rad_cloudy(ij:ik,:) = rttov_rad_cloudy if (associated(cospOUT % rttov_outputs(i) % refl_total)) & cospOUT % rttov_outputs(i) % refl_total(ij:ik,:) = rttov_refl_total + if (verbose) then + print*,'associated(cospOUT % rttov_outputs(i) % bt_total): ',associated(cospOUT % rttov_outputs(i) % bt_total) + print*,'associated(cospOUT % rttov_outputs(i) % refl_total): ',associated(cospOUT % rttov_outputs(i) % refl_total) + print*,'associated(cospOUT % rttov_outputs(i) % refl_clear): ',associated(cospOUT % rttov_outputs(i) % refl_clear) + end if if (associated(cospOUT % rttov_outputs(i) % refl_clear)) & cospOUT % rttov_outputs(i) % refl_clear(ij:ik,:) = rttov_refl_clear endif @@ -1841,7 +1850,7 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La cloudsat_radar_freq, cloudsat_k2, cloudsat_use_gas_abs, cloudsat_do_ray, & isccp_top_height, isccp_top_height_direction, surface_radar, rcfg, lusevgrid, & luseCSATvgrid, Nvgrid, Nlevels, cloudsat_micro_scheme, & - rttov_Ninstruments, rttov_instrument_namelists,rttov_configs,unitn) + rttov_Ninstruments, rttov_instrument_namelists,rttov_configs,unitn,debug) ! INPUTS logical,intent(in) :: Lisccp,Lmodis,Lmisr,Lcloudsat,Lcalipso,LgrLidar532,Latlid,Lparasol @@ -1875,10 +1884,15 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La ! Optional args integer,intent(in),Optional :: unitn ! Used for io limits + logical,intent(in),Optional :: debug + logical :: verbose = .false. ! Local variables integer :: i real(wp) :: zstep + + ! Init debug print statements: + if (present(debug)) verbose = debug ! Initialize MODIS optical-depth bin boundaries for joint-histogram. (defined in cosp_config.F90) if (.not. allocated(modis_histTau)) then @@ -1919,23 +1933,21 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La if (Lmodis) call cosp_modis_init() if (Lmisr) call cosp_misr_init() - ! I think that I will try to store an object of rttov_init_objects here, - - ! Could print diagnostic on timing here. if (Lrttov) then call cpu_time(driver_time(1)) - print*,'rttov_instrument_namelists: ',rttov_instrument_namelists ! JKS test + if (verbose) print*,'rttov_instrument_namelists: ',rttov_instrument_namelists if (present(unitn)) then call cosp_rttov_init(Lrttov,Nlevels,rttov_Ninstruments, & rttov_instrument_namelists, & - rttov_configs,unitn=unitn) + rttov_configs,unitn=unitn, & + debug=verbose) else call cosp_rttov_init(Lrttov,Nlevels,rttov_Ninstruments, & rttov_instrument_namelists, & - rttov_configs) + rttov_configs,debug=verbose) end if call cpu_time(driver_time(2)) -! print*,'Time to run cosp_rttov_init: ',driver_time(2)-driver_time(1) + if (verbose) print*,'Time to run cosp_rttov_init: ',driver_time(2)-driver_time(1) endif if (Lcloudsat) call cosp_cloudsat_init(cloudsat_radar_freq,cloudsat_k2, & @@ -1952,7 +1964,7 @@ END SUBROUTINE COSP_INIT !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_cleanUp !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_cleanUp() + subroutine cosp_cleanUp() deallocate(vgrid_zl,vgrid_zu,vgrid_z,dz) end subroutine cosp_cleanUp @@ -3375,7 +3387,6 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, if (any(cospgridIN%tca .lt. 0 .OR. cospgridIN%tca .gt. 1)) then ! tca on [0,1] nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospIN%tca contains values out of range' - print*,'cospgridIN%tca: ',cospgridIN%tca Lrttov_column = .false. if (associated(cospOUT%rttov_outputs)) then do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 4360077dfb..cb041cc696 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -135,7 +135,7 @@ MODULE MOD_COSP_RTTOV_INTERFACE ! SUBROUTINE cosp_rttov_init !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SUBROUTINE COSP_RTTOV_INIT(Lrttov, Nlevels,Ninstruments,instrument_namelists, & - rttov_configs, unitn) + rttov_configs, unitn, debug) logical,intent(in) :: & Lrttov @@ -144,27 +144,25 @@ SUBROUTINE COSP_RTTOV_INIT(Lrttov, Nlevels,Ninstruments,instrument_namelists, Ninstruments type(character(len=256)), dimension(Ninstruments) :: & instrument_namelists ! Array of paths to RTTOV instrument namelists - type(rttov_cfg), dimension(:), intent(out), allocatable :: & ! intent(out)? + type(rttov_cfg), dimension(:), intent(out), allocatable :: & rttov_configs - integer,intent(in),Optional :: unitn ! Used for io limits + integer,intent(in),Optional :: unitn + logical,intent(in),Optional :: debug ! Local variables integer :: & inst_idx ! iterator + logical :: verbose + if (present(debug)) verbose = debug allocate(rttov_configs(Ninstruments)) ! Create config objects for each instrument to be simulated by RTTOV. Return to the main subroutine. do inst_idx=1,Ninstruments -! print*,'inst_idx: ',inst_idx -! print*,'instrument_namelists(inst_idx): ',instrument_namelists(inst_idx) -! print*,'kind(rttov_configs(inst_idx)): ',kind(rttov_configs(inst_idx)) -! print*,'rttov_configs(inst_idx): ',rttov_configs(inst_idx) if (present(unitn)) then -! print*,'instrument_namelists(inst_idx): ',instrument_namelists(inst_idx) ! JKS check - call cosp_rttov_init_s(Nlevels,instrument_namelists(inst_idx),rttov_configs(inst_idx),unitn=unitn) + call cosp_rttov_init_s(Nlevels,instrument_namelists(inst_idx),rttov_configs(inst_idx),unitn=unitn,debug=verbose) else - call cosp_rttov_init_s(Nlevels,instrument_namelists(inst_idx),rttov_configs(inst_idx)) + call cosp_rttov_init_s(Nlevels,instrument_namelists(inst_idx),rttov_configs(inst_idx),debug=verbose) endif end do @@ -175,7 +173,7 @@ END SUBROUTINE COSP_RTTOV_INIT ! SUBROUTINE cosp_rttov_init !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & - rttov_config, unitn) + rttov_config, unitn, debug) integer,intent(in) :: & Nlevels @@ -183,9 +181,10 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & namelist_filepath ! Array of paths to RTTOV instrument namelists type(rttov_cfg),intent(out) :: & ! intent(out)? rttov_config - + integer,intent(in),Optional :: unitn ! Used for io limits - + logical,intent(in),Optional :: debug + ! Local variables character(len=256),target :: & channel_filepath, & @@ -246,7 +245,10 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & ! JKS for checking errors in filenames. character(len=256) :: imsg !<-- some suitable length, say XX=256 integer :: erro - + + logical :: verbose = .false. + if (present(debug)) verbose = debug + ! Init. variables to false. rttov_Nlocaltime = 0 Lrttov_bt = .false. @@ -489,7 +491,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & nchannels_rec = rttov_config % coefs % coef % fmv_chn print*,'nchannels_rec cap hit' endif - endif + endif ! We aren't checking an allocation steps so this seems more appropriate. call rttov_error('fatal error reading coefficients' , lalloc = .false.) @@ -500,7 +502,6 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & ! We aren't checking an allocation steps so this seems more appropriate. call rttov_error('error in rttov options' , lalloc = .false.) - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Figure out how many channels we actually want to reconstruct !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -543,6 +544,19 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & allocate(rttov_config % iChannel(rttov_config % nchan_out)) rttov_config % iChannel(:) = (/ (i, i = 1, rttov_config % nchan_out) /) endif + + if (verbose) then + print*,'rttov_config % nchan_out: ',rttov_config % nchan_out + print*,'rttov_config % Lrttov_bt: ',rttov_config % Lrttov_bt + print*,'rttov_config % Lrttov_rad: ',rttov_config % Lrttov_rad + print*,'rttov_config % Lrttov_refl: ',rttov_config % Lrttov_refl + print*,'rttov_config % Lrttov_cld: ',rttov_config % Lrttov_cld + print*,'rttov_config % Lrttov_aer: ',rttov_config % Lrttov_aer + print*,'rttov_config % Lrttov_pc: ',rttov_config % Lrttov_pc + print*,'rttov_config % rttov_Nlocaltime: ',rttov_config % rttov_Nlocaltime + print*,'rttov_config % rttov_localtime: ',rttov_config % rttov_localtime + print*,'rttov_config % rttov_localtime_width: ',rttov_config % rttov_localtime_width + end if ! subsub routines contains @@ -589,7 +603,8 @@ END SUBROUTINE DESTROY_RTTOV_CONFIG SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup,error, & ! Inputs bt_total,bt_clear, & ! Brightness Temp Outputs rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs - refl_total,refl_clear) ! Reflectance Outputs + refl_total,refl_clear, & ! Reflectance Outputs + debug) type(rttov_in),intent(in) :: & rttovIN @@ -607,20 +622,23 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup,error, rad_cloudy, & ! Cloudy-sky refl_total, & ! All-sky refl_clear ! Clear-sky + logical,intent(in),optional :: & + debug + + logical :: verbose = .false. + if (present(debug)) verbose = debug ! Check options to determine if the principal component approach should be run if (rttovConfig % opts % rt_ir % pc % addpc) then call COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & bt_clear,rad_clear, & - error) - + error,verbose) else call COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & bt_total,bt_clear, & rad_total,rad_clear,rad_cloudy, & refl_total,refl_clear, & - error) - + error,verbose) endif END SUBROUTINE COSP_RTTOV_SIMULATE @@ -632,7 +650,7 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, bt_total,bt_clear, & ! Brightness Temp Outputs rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs refl_total,refl_clear, & ! Reflectance Outputs - error) + error,verbose) use mod_cosp_rttov, only: & cosp_rttov_allocate, & @@ -657,11 +675,11 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rad_cloudy, & ! Cloudy-sky refl_total, & ! All-sky refl_clear ! Clear-sky - character(len=128) :: & - error ! Error messages (only populated if error encountered) + character(len=128),intent(inout) :: & + error ! Error messages (only populated if error encountered) + logical,intent(in) :: verbose real(wp),dimension(10) :: driver_time - logical :: verbose = .true. ! Run each step for running RTTOV from mod_cosp_rttov (and time them) call cpu_time(driver_time(1)) @@ -759,8 +777,8 @@ END SUBROUTINE COSP_REG_RTTOV_SIMULATE ! SUBROUTINE cosp_pc_rttov_simulate - Call subroutines in mod_cosp_rttov to run RTTOV !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & ! Inputs - bt_clear,rad_clear, & ! Outputs - error) + bt_clear,rad_clear, & ! Outputs + error,verbose) use mod_cosp_rttov, only: & cosp_pc_rttov_allocate, & @@ -780,11 +798,11 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, real(wp),intent(inout),dimension(rttovIN%nPoints,rttovConfig%nchan_out) :: & ! Can I do this? I guess so! bt_clear, & ! All-sky rad_clear ! All-sky - character(len=128) :: & + character(len=128),intent(inout) :: & error ! Error messages (only populated if error encountered) + logical,intent(in) :: verbose real(wp),dimension(10) :: driver_time - logical :: verbose = .true. ! Run each step for running RTTOV from mod_cosp_rttov (and time them) call cpu_time(driver_time(1)) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 509cefb063..8084838885 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -204,7 +204,7 @@ end subroutine rttov_error subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & inst_coefs,inst_iChannel,rttov_Nlocaltime, & rttov_localtime,rttov_localtime_width, & - inst_nchanprof,inst_nprof,swath_mask) + inst_nchanprof,inst_nprof,swath_mask,debug) type(rttov_in),intent(in) :: & rttovIN @@ -226,6 +226,8 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & inst_nprof ! Now accounting for orbits logical(jplm),dimension(rttovIN % nPoints),intent(inout) :: & swath_mask + logical,intent(in),optional :: & + debug !---- Local variables ----! ! Loop variables @@ -241,6 +243,10 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & dlon, & ! distance to satellite longitude in degrees dx ! distance to satellite longitude in km? + logical :: verbose = .false. + + if (present(debug)) verbose = debug + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 3. Allocate RTTOV input and output structures ! ------------------------------------------------------ @@ -248,7 +254,7 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Handle swathing here. Initial code from Genevieve with minor changes. - if (rttov_Nlocaltime > 0) then + if (rttov_Nlocaltime .gt. 0) then ! Iterate over local times do j=1,rttov_Nlocaltime ! Calculate the central longitude for each gridcell and orbit @@ -274,7 +280,6 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & swath_mask(j) = .true. end if end do - ! Determine the total number of radiances to simulate (nchanprof). else swath_mask(:) = .true. ! Compute on all columns in no local times are passed. end if @@ -282,9 +287,11 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & inst_nprof = count(swath_mask) inst_nchanprof = inst_nChannels_rec * inst_nprof - print*,'inst_nprof: ',inst_nprof - print*,'inst_nChannels_rec: ',inst_nChannels_rec - print*,'inst_nchanprof: ',inst_nchanprof + if (verbose) then + print*,'inst_nprof: ',inst_nprof + print*,'inst_nChannels_rec: ',inst_nChannels_rec + print*,'inst_nchanprof: ',inst_nchanprof + end if ! Allocate structures for rttov_direct call rttov_alloc_direct( & @@ -320,7 +327,7 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & chanprof(nch)%chan = inst_iChannel(jch) ! Example code used channel_list end do end do - print*,'Done with "cosp_rttov_allocate"' + if (verbose) print*,'Done with "cosp_rttov_allocate"' end subroutine cosp_rttov_allocate @@ -335,7 +342,8 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, inst_coefs,inst_opts, & inst_nchannels_rec,inst_iChannel_in, & rttov_Nlocaltime,rttov_localtime,rttov_localtime_width, & - inst_nchanprof,inst_nprof,inst_iChannel_out,swath_mask) + inst_nchanprof,inst_nprof,inst_iChannel_out,swath_mask, & + debug) type(rttov_in),intent(in) :: & rttovIN @@ -361,6 +369,8 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, inst_iChannel_out(:) ! Passing out the channel indices logical(jplm),dimension(rttovIN % nPoints),intent(inout) :: & swath_mask + logical,intent(in),optional :: & + debug ! Loop variables integer(kind=jpim) :: j, jch, nch @@ -378,6 +388,10 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, swath_mask_all, & ! Mask of reals over all local times dlon, & ! distance to satellite longitude in degrees dx ! distance to satellite longitude in km? + + logical :: verbose = .false. + + if (present(debug)) verbose = debug ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 3. Allocate RTTOV input and output structures @@ -426,27 +440,29 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, ! npred_pc is only used in the pc_rttov_allocate step so I can remove the global definition later inst_npred_pc = SIZE(predictindex) inst_nchanprof = inst_npred_pc * inst_nprof ! Size of chanprof array is total number of predictors over all profiles - - print*,'inst_nprof: ',inst_nprof - print*,'inst_nChannels_rec: ',inst_nChannels_rec - print*,'inst_nchanprof: ',inst_nchanprof + + if (verbose) then + print*,'inst_nprof: ',inst_nprof + print*,'inst_nChannels_rec: ',inst_nChannels_rec + print*,'inst_nchanprof: ',inst_nchanprof + end if ! Determine the number of reconstructed radiances per profile (nchannels_rec) if (allocated(inst_iChannel_out)) deallocate(inst_iChannel_out) ! Reset because this variable is internal and used by multiple instruments. if (inst_opts % rt_ir % pc % addradrec) then if (inst_nchannels_rec < 0) then ! If the number of channels is negative, don't reconstruct radiances at all - print*,'radrec 1.' + if (verbose) print*,'radrec 1.' inst_opts % rt_ir % pc % addradrec = .FALSE. else if (inst_nchannels_rec == 0) then ! If the number of channels is set to 0 then reconstruct all instrument channels - print*,'radrec 2.' + if (verbose) print*,'radrec 2.' inst_nchannels_rec = inst_coefs % coef % fmv_chn allocate(inst_iChannel_out(inst_nchannels_rec)) inst_iChannel_out = (/ (j, j = 1, inst_nchannels_rec) /) else ! Otherwise read the channel list from the file - print*,'radrec 3.' + if (verbose) print*,'radrec 3.' allocate(inst_iChannel_out(inst_nchannels_rec)) inst_iChannel_out = inst_iChannel_in endif @@ -517,7 +533,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & inst_zenang, & inst_nprof, & inst_swath_mask,& - verbose) + debug) type(rttov_in),intent(in) :: & ! What is the best way to do this? Should rttovIN be a module-wide DDT? Yes. rttovIN @@ -530,8 +546,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & Ldo_co, & Ldo_n2o, & Ldo_so2, & - Ldo_o3, & - verbose + Ldo_o3 real(wp),intent(in) :: & inst_co2_mr, & inst_ch4_mr, & @@ -543,10 +558,15 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & inst_nprof logical(kind=jplm),dimension(rttovIN % nPoints),intent(in) :: & inst_swath_mask + logical,intent(in),optional :: & + debug ! Loop variables integer(kind=jpim) :: i, j ! Use i to iterate over profile, j for swath_mask. - + logical :: verbose = .false. + + if (present(debug)) verbose = debug + ! Store profile data from rttovIN in profile type. ! See RTTOV user guide pg 163 for description of "profiles" type @@ -558,12 +578,13 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & profiles(:)%gas_units = 1 ! kg/kg over moist air (default) -! if (verbose) then -! print*,'shape(rttovIN%co2): ',shape(rttovIN%co2) -! print*,'shape(rttovIN%n2o): ',shape(rttovIN%n2o) -! print*,'rttovIN%co2(1,:): ',rttovIN%co2(1,1:10) -! print*,'rttovIN%n2o(1,:): ',rttovIN%n2o(1,1:10) -! end if + if (verbose) then + print*,'shape(rttovIN%co2): ',shape(rttovIN%co2) + print*,'shape(rttovIN%n2o): ',shape(rttovIN%n2o) + print*,'rttovIN%co2(1,:): ',rttovIN%co2(1,1:10) + print*,'rttovIN%n2o(1,:): ',rttovIN%n2o(1,1:10) +! print*,'rttovIN%t_skin: ',rttovIN%t_skin + end if ! Iterate over all columns j = 0 ! Initialize input @@ -613,7 +634,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & ! skin variables for emissivity calculations profiles(j)%skin%t = rttovIN%t_skin(i) - + ! fastem coefficients - for mw calculations profiles(j)%skin%fastem(1) = 3.0 profiles(j)%skin%fastem(2) = 5.0 @@ -654,11 +675,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & ! JKS - nothing to check here, this will never trigger. call rttov_error('error in profile initialization' , lalloc = .false.) - -! print*,'profiles(1)%p(:): ',profiles(1)%p(:) -! print*,'profiles(1)%q(:): ',profiles(1)%q(:) -! print*,'profiles(1)%t(:): ',profiles(1)%t(:) - + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Only add the cloud fields if simulating cloud. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -775,7 +792,8 @@ end subroutine cosp_pc_rttov_setup_emissivity subroutine cosp_rttov_call_direct(inst_nthreads, & inst_opts, & - inst_coefs) + inst_coefs, & + debug) integer(KIND=jpim),intent(in) :: & inst_nthreads @@ -783,15 +801,23 @@ subroutine cosp_rttov_call_direct(inst_nthreads, & inst_opts type(rttov_coefs),intent(in) :: & inst_coefs - - print*,'shape(chanprof%prof): ',shape(chanprof%prof) - print*,'shape(chanprof%chan): ',shape(chanprof%chan) - print*,'shape(profiles): ',shape(profiles) + logical,intent(in),optional :: & + debug + logical :: verbose = .false. + + if (present(debug)) verbose = debug + + if (verbose) then + print*,'shape(chanprof%prof): ',shape(chanprof%prof) + print*,'shape(chanprof%chan): ',shape(chanprof%chan) + print*,'shape(profiles): ',shape(profiles) ! print*,'shape(profiles(:)%q): ',shape(profiles(:)%q) ! print*,'shape(bt_total): ',shape(bt_total) - + end if + + if (inst_nthreads <= 1) then - print*,'Calling rttov_direct' + if (verbose) print*,'Calling rttov_direct' call rttov_direct( & errorstatus, &! out error flag chanprof, &! in channel and profile index structure @@ -805,7 +831,7 @@ subroutine cosp_rttov_call_direct(inst_nthreads, & calcrefl = calcrefl, &! in flag for internal BRDF calcs reflectance = reflectance) ! inout input/output BRDFs per channel else - print*,'Calling rttov_parallel_direct' + if (verbose) print*,'Calling rttov_parallel_direct' call rttov_parallel_direct( & errorstatus, &! out error flag chanprof, &! in channel and profile index structure @@ -834,7 +860,8 @@ subroutine cosp_pc_rttov_call_direct(inst_nthreads, & inst_opts, & inst_coefs, & inst_nchannels_rec, & - inst_channels_rec) + inst_channels_rec, & + debug) integer(KIND=jpim),intent(in) :: & inst_nthreads @@ -846,9 +873,14 @@ subroutine cosp_pc_rttov_call_direct(inst_nthreads, & inst_nchannels_rec integer(jpim),dimension(inst_nchannels_rec),intent(in) :: & inst_channels_rec + logical,intent(in),optional :: & + debug + logical :: verbose = .false. + + if (present(debug)) verbose = debug if (inst_nthreads <= 1) then - print*,'Calling rttov_direct (PC-RTTOV)' + if (verbose) print*,'Calling rttov_direct (PC-RTTOV)' call rttov_direct( & errorstatus, &! out error flag chanprof, &! in channel and profile index structure @@ -862,7 +894,7 @@ subroutine cosp_pc_rttov_call_direct(inst_nthreads, & pccomp = pccomp, &! inout computed PC scores channels_rec = inst_channels_rec) ! in reconstructed channel list else - print*,'Calling rttov_parallel_direct (PC-RTTOV)' + if (verbose) print*,'Calling rttov_parallel_direct (PC-RTTOV)' call rttov_parallel_direct( & errorstatus, &! out error flag chanprof, &! in channel and profile index structure @@ -989,7 +1021,8 @@ subroutine cosp_pc_rttov_save_output(nPoints, & Lrttov_bt, & Lrttov_rad, & bt_clear, & - rad_clear) + rad_clear, & + debug) integer,intent(in) :: & nPoints, & @@ -1002,18 +1035,24 @@ subroutine cosp_pc_rttov_save_output(nPoints, & real(wp),dimension(nPoints,inst_nchannels_rec),intent(inout) :: & ! Can I do this? I guess so! bt_clear, & rad_clear - + logical,intent(in),optional :: & + debug + ! Local iterators. i is the gridcell index. j is the swath cells index. integer :: i, j + logical :: verbose = .false. -! print*,'shape(bt_total): ',shape(bt_total) -! print*,'shape(rad_total): ',shape(rad_total) -! print*,'nPoints: ',nPoints -! print*,'inst_nchannels_rec: ',inst_nchannels_rec -! print*,'nchanprof: ',nchanprof ! This is the number of predictors so not the reconstructed channel dimension -! print*,'size(pccomp%bt_pccomp): ',size(pccomp%bt_pccomp) -! print*,'size(pccomp%total_pccomp): ',size(pccomp%total_pccomp) -! print*,'inst_nchannels_rec * nPoints: ',inst_nchannels_rec * nPoints + if (present(debug)) verbose = debug + + if (verbose) then + print*,'shape(bt_total): ',shape(bt_clear) + print*,'shape(rad_total): ',shape(rad_clear) + print*,'nPoints: ',nPoints + print*,'inst_nchannels_rec: ',inst_nchannels_rec + print*,'size(pccomp%bt_pccomp): ',size(pccomp%bt_pccomp) + print*,'size(pccomp%total_pccomp): ',size(pccomp%total_pccomp) + print*,'inst_nchannels_rec * nPoints: ',inst_nchannels_rec * nPoints + end if ! Documentation for RTTOV radiance structure in RTTOV User Guide pg 166 From d3937c6f11943f98218a76f89027ad7eafa4d7d7 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Mon, 21 Aug 2023 09:59:46 -0600 Subject: [PATCH 085/159] Compatibility with STUB files and a small change to rttov_cfg deallocation. --- driver/run/cosp2_input_nl.txt | 22 +++++------ driver/run/cosp2_input_rttov_nl.txt | 8 ++-- driver/run/cosp2_output_nl.txt | 2 +- driver/run/cosp2_output_rttov_nl.txt | 11 +----- driver/src/cosp2_test.F90 | 4 +- src/simulator/cosp_rttov_interfaceSTUB.F90 | 44 ++++++---------------- 6 files changed, 30 insertions(+), 61 deletions(-) diff --git a/driver/run/cosp2_input_nl.txt b/driver/run/cosp2_input_nl.txt index 65a16fc44d..f27d166f55 100644 --- a/driver/run/cosp2_input_nl.txt +++ b/driver/run/cosp2_input_nl.txt @@ -82,15 +82,15 @@ !---------------------------------------------------------------------------------- !-------------- RTTOV inputs !---------------------------------------------------------------------------------- - rttov_Platform=1, ! satellite platform - rttov_Satellite=15, ! satellite - rttov_Instrument=5, ! instrument - rttov_Nchannels=3, ! Number of channels to be computed - rttov_Channels=1,2,3, ! Channel numbers (please be sure that you supply Nchannels) - rttov_Surfem=0.0,0.0,0.0, ! Surface emissivity (please be sure that you supply Nchannels) - rttov_ZenAng=50.0, ! Satellite Zenith Angle - CO2=5.241e-04, ! Mixing ratios of trace gases - CH4=9.139e-07, - N2O=4.665e-07, - CO=2.098e-07 +! rttov_Platform=1, ! satellite platform +! rttov_Satellite=15, ! satellite +! rttov_Instrument=5, ! instrument +! rttov_Nchannels=3, ! Number of channels to be computed +! rttov_Channels=1,2,3, ! Channel numbers (please be sure that you supply Nchannels) +! rttov_Surfem=0.0,0.0,0.0, ! Surface emissivity (please be sure that you supply Nchannels) +! rttov_ZenAng=50.0, ! Satellite Zenith Angle +! CO2=5.241e-04, ! Mixing ratios of trace gases +! CH4=9.139e-07, +! N2O=4.665e-07, +! CO=2.098e-07 / diff --git a/driver/run/cosp2_input_rttov_nl.txt b/driver/run/cosp2_input_rttov_nl.txt index 61a6b75fc6..0e30eb90ce 100644 --- a/driver/run/cosp2_input_rttov_nl.txt +++ b/driver/run/cosp2_input_rttov_nl.txt @@ -82,9 +82,9 @@ !---------------------------------------------------------------------------------- !-------------- RTTOV inputs !---------------------------------------------------------------------------------- - rttov_Ninstruments=3, - rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt', -! rttov_Ninstruments=1, -! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt', +! rttov_Ninstruments=3, +! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt', + rttov_Ninstruments=1, + rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt', rttov_verbose=.false. / diff --git a/driver/run/cosp2_output_nl.txt b/driver/run/cosp2_output_nl.txt index 7f39228c71..be75d7d0a9 100755 --- a/driver/run/cosp2_output_nl.txt +++ b/driver/run/cosp2_output_nl.txt @@ -133,7 +133,7 @@ Liwpmodis=.true., Lclmodis=.true., !- RTTOV - Ltbrttov=.false., +! Ltbrttov=.false., ! -CLOUDSAT precipitation frequency/occurence diagnostics Lptradarflag0=.true., Lptradarflag1=.true., diff --git a/driver/run/cosp2_output_rttov_nl.txt b/driver/run/cosp2_output_rttov_nl.txt index 168091067e..9c8a349949 100755 --- a/driver/run/cosp2_output_rttov_nl.txt +++ b/driver/run/cosp2_output_rttov_nl.txt @@ -133,16 +133,7 @@ Liwpmodis=.true., Lclmodis=.true., !- RTTOV - Lrttov_run=.true., - Lrttov_bt=.true., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aer=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_localtime=.false., ! May not be necessary at this level - Lrttov_pc=.false., + Lrttov_run=.true., ! Run RTTOV? ! -CLOUDSAT precipitation frequency/occurence diagnostics Lptradarflag0=.true., Lptradarflag1=.true., diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 1a2b444222..a3839f9ef1 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -1917,7 +1917,7 @@ subroutine destroy_cosp_outputs(y) end subroutine destroy_cosp_outputs !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE destroy_cospIN + ! SUBROUTINE rttov_cleanup !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine rttov_cleanup(y) use MOD_COSP_RTTOV_INTERFACE, only: DESTROY_RTTOV_CONFIG @@ -1930,7 +1930,7 @@ subroutine rttov_cleanup(y) call destroy_rttov_config(y%cfg_rttov(i)) end do end if -! deallocate(y%cfg_rttov) + nullify(y%cfg_rttov) end subroutine rttov_cleanup diff --git a/src/simulator/cosp_rttov_interfaceSTUB.F90 b/src/simulator/cosp_rttov_interfaceSTUB.F90 index c3bd27371e..02bf7dbc88 100644 --- a/src/simulator/cosp_rttov_interfaceSTUB.F90 +++ b/src/simulator/cosp_rttov_interfaceSTUB.F90 @@ -100,7 +100,7 @@ MODULE MOD_COSP_RTTOV_INTERFACE ! SUBROUTINE cosp_rttov_init !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SUBROUTINE COSP_RTTOV_INIT(Lrttov,Nlevels,Ninstruments,instrument_namelists, & - rttov_configs,unitn) + rttov_configs,unitn,debug) logical,intent(inout) :: & Lrttov @@ -112,6 +112,7 @@ SUBROUTINE COSP_RTTOV_INIT(Lrttov,Nlevels,Ninstruments,instrument_namelists, type(rttov_cfg), dimension(:), intent(out), allocatable :: & ! intent(out)? rttov_configs integer,intent(in),Optional :: unitn ! Used for io limits + logical,intent(in),Optional :: debug Lrttov = .false. allocate(rttov_configs(Ninstruments)) @@ -141,12 +142,12 @@ END SUBROUTINE DESTROY_RTTOV_CONFIG !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_simulate - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & ! Inputs + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup,error, & ! Inputs bt_total,bt_clear, & ! Brightness Temp Outputs rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs refl_total,refl_clear, & ! Reflectance Outputs - error) + debug) type(rttov_in),intent(in) :: & rttovIN @@ -154,16 +155,18 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & rttovConfig logical,intent(in) :: & lCleanup ! Flag to determine whether to deallocate RTTOV types - real(wp),intent(inout),dimension(rttovIN%nPoints,rttovConfig%nchan_out) :: & ! Can I do this? I guess so! + character(len=128) :: & + error ! Error messages (only populated if error encountered) + real(wp),intent(inout),dimension(rttovIN%nPoints,rttovConfig%nchan_out),optional :: & bt_total, & ! All-sky bt_clear, & ! Clear-sky rad_total, & ! All-sky rad_clear, & ! Clear-sky rad_cloudy, & ! Cloudy-sky refl_total, & ! All-sky - refl_clear ! Clear-sky - character(len=128) :: & - error ! Error messages (only populated if error encountered) + refl_clear ! Clear-sky + logical,intent(in),optional :: & + debug print*,'Running COSP_RTTOV_SIMULATE from STUB files.', & 'To run RTTOV, compile COSP after setting environmental variable "RTTOV"' @@ -171,31 +174,6 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & END SUBROUTINE COSP_RTTOV_SIMULATE - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE cosp_pc_rttov_simulate - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & ! Inputs - bt_total,rad_total, & ! Outputs - error) - - type(rttov_in),intent(in) :: & - rttovIN - type(rttov_cfg),intent(inout) :: & - rttovConfig - logical,intent(in) :: & - lCleanup ! Flag to determine whether to deallocate RTTOV types - real(wp),intent(inout),dimension(rttovIN%nPoints,rttovConfig%nchan_out) :: & ! Can I do this? I guess so! - bt_total, & ! All-sky - rad_total ! All-sky - character(len=128) :: & - error ! Error messages (only populated if error encountered) - - print*,'Running COSP_PC_RTTOV_SIMULATE from STUB files.', & - 'To run RTTOV, compile COSP after setting environmental variable "RTTOV"' - ! How do I want the interface to function? How should it to be consistent with the rest of COSP? - - END SUBROUTINE COSP_PC_RTTOV_SIMULATE - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! END MODULE ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From e65345c78920617cf9d1d3afed20a0f33b01f03e Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 22 Aug 2023 10:32:01 -0600 Subject: [PATCH 086/159] Make the "rttov_output" DDT allocatable rather than a pointer. Data arrays within the DDT are still pointers inited to null() --- driver/run/cosp2_input_rttov_nl.txt | 8 ++-- driver/src/cosp2_io.f90 | 6 +-- driver/src/cosp2_test.F90 | 3 +- src/cosp.F90 | 44 +++++++++++----------- src/simulator/cosp_rttov_interface_v13.F90 | 20 +++++----- 5 files changed, 40 insertions(+), 41 deletions(-) diff --git a/driver/run/cosp2_input_rttov_nl.txt b/driver/run/cosp2_input_rttov_nl.txt index 0e30eb90ce..61a6b75fc6 100644 --- a/driver/run/cosp2_input_rttov_nl.txt +++ b/driver/run/cosp2_input_rttov_nl.txt @@ -82,9 +82,9 @@ !---------------------------------------------------------------------------------- !-------------- RTTOV inputs !---------------------------------------------------------------------------------- -! rttov_Ninstruments=3, -! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt', - rttov_Ninstruments=1, - rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt', + rttov_Ninstruments=3, + rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt', +! rttov_Ninstruments=1, +! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt', rttov_verbose=.false. / diff --git a/driver/src/cosp2_io.f90 b/driver/src/cosp2_io.f90 index 4f6522e3fb..4829a08c64 100644 --- a/driver/src/cosp2_io.f90 +++ b/driver/src/cosp2_io.f90 @@ -86,7 +86,7 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Ninst_rttov, lev, lon, if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) ! Define instrument channel indices for multiple RTTOV instruments - if (associated(cospOUT%rttov_outputs)) then + if (allocated(cospOUT%rttov_outputs)) then do i=1,Ninst_rttov write (i_str,fmt) i ! converting integer to string i_str using a 'internal file' status = nf90_def_dim(fileID,"RTTOV_CHAN_INST"//trim(i_str),cospOUT % rttov_outputs(i) % nchan_out,dimID(20+i)) ! Start at 100 for RTTOV output channel dimensions @@ -1438,7 +1438,7 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Ninst_rttov, lev, lon, ! Define instrument channel indices for multiple RTTOV instruments ii = 165 ! RTTOV variable indices start at 165 - if (associated(cospOUT%rttov_outputs)) then + if (allocated(cospOUT%rttov_outputs)) then do i=1,Ninst_rttov write (i_str,fmt) i ! converting integer to string i_str using a 'internal file' if (associated(cospOUT%rttov_outputs(i)%channel_indices)) then @@ -2033,7 +2033,7 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Ninst_rttov, lev, lon, ! Define instrument channel indices for multiple RTTOV instruments ii = 165 ! RTTOV variable indices start at 166 - if (associated(cospOUT%rttov_outputs)) then + if (allocated(cospOUT%rttov_outputs)) then do i=1,Ninst_rttov write (i_str,fmt) i ! converting integer to string i_str using a 'internal file' if (associated(cospOUT%rttov_outputs(i)%channel_indices)) then diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index a3839f9ef1..2df0667893 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -1867,7 +1867,7 @@ subroutine destroy_cosp_outputs(y) endif ! RTTOV multi-instrument - if (associated(y%rttov_outputs)) then + if (allocated(y%rttov_outputs)) then do i=1,y % N_rttov_instruments ! Iterate over each instrument if (associated(y%rttov_outputs(i)%channel_indices)) then deallocate(y%rttov_outputs(i)%channel_indices) @@ -1911,7 +1911,6 @@ subroutine destroy_cosp_outputs(y) endif end do deallocate(y%rttov_outputs) - nullify(y%rttov_outputs) end if end subroutine destroy_cosp_outputs diff --git a/src/cosp.F90 b/src/cosp.F90 index f1f7c69954..9d792eff17 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -305,8 +305,8 @@ MODULE MOD_COSP wr_occfreq_ntotal => null() ! # of nonprecip/drizzle/precip (Npoints,WR_NREGIME) integer :: & N_rttov_instruments - type(rttov_output),pointer :: & - rttov_outputs(:) + type(rttov_output),dimension(:),allocatable :: & + rttov_outputs end type cosp_outputs @@ -512,7 +512,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) Lparasol_subcolumn = .true. ! RTTOV Column - if (associated(cospOUT%rttov_outputs)) then + if (allocated(cospOUT%rttov_outputs)) then Lrttov_column = .true. endif @@ -2698,7 +2698,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, endif if (.not. alloc_status) then Lrttov_column = .false. - if (associated(cospOUT%rttov_outputs)) then + if (allocated(cospOUT%rttov_outputs)) then do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF @@ -2809,7 +2809,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lcloudsat_tcc = .false. Lcloudsat_tcc2 = .false. Lcloudsat_modis_wr = .false. - if (associated(cospOUT%rttov_outputs)) then + if (allocated(cospOUT%rttov_outputs)) then do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF @@ -2864,7 +2864,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lisccp_subcolumn = .false. Lisccp_column = .false. Lrttov_column = .false. - if (associated(cospOUT%rttov_outputs)) then + if (allocated(cospOUT%rttov_outputs)) then do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF @@ -2902,7 +2902,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lrttov_column = .false. Latlid_column = .false. LgrLidar532_column = .false. - if (associated(cospOUT%rttov_outputs)) then + if (allocated(cospOUT%rttov_outputs)) then do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF @@ -2992,7 +2992,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lisccp_subcolumn = .false. Lisccp_column = .false. Lrttov_column = .false. - if (associated(cospOUT%rttov_outputs)) then + if (allocated(cospOUT%rttov_outputs)) then do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF @@ -3082,7 +3082,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Latlid_column = .false. LgrLidar532_column = .false. Lcloudsat_modis_wr = .false. - if (associated(cospOUT%rttov_outputs)) then + if (allocated(cospOUT%rttov_outputs)) then do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF @@ -3130,7 +3130,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lrttov_column = .false. Lcalipso_column = .false. Lparasol_column = .false. - if (associated(cospOUT%rttov_outputs)) then + if (allocated(cospOUT%rttov_outputs)) then do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF @@ -3166,7 +3166,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lisccp_subcolumn = .false. Lisccp_column = .false. Lrttov_column = .false. - if (associated(cospOUT%rttov_outputs)) then + if (allocated(cospOUT%rttov_outputs)) then do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF @@ -3198,7 +3198,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%co2 contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_outputs)) then + if (allocated(cospOUT%rttov_outputs)) then do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF @@ -3217,7 +3217,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%ch4 contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_outputs)) then + if (allocated(cospOUT%rttov_outputs)) then do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF @@ -3236,7 +3236,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%n2o contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_outputs)) then + if (allocated(cospOUT%rttov_outputs)) then do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF @@ -3255,7 +3255,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%co contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_outputs)) then + if (allocated(cospOUT%rttov_outputs)) then do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF @@ -3274,7 +3274,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%o3 contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_outputs)) then + if (allocated(cospOUT%rttov_outputs)) then do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF @@ -3293,7 +3293,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, ! nError=nError+1 ! errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%emis_sfc contains values out of range' ! Lrttov_column = .false. -! if (associated(cospOUT%rttov_outputs)) then +! if (allocated(cospOUT%rttov_outputs)) then ! do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument ! if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 ! if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF @@ -3312,7 +3312,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, ! nError=nError+1 ! errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%refl_sfc contains values out of range' ! Lrttov_column = .false. -! if (associated(cospOUT%rttov_outputs)) then +! if (allocated(cospOUT%rttov_outputs)) then ! do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument ! if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 ! if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF @@ -3331,7 +3331,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospIN%u_sfc contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_outputs)) then + if (allocated(cospOUT%rttov_outputs)) then do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF @@ -3350,7 +3350,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospIN%v_sfc contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_outputs)) then + if (allocated(cospOUT%rttov_outputs)) then do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF @@ -3369,7 +3369,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospIN%lat contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_outputs)) then + if (allocated(cospOUT%rttov_outputs)) then do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF @@ -3388,7 +3388,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospIN%tca contains values out of range' Lrttov_column = .false. - if (associated(cospOUT%rttov_outputs)) then + if (allocated(cospOUT%rttov_outputs)) then do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index cb041cc696..b521768933 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -116,17 +116,17 @@ MODULE MOD_COSP_RTTOV_INTERFACE integer :: & nchan_out integer,pointer :: & - channel_indices(:) + channel_indices(:) => null() real(wp),pointer :: & - bt_total(:,:), & - bt_clear(:,:), & - rad_total(:,:), & - rad_clear(:,:), & - rad_cloudy(:,:), & - refl_total(:,:), & - refl_clear(:,:), & - bt_total_pc(:,:), & - rad_total_pc(:,:) + bt_total(:,:) => null(), & + bt_clear(:,:) => null(), & + rad_total(:,:) => null(), & + rad_clear(:,:) => null(), & + rad_cloudy(:,:) => null(), & + refl_total(:,:) => null(), & + refl_clear(:,:) => null(), & + bt_total_pc(:,:) => null(), & + rad_total_pc(:,:) => null() end type rttov_output CONTAINS From ae145e0e311d32988ce0f2fb6ef08edabbcf3686 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 29 Aug 2023 15:48:38 -0600 Subject: [PATCH 087/159] RTTOV SZA and surface mask implementation. Also create t2m and q2m variables. --- driver/run/cosp2_input_rttov_nl.txt | 2 +- .../run/instrument_nls/cosp2_rttov_inst1.txt | 5 +- driver/src/cosp2_test.F90 | 18 +-- src/cosp.F90 | 137 +++++++++++++++--- src/simulator/cosp_rttov_interface_v13.F90 | 1 + src/simulator/rttov/cosp_rttov_v13.F90 | 73 ++++++---- 6 files changed, 176 insertions(+), 60 deletions(-) diff --git a/driver/run/cosp2_input_rttov_nl.txt b/driver/run/cosp2_input_rttov_nl.txt index 61a6b75fc6..800c2ec8e4 100644 --- a/driver/run/cosp2_input_rttov_nl.txt +++ b/driver/run/cosp2_input_rttov_nl.txt @@ -86,5 +86,5 @@ rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt', ! rttov_Ninstruments=1, ! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt', - rttov_verbose=.false. + rttov_verbose=.true. / diff --git a/driver/run/instrument_nls/cosp2_rttov_inst1.txt b/driver/run/instrument_nls/cosp2_rttov_inst1.txt index 507b18f4a8..4be037e2d0 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst1.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst1.txt @@ -41,7 +41,6 @@ channel_filepath='rttov_channel_input_AIRS.csv', rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov13pred54L/rtcoef_eos_2_modis-shifted_7gas.dat', aer_coef_filepath='cldaer_visir/scaercoef_eos_2_modis-shifted_cams.dat', cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_modis-shifted.dat', @@ -75,7 +74,5 @@ rttov_nthreads=16, rttov_ZenAng=0.0, ! Satellite Zenith Angle ! Set local time sampling with swath widths - rttov_Nlocaltime=2, ! Number of local times to sample at - rttov_localtime=0.75,13.5, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=3.e3,5.6e3, ! Swath width (km) + rttov_Nlocaltime=0, ! Number of local times to sample at / diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 2df0667893..321fb61121 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -530,7 +530,7 @@ program cosp2_test ! Time information cospstateIN%month = month(start_idx:end_idx) cospstateIN%time_frac = (60*hour(start_idx:end_idx) + minute(start_idx:end_idx)) / (24*60) ! Time (UTC) expressed as a fraction on [0,1] - !deallocate(month,hour,minute) ! JKS - helpful? + cospstateIN%sza = 0._wp ! => null() didn't work. ! JKS nothing passed in the UKMO input. ! From the data input file cospstateIN%u_sfc = u_wind(start_idx:end_idx) @@ -552,7 +552,7 @@ program cosp2_test fl_lsgrpl(start_idx:end_idx,Nlevels:1:-1) ! Inputs not supplied in the UKMO test data - cospstateIN%seaice(:) = 0._wp + cospstateIN%rttov_sfcmask = landmask(start_idx:end_idx) ! (0=ocn,1=land,2=seaice). No sea ice in UKMO input here. !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Generate subcolumns and compute optical inputs. @@ -1096,14 +1096,14 @@ subroutine construct_cospstateIN(npoints,nlevels,y) allocate(y%sunlit(npoints),y%skt(npoints),y%land(npoints),y%at(npoints,nlevels), & y%pfull(npoints,nlevels),y%phalf(npoints,nlevels+1),y%qv(npoints,nlevels), & y%o3(npoints,nlevels),y%hgt_matrix(npoints,nlevels),y%u_sfc(npoints), & - y%v_sfc(npoints),y%lat(npoints),y%lon(nPoints), & + y%v_sfc(npoints),y%lat(npoints),y%lon(nPoints),y%rttov_sfcmask(nPoints), & y%co(npoints,nlevels),y%n2o(npoints,nlevels),y%ch4(npoints,nlevels), & y%co2(npoints,nlevels), & ! y%emis_sfc(npoints,nchan),y%refl_sfc(npoints,nchan), & - y%cloudIce(nPoints,nLevels),y%cloudLiq(nPoints,nLevels),y%surfelev(npoints),& - y%fl_snow(nPoints,nLevels),y%fl_rain(nPoints,nLevels),y%seaice(npoints), & - y%tca(nPoints,nLevels),y%hgt_matrix_half(npoints,nlevels), & - y%month(nPoints),y%time_frac(nPoints)) + y%cloudIce(nPoints,nLevels),y%cloudLiq(nPoints,nLevels),y%surfelev(nPoints),& + y%fl_snow(nPoints,nLevels),y%fl_rain(nPoints,nLevels), & + y%tca(nPoints,nLevels),y%hgt_matrix_half(nPoints,nlevels), & + y%month(nPoints),y%time_frac(nPoints),y%sza(nPoints)) end subroutine construct_cospstateIN @@ -1519,6 +1519,7 @@ subroutine destroy_cospstateIN(y) if (allocated(y%sunlit)) deallocate(y%sunlit) if (allocated(y%skt)) deallocate(y%skt) if (allocated(y%land)) deallocate(y%land) + if (allocated(y%rttov_sfcmask)) deallocate(y%rttov_sfcmask) if (allocated(y%at)) deallocate(y%at) if (allocated(y%pfull)) deallocate(y%pfull) if (allocated(y%phalf)) deallocate(y%phalf) @@ -1528,6 +1529,7 @@ subroutine destroy_cospstateIN(y) if (allocated(y%surfelev)) deallocate(y%surfelev) if (allocated(y%month)) deallocate(y%month) if (allocated(y%time_frac)) deallocate(y%time_frac) + if (allocated(y%sza)) deallocate(y%sza) if (allocated(y%co2)) deallocate(y%co2) if (allocated(y%ch4)) deallocate(y%ch4) if (allocated(y%n2o)) deallocate(y%n2o) @@ -1541,11 +1543,9 @@ subroutine destroy_cospstateIN(y) if (allocated(y%refl_sfc)) deallocate(y%refl_sfc) if (allocated(y%cloudIce)) deallocate(y%cloudIce) if (allocated(y%cloudLiq)) deallocate(y%cloudLiq) - if (allocated(y%seaice)) deallocate(y%seaice) if (allocated(y%fl_rain)) deallocate(y%fl_rain) if (allocated(y%fl_snow)) deallocate(y%fl_snow) if (allocated(y%tca)) deallocate(y%tca) - if (allocated(y%time_frac)) deallocate(y%time_frac) end subroutine destroy_cospstateIN diff --git a/src/cosp.F90 b/src/cosp.F90 index 9d792eff17..c1c4a93603 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -105,26 +105,29 @@ MODULE MOD_COSP ! Last level contains the bottom of the surface layer. real(wp),allocatable,dimension(:) :: & - land, & ! Land/Sea mask (0-1) + land, & ! Land/Sea mask (0 for ocean, 1 for land) skt, & ! Surface temperature (K) - surfelev ! Surface Elevation (m) + surfelev, & ! Surface Elevation (m) + rttov_sfcmask ! Mask for RTTOV surface types (0 for ocean, 1 for land, 2 for sea ice) ! Fields used ONLY by RTTOV integer,allocatable,dimension(:) :: & month ! Month for surface emissivty atlas (1-12) real(wp),allocatable,dimension(:) :: & u_sfc, & ! Surface u-wind (m/s) v_sfc, & ! Surface v-wind (m/s) - seaice, & ! Sea-ice fraction (0-1) + t2m, & ! 2-meter temperature (K) + q2m, & ! 2-meter specific humidity (kg/kg) lat, & ! Latitude (deg) lon, & ! Longitude (deg) - time_frac ! Time (UTC) expressed as a fraction on [0,1] + time_frac, & ! Time (UTC) expressed as a fraction on [0,1] + sza ! Solar Zenith Angle in degrees real(wp),allocatable,dimension(:,:) :: & - emis_sfc, & ! Surface emissivity (1) - refl_sfc, & ! Surface reflectance (1) o3, & ! Ozone (kg/kg) tca, & ! Total layer cloud fraction (0-1) cloudIce, & ! Cloud ice water mixing ratio (kg/kg) cloudLiq, & ! Cloud liquid water mixing ratio (kg/kg) + emis_sfc, & ! Surface emissivity (point,channel) (1) + refl_sfc, & ! Surface reflectance (point,channel) (1) fl_rain, & ! Precipitation (rain) flux (kg/m2/s) fl_snow ! Precipitation (snow) flux (kg/m2/s) end type cosp_column_inputs @@ -761,12 +764,20 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) rttovIN%v_surf => cospgridIN%v_sfc rttovIN%t_skin => cospgridIN%skt rttovIN%p_surf => cospgridIN%phalf(:,cospIN%Nlevels+1) - rttovIN%q2m => cospgridIN%qv(:,cospIN%Nlevels) - rttovIN%t2m => cospgridIN%at(:,cospIN%Nlevels) - rttovIN%lsmask => cospgridIN%land + if (allocated(cospgridIN%q2m)) then + rttovIN%q2m => cospgridIN%q2m(:) + else + rttovIN%q2m => cospgridIN%qv(:,cospIN%Nlevels) + end if + if (allocated(cospgridIN%t2m)) then + rttovIN%t2m => cospgridIN%t2m(:) + else + rttovIN%t2m => cospgridIN%at(:,cospIN%Nlevels) + end if + rttovIN%sfcmask => cospgridIN%rttov_sfcmask rttovIN%latitude => cospgridIN%lat rttovIN%longitude => cospgridIN%lon - rttovIN%seaice => cospgridIN%seaice +! rttovIN%seaice => cospgridIN%seaice rttovIN%p => cospgridIN%pfull rttovIN%ph => cospgridIN%phalf rttovIN%t => cospgridIN%at @@ -775,6 +786,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Below only needed for all-sky RTTOV calculation rttovIN%month => cospgridIN%month rttovIN%time_frac => cospgridIN%time_frac + rttovIN%sza => cospgridIN%sza ! JKS make optional? Defeats the purpose of the "associated" check in cosp_rttov_v13. rttovIN%tca => cospgridIN%tca rttovIN%cldIce => cospgridIN%cloudIce rttovIN%cldLiq => cospgridIN%cloudLiq @@ -2626,9 +2638,9 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%at has not been allocated' alloc_status = .false. endif - if (.not. allocated(cospgridIN%land)) then + if (.not. allocated(cospgridIN%rttov_sfcmask)) then nError=nError+1 - errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%land has not been allocated' + errorMessage(nError) = 'ERROR: COSP input variable (RTTOV simulator): cospgridIN%rttov_sfcmask has not been allocated' alloc_status = .false. endif if (.not. allocated(cospgridIN%lat)) then @@ -2641,11 +2653,6 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%lon has not been allocated' alloc_status = .false. endif - if (.not. allocated(cospgridIN%seaice)) then - nError=nError+1 - errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%seaice has not been allocated' - alloc_status = .false. - endif if (.not. allocated(cospgridIN%pfull)) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%pfull has not been allocated' @@ -2676,6 +2683,21 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%tca has not been allocated' alloc_status = .false. endif + if (.not. allocated(cospgridIN%month)) then + nError=nError+1 + errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%month has not been allocated' + alloc_status = .false. + endif + if (.not. allocated(cospgridIN%time_frac)) then + nError=nError+1 + errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%time_frac has not been allocated' + alloc_status = .false. + endif + if (.not. allocated(cospgridIN%sza)) then + nError=nError+1 + errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%sza has not been allocated' + alloc_status = .false. + endif if (.not. allocated(cospgridIN%cloudIce)) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%cloudIce has not been allocated' @@ -3327,6 +3349,25 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, ! end do ! end if ! endif + if (any(cospgridIN%rttov_sfcmask .lt. 0 .or. cospgridIN%rttov_sfcmask .gt. 2)) then + nError=nError+1 + errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%rttov_sfcmask contains values out of range' + Lrttov_column = .false. + if (allocated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if + endif if (any(cospgridIN%u_sfc .lt. -100. .OR. cospgridIN%u_sfc .gt. 100.)) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospIN%u_sfc contains values out of range' @@ -3384,6 +3425,25 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, end do end if endif + if (any(cospgridIN%lon .lt. -180 .OR. cospgridIN%lon .gt. 360)) then + nError=nError+1 + errorMessage(nError) = 'ERROR: COSP input variable: cospIN%lon contains values out of range' + Lrttov_column = .false. + if (allocated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if + endif if (any(cospgridIN%tca .lt. 0 .OR. cospgridIN%tca .gt. 1)) then ! tca on [0,1] nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospIN%tca contains values out of range' @@ -3402,7 +3462,45 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF end do end if - endif + endif + if (any(cospgridIN%month .lt. 1 .OR. cospgridIN%month .gt. 12)) then ! month on [1,12] + nError=nError+1 + errorMessage(nError) = 'ERROR: COSP input variable: cospIN%month contains values out of range' + Lrttov_column = .false. + if (allocated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if + endif + if (any(cospgridIN%time_frac .lt. 0 .OR. cospgridIN%time_frac .gt. 1)) then ! time_frac on [0,1] + nError=nError+1 + errorMessage(nError) = 'ERROR: COSP input variable: cospIN%time_frac contains values out of range' + Lrttov_column = .false. + if (allocated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if + endif endif ! COSP_INPUTS @@ -4195,10 +4293,9 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, size(cospgridIN%v_sfc) .ne. cospIN%Npoints .OR. & size(cospgridIN%skt) .ne. cospIN%Npoints .OR. & size(cospgridIN%phalf,1) .ne. cospIN%Npoints .OR. & - size(cospgridIN%seaice) .ne. cospIN%Npoints .OR. & size(cospgridIN%cloudIce,1) .ne. cospIN%Npoints .OR. & size(cospgridIN%cloudLiq,1) .ne. cospIN%Npoints .OR. & - size(cospgridIN%land) .ne. cospIN%Npoints .OR. & + size(cospgridIN%rttov_sfcmask) .ne. cospIN%Npoints .OR. & size(cospgridIN%lon) .ne. cospIN%Npoints .OR. & size(cospgridIN%lat) .ne. cospIN%Npoints) then Lrttov_column = .false. diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index b521768933..63cf91901c 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -29,6 +29,7 @@ ! History ! May 2015 - D. Swales - Original version ! Apr 2015 - D. Swales - Modified for RTTOVv11.3 +! Aug 2023 - J. Shaw - Modified for RTTOV v13 ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MODULE MOD_COSP_RTTOV_INTERFACE USE COSP_KINDS, ONLY: wp diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 8084838885..a86501703a 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -9,7 +9,7 @@ ! conditions and the following disclaimer. ! ! 2. Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other +! of conditions and the following disclaimer in the documentation and/or other ! materials provided with the distribution. ! ! 3. Neither the name of the copyright holder nor the names of its contributors may be @@ -128,7 +128,6 @@ module mod_cosp_rttov ! TYPE rttov_in ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! JKS - add additional COSP inputs here. type rttov_IN integer(kind=jpim),pointer :: & ! JKS trying this nPoints, & ! Number of profiles to simulate @@ -140,18 +139,18 @@ module mod_cosp_rttov ! surfem ! Surface emissivities for the channels ! refl, & ! Surface reflectances for the channels real(wp),dimension(:),pointer :: & - h_surf, & ! Surface height - u_surf, & ! U component of surface wind - v_surf, & ! V component of surface wind - t_skin, & ! Surface skin temperature - p_surf, & ! Surface pressure - t2m, & ! 2 m Temperature - q2m, & ! 2 m Specific humidity - lsmask, & ! land-sea mask - latitude, & ! Latitude (degrees) - longitude, & ! Longitude (degrees) - seaice, & ! Sea-ice? - time_frac ! Fractional UTC time [0-1] + h_surf, & ! Surface height + u_surf, & ! U component of surface wind + v_surf, & ! V component of surface wind + t_skin, & ! Surface skin temperature + p_surf, & ! Surface pressure + t2m => null(), & ! 2 m Temperature + q2m => null(), & ! 2 m Specific humidity + sfcmask, & ! sea-land-ice mask (0=sea, 1=land, 2=seaice) + latitude, & ! Latitude (degrees) + longitude, & ! Longitude (degrees) + time_frac, & ! Fractional UTC time [0-1] + sza => null() ! Solar zenith angle (deg) real(wp),dimension(:,:),pointer :: & p, & ! Pressure @ model levels ph, & ! Pressure @ model half levels @@ -650,21 +649,34 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & profiles(j)%longitude = rttovIN%longitude(i) profiles(j)%elevation = rttovIN%h_surf(i) * 1e-3 ! Convert m to km - ! Solar angles. JKS - get this from COSP/CESM? Doesn't seem to be passed in. - profiles(j)%sunzenangle = 0. ! hard-coded in rttov9 int - profiles(j)%sunazangle = 0. ! hard-coded in rttov9 int + ! Solar angles. + if (associated(rttovIN%sza)) then + profiles(j)%sunzenangle = rttovIN%sza(i) ! SZA in degrees + else + print*,'No solar zenith angle passed. Setting to zero.' + profiles(j)%sunzenangle = 0. + end if + profiles(j)%sunazangle = 0. ! hard-coded in like rttov9 - ! surface type - ! land-sea mask (lsmask) indicates proportion of land in grid - if (rttovIN%lsmask(i) < 0.5) then - profiles(j)%skin%surftype = surftype_sea + ! surface type. sfcmask is 0 for ocean, 1 for land, and 2 for sea ice + if (rttovIN%sfcmask(i) .lt. 0.5) then + profiles(j)%skin%surftype = surftype_land + else if (rttovIN%sfcmask(i) .lt. 1.5) then + profiles(j)%skin%surftype = surftype_sea else - profiles(j)%skin%surftype = surftype_land - endif + profiles(j)%skin%surftype = surftype_seaice + end if + + ! land-sea mask (lsmask) indicates proportion of land in grid (not in CESM implementation! just a binary mask there) +! if (rttovIN%lsmask(i) < 0.5) then +! profiles(j)%skin%surftype = surftype_sea +! else +! profiles(j)%skin%surftype = surftype_land +! endif ! sea-ice fraction - if (rttovIN%seaice(i) >= 0.5) then - profiles(j)%skin%surftype = surftype_seaice - endif +! if (rttovIN%icefrac(i) >= 0.5) then +! profiles(j)%skin%surftype = surftype_seaice +! endif ! dar: hard-coded to 1 (=ocean water) in rttov 9 int profiles(j)%skin%watertype = 1 @@ -673,6 +685,15 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & end if end do +! if (verbose) then +! print*,'profiles(1)%p(:): ',profiles(1)%p(:) +! print*,'profiles(1)%t(:): ',profiles(1)%t(:) +! print*,'profiles(1)%q(:): ',profiles(1)%q(:) +! print*,'profiles(1)%co2(:): ',profiles(1)%co2(:) +! print*,'profiles(1)%skin%t: ',profiles(1)%skin%t +! print*,'profiles(1)%s2m%t: ',profiles(1)%s2m%t +! end if + ! JKS - nothing to check here, this will never trigger. call rttov_error('error in profile initialization' , lalloc = .false.) From 57ee3ad35622ce4545e1793cce1adcf508598c66 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Thu, 7 Sep 2023 17:03:28 -0600 Subject: [PATCH 088/159] Integrate effective radius values for cloud ice and cloud water into RTTOV profiles input. --- driver/src/cosp2_test.F90 | 42 ++++++++++++++++++++++++-- src/cosp.F90 | 8 +++-- src/simulator/rttov/cosp_rttovSTUB.F90 | 26 ++++++++-------- src/simulator/rttov/cosp_rttov_v13.F90 | 9 ++++-- 4 files changed, 66 insertions(+), 19 deletions(-) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 321fb61121..56d7661e2f 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -541,11 +541,46 @@ program cosp2_test cospstateIN%o3 = mr_ozone(start_idx:end_idx,Nlevels:1:-1) cospstateIN%tca = tca(start_idx:end_idx,Nlevels:1:-1) - ! Combine large-scale and convective cloud mixing ratios for RTTOV + ! Combine large-scale and convective cloud mixing ratios for RTTOV [kg/kg] cospstateIN%cloudIce = mr_lsice(start_idx:end_idx,Nlevels:1:-1) + mr_ccice(start_idx:end_idx,Nlevels:1:-1) cospstateIN%cloudLiq = mr_lsliq(start_idx:end_idx,Nlevels:1:-1) + mr_ccliq(start_idx:end_idx,Nlevels:1:-1) + + ! Combine large-scale and convective cloud effective radii into effective diameters for RTTOV + ! Reff(Npoints,Nlevels,N_HYDRO) + ! The weighted Reff is given by: Reff_net = (M_1 + M_2) / (M_1/Reff_1 + M_2/Reff_2) + cospstateIN%DeffLiq(:,:) = 0._wp ! Initialize for zero everywhere. + where ((mr_lsliq(:,Nlevels:1:-1) .gt. 0._wp) .and. (mr_ccliq(:,Nlevels:1:-1) .gt. 0._wp)) + cospstateIN%DeffLiq(:,:) = 2._wp * 1.0e6 * (mr_lsliq(start_idx:end_idx,Nlevels:1:-1) + mr_ccliq(start_idx:end_idx,Nlevels:1:-1)) / (mr_lsliq(start_idx:end_idx,Nlevels:1:-1) / Reff(start_idx:end_idx,Nlevels:1:-1,I_LSCLIQ) + mr_ccliq(start_idx:end_idx,Nlevels:1:-1) / Reff(start_idx:end_idx,Nlevels:1:-1,I_CVCLIQ)) + elsewhere (mr_lsliq(:,Nlevels:1:-1) .gt. 0._wp) + cospstateIN%DeffLiq(:,:) = 2._wp * 1.0e6 * Reff(start_idx:end_idx,Nlevels:1:-1,I_LSCLIQ) + elsewhere (mr_ccliq(:,Nlevels:1:-1) .gt. 0._wp) + cospstateIN%DeffLiq(:,:) = 2._wp * 1.0e6 * Reff(start_idx:end_idx,Nlevels:1:-1,I_CVCLIQ) + end where + + cospstateIN%DeffIce(:,:) = 0._wp ! Initialize for zero everywhere. + where ((mr_lsice(:,Nlevels:1:-1) .gt. 0._wp) .and. (mr_ccice(:,Nlevels:1:-1) .gt. 0._wp)) + cospstateIN%DeffIce(:,:) = 2._wp * 1.0e6 * (mr_lsice(start_idx:end_idx,Nlevels:1:-1) + mr_ccice(start_idx:end_idx,Nlevels:1:-1)) / (mr_lsice(start_idx:end_idx,Nlevels:1:-1) / Reff(start_idx:end_idx,Nlevels:1:-1,I_LSCICE) + mr_ccice(start_idx:end_idx,Nlevels:1:-1) / Reff(start_idx:end_idx,Nlevels:1:-1,I_CVCICE)) + elsewhere (mr_lsice(:,Nlevels:1:-1) .gt. 0._wp) + cospstateIN%DeffIce(:,:) = 2._wp * 1.0e6 * Reff(start_idx:end_idx,Nlevels:1:-1,I_LSCICE) + elsewhere (mr_ccice(:,Nlevels:1:-1) .gt. 0._wp) + cospstateIN%DeffIce(:,:) = 2._wp * 1.0e6 * Reff(start_idx:end_idx,Nlevels:1:-1,I_CVCICE) + end where - ! RTTOV doesn't consider precip flux, but I think it was used previously. +! print*,'Reff(9,Nlevels:1:-1,I_CVCLIQ): ',Reff(9,Nlevels:1:-1,I_CVCLIQ) +! print*,'Reff(9,Nlevels:1:-1,I_LSCLIQ): ',Reff(9,Nlevels:1:-1,I_LSCLIQ) +! print*,'mr_lsliq(9,Nlevels:1:-1): ',mr_lsliq(9,Nlevels:1:-1) +! print*,'mr_ccliq(9,Nlevels:1:-1): ',mr_ccliq(9,Nlevels:1:-1) + +! print*,'cospstateIN%DeffLiq(9,:): ',cospstateIN%DeffLiq(9,:) + +! print*,'Reff(2:4,Nlevels:1:-1,I_CVCICE): ',Reff(2:4,Nlevels:1:-1,I_CVCICE) +! print*,'Reff(2:4,Nlevels:1:-1,I_LSCICE): ',Reff(2:4,Nlevels:1:-1,I_LSCICE) +! print*,'mr_lsice(2:4,Nlevels:1:-1): ',mr_lsice(2:4,Nlevels:1:-1) +! print*,'mr_ccice(2:4,Nlevels:1:-1): ',mr_ccice(2:4,Nlevels:1:-1) + +! print*,'cospstateIN%DeffIce(2:4,:): ',cospstateIN%DeffIce(2:4,:) + + ! RTTOV doesn't consider precip flux for longwave, but it could be used when simulating MW instruments. ! Graupel goes in the snow category, arbitrarily cospstateIN%fl_rain = fl_lsrain(start_idx:end_idx,Nlevels:1:-1) + fl_ccrain(start_idx:end_idx,Nlevels:1:-1) cospstateIN%fl_snow = fl_lssnow(start_idx:end_idx,Nlevels:1:-1) + fl_ccsnow(start_idx:end_idx,Nlevels:1:-1) + & @@ -1101,6 +1136,7 @@ subroutine construct_cospstateIN(npoints,nlevels,y) y%co2(npoints,nlevels), & ! y%emis_sfc(npoints,nchan),y%refl_sfc(npoints,nchan), & y%cloudIce(nPoints,nLevels),y%cloudLiq(nPoints,nLevels),y%surfelev(nPoints),& + y%DeffLiq(nPoints,nLevels),y%DeffIce(nPoints,nLevels), & y%fl_snow(nPoints,nLevels),y%fl_rain(nPoints,nLevels), & y%tca(nPoints,nLevels),y%hgt_matrix_half(nPoints,nlevels), & y%month(nPoints),y%time_frac(nPoints),y%sza(nPoints)) @@ -1543,6 +1579,8 @@ subroutine destroy_cospstateIN(y) if (allocated(y%refl_sfc)) deallocate(y%refl_sfc) if (allocated(y%cloudIce)) deallocate(y%cloudIce) if (allocated(y%cloudLiq)) deallocate(y%cloudLiq) + if (allocated(y%DeffLiq)) deallocate(y%DeffLiq) + if (allocated(y%DeffIce)) deallocate(y%DeffIce) if (allocated(y%fl_rain)) deallocate(y%fl_rain) if (allocated(y%fl_snow)) deallocate(y%fl_snow) if (allocated(y%tca)) deallocate(y%tca) diff --git a/src/cosp.F90 b/src/cosp.F90 index c1c4a93603..f6bc421fee 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -126,6 +126,8 @@ MODULE MOD_COSP tca, & ! Total layer cloud fraction (0-1) cloudIce, & ! Cloud ice water mixing ratio (kg/kg) cloudLiq, & ! Cloud liquid water mixing ratio (kg/kg) + DeffLiq, & ! Cloud liquid effective diameter (um) + DeffIce, & ! Cloud ice effective diameter (um) emis_sfc, & ! Surface emissivity (point,channel) (1) refl_sfc, & ! Surface reflectance (point,channel) (1) fl_rain, & ! Precipitation (rain) flux (kg/m2/s) @@ -758,7 +760,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) rttovIN%co => cospgridIN%co ! rttovIN%surfem => cospgridIN%emis_sfc ! rttovIN%refl_sfc => cospgridIN%refl_sfc -! rttovIN%h_surf => cospgridIN%hgt_matrix_half(:,cospIN%Nlevels) rttovIN%h_surf => cospgridIN%surfelev rttovIN%u_surf => cospgridIN%u_sfc rttovIN%v_surf => cospgridIN%v_sfc @@ -777,7 +778,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) rttovIN%sfcmask => cospgridIN%rttov_sfcmask rttovIN%latitude => cospgridIN%lat rttovIN%longitude => cospgridIN%lon -! rttovIN%seaice => cospgridIN%seaice rttovIN%p => cospgridIN%pfull rttovIN%ph => cospgridIN%phalf rttovIN%t => cospgridIN%at @@ -788,8 +788,10 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) rttovIN%time_frac => cospgridIN%time_frac rttovIN%sza => cospgridIN%sza ! JKS make optional? Defeats the purpose of the "associated" check in cosp_rttov_v13. rttovIN%tca => cospgridIN%tca - rttovIN%cldIce => cospgridIN%cloudIce rttovIN%cldLiq => cospgridIN%cloudLiq + rttovIN%cldIce => cospgridIN%cloudIce + rttovIN%DeffLiq => cospgridIN%DeffLiq + rttovIN%DeffIce => cospgridIN%DeffIce rttovIN%fl_rain => cospgridIN%fl_rain ! JKS remove? rttovIN%fl_snow => cospgridIN%fl_snow ! JKS remove? endif diff --git a/src/simulator/rttov/cosp_rttovSTUB.F90 b/src/simulator/rttov/cosp_rttovSTUB.F90 index 0b1171fe1e..ce5559c759 100644 --- a/src/simulator/rttov/cosp_rttovSTUB.F90 +++ b/src/simulator/rttov/cosp_rttovSTUB.F90 @@ -63,18 +63,18 @@ MODULE MOD_COSP_RTTOV ! surfem ! Surface emissivities for the channels ! refl, & ! Surface reflectances for the channels real(wp),dimension(:),pointer :: & - h_surf, & ! Surface height - u_surf, & ! U component of surface wind - v_surf, & ! V component of surface wind - t_skin, & ! Surface skin temperature - p_surf, & ! Surface pressure - t2m, & ! 2 m Temperature - q2m, & ! 2 m Specific humidity - lsmask, & ! land-sea mask - latitude, & ! Latitude (degrees) - longitude, & ! Longitude (degrees) - seaice, & ! Sea-ice? - time_frac ! Fractional UTC time [0-1] + h_surf, & ! Surface height + u_surf, & ! U component of surface wind + v_surf, & ! V component of surface wind + t_skin, & ! Surface skin temperature + p_surf, & ! Surface pressure + t2m => null(), & ! 2 m Temperature + q2m => null(), & ! 2 m Specific humidity + sfcmask, & ! sea-land-ice mask (0=sea, 1=land, 2=seaice) + latitude, & ! Latitude (degrees) + longitude, & ! Longitude (degrees) + time_frac, & ! Fractional UTC time [0-1] + sza => null() ! Solar zenith angle (deg) real(wp),dimension(:,:),pointer :: & p, & ! Pressure @ model levels ph, & ! Pressure @ model half levels @@ -91,6 +91,8 @@ MODULE MOD_COSP_RTTOV tca, & ! Cloud fraction cldIce, & ! Cloud ice cldLiq, & ! Cloud liquid + DeffIce, & ! Cloud ice effective diameter (um) + DeffLiq, & ! Cloud liquid effective diameter (um) fl_rain, & ! Precipitation flux (startiform+convective rain) (kg/m2/s) fl_snow ! Precipitation flux (stratiform+convective snow) end type rttov_IN diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index a86501703a..3bfb1d43e2 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -167,6 +167,8 @@ module mod_cosp_rttov tca, & ! Cloud fraction cldIce, & ! Cloud ice cldLiq, & ! Cloud liquid + DeffLiq, & ! Cloud liquid effective diameter + DeffIce, & ! Cloud ice effective diameter fl_rain, & ! Precipitation flux (startiform+convective rain) (kg/m2/s) fl_snow ! Precipitation flux (stratiform+convective snow) end type rttov_IN @@ -706,8 +708,8 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & ! Set cloud mass mixing ratio units profiles(:)%mmr_cldaer = .true. ! kg/kg for cloud and aerosol (default) - profiles(:)%clw_scheme = 2 ! Deff scheme avoids cloud types - ! profiles%clwde_scheme = 1. ! Not implemented? + profiles(:)%clw_scheme = 2 ! Deff scheme avoids cloud types but requires an effective diameter value + ! profiles(:)%clwde_scheme = 1. ! Scheme for cloud liquid water cotent to effective diameter. User guide says do not change. profiles(:)%ice_scheme = 1 !1:Baum 2:Baran(2014) 3:Baran(2018) profiles(:)%icede_param = 2 ! 2:Wyser(recommended). Only used if ice effective diameter not input @@ -722,6 +724,9 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & profiles(j)%cloud(1,:) = rttovIN%cldLiq(i,:) ! Cloud water mixing ratio (all in the first type for Deff) profiles(j)%cloud(6,:) = rttovIN%cldIce(i,:) ! Cloud ice mixing ratio (1 type). See pg 74. + profiles(j)%clwde = rttovIN%DeffLiq(i,:) ! Cloud water effective diameter + profiles(j)%icede = rttovIN%DeffIce(i,:) ! Cloud ice effective diameter + ! Example UKMO input has effective radii for multiple cloud types, making identification of a single ! liquid droplet or ice crystal effective diameter difficult. ! I opt to let RTTOV decide on the effective radius values, but more complex implementation From 2c5fc695e67089eea2f3242b385fb23a0fd618d1 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Mon, 11 Sep 2023 15:35:16 -0600 Subject: [PATCH 089/159] Added greybody emissivity functionality and handled mismatches in global vs. small batch COSP offline inputs --- driver/src/cosp2_test.F90 | 70 ++++++++++++++++++---- src/cosp.F90 | 27 +++++---- src/simulator/cosp_rttov_interface_v13.F90 | 9 ++- src/simulator/rttov/cosp_rttov_v13.F90 | 23 ++++++- 4 files changed, 101 insertions(+), 28 deletions(-) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 56d7661e2f..df50854428 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -326,6 +326,11 @@ program cosp2_test frac_out(Npoints,Ncolumns,Nlevels),surfelev(Npoints),month(Npoints), & hour(Npoints),minute(Npoints)) + ! Set some fields to masked values if the COSP offline driver outputs are inconsistent + month(:) = R_UNDEF + hour(:) = R_UNDEF + minute(:) = R_UNDEF + fileIN = trim(dinput)//trim(finput) call nc_read_input_file(fileIN,Npoints,Nlevels,N_HYDRO,lon,lat,p,ph,zlev,zlev_half, & T,sh,rh,tca,cca,mr_lsliq,mr_lsice,mr_ccliq,mr_ccice,fl_lsrain, & @@ -474,13 +479,17 @@ program cosp2_test !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Construct COSP input types !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + print*,'1.' if (iChunk .eq. 1) then +! call construct_cospIN(Nptsperit,nColumns,nLevels,rttov_Ninstruments,cospIN,emis_grey=0.2_wp) call construct_cospIN(Nptsperit,nColumns,nLevels,rttov_Ninstruments,cospIN) + print*,'1.a' call construct_cospstateIN(Nptsperit,nLevels,cospstateIN) endif if (iChunk .eq. nChunks) then call destroy_cospIN(cospIN) call destroy_cospstateIN(cospstateIN) +! call construct_cospIN(Nptsperit,nColumns,nLevels,rttov_Ninstruments,cospIN,emis_grey=0.2_wp) call construct_cospIN(Nptsperit,nColumns,nLevels,rttov_Ninstruments,cospIN) call construct_cospstateIN(Nptsperit,nLevels,cospstateIN) endif @@ -492,6 +501,7 @@ program cosp2_test ! surface-2-TOA, whereas COSP expects all fields to be ordered from TOA-2-SFC. So the ! vertical fields are flipped prior to storing to COSP input type. !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + print*,'2.' cospIN%emsfc_lw = emsfc_lw cospIN%rcfg_cloudsat = rcfg_cloudsat @@ -515,8 +525,8 @@ program cosp2_test ! Assign RTTOV values ! Keeping these structures since refl and emis could come from model input - cospstateIN%emis_sfc(:,:) = 0._wp - cospstateIN%refl_sfc(:,:) = 0._wp + cospstateIN%emis_in(:,:) = 1._wp + cospstateIN%refl_in(:,:) = 1._wp ! Well-mixed gases are not provided in COSP offline input, so hardcoding them in. ! Units are kg/kg over moist air. @@ -527,6 +537,25 @@ program cosp2_test cospstateIN%co(:,:) = 2.098e-07 cospstateIN%so2(:,:) = 2.0e-11 + if (any(month(start_idx:end_idx) .lt. 0._wp)) then + print*,'Some of values of the input month field are masked. Replacing with 1 so RTTOV will run.' + where (month(start_idx:end_idx) .lt. 0._wp) + month(start_idx:end_idx) = 1 + end where + end if + if (any(hour(start_idx:end_idx) .lt. 0._wp)) then + print*,'Some of values of the input hour field are masked. Replacing with 1 so RTTOV will run.' + where (hour(start_idx:end_idx) .lt. 0._wp) + hour(start_idx:end_idx) = 1._wp + end where + end if + if (any(minute(start_idx:end_idx) .lt. 0._wp)) then + print*,'Some of values of the input minute field are masked. Replacing with 1 so RTTOV will run.' + where (minute(start_idx:end_idx) .lt. 0._wp) + minute(start_idx:end_idx) = 1._wp + end where + end if + ! Time information cospstateIN%month = month(start_idx:end_idx) cospstateIN%time_frac = (60*hour(start_idx:end_idx) + minute(start_idx:end_idx)) / (24*60) ! Time (UTC) expressed as a fraction on [0,1] @@ -549,20 +578,20 @@ program cosp2_test ! Reff(Npoints,Nlevels,N_HYDRO) ! The weighted Reff is given by: Reff_net = (M_1 + M_2) / (M_1/Reff_1 + M_2/Reff_2) cospstateIN%DeffLiq(:,:) = 0._wp ! Initialize for zero everywhere. - where ((mr_lsliq(:,Nlevels:1:-1) .gt. 0._wp) .and. (mr_ccliq(:,Nlevels:1:-1) .gt. 0._wp)) + where ((mr_lsliq(start_idx:end_idx,Nlevels:1:-1) .gt. 0._wp) .and. (mr_ccliq(start_idx:end_idx,Nlevels:1:-1) .gt. 0._wp)) cospstateIN%DeffLiq(:,:) = 2._wp * 1.0e6 * (mr_lsliq(start_idx:end_idx,Nlevels:1:-1) + mr_ccliq(start_idx:end_idx,Nlevels:1:-1)) / (mr_lsliq(start_idx:end_idx,Nlevels:1:-1) / Reff(start_idx:end_idx,Nlevels:1:-1,I_LSCLIQ) + mr_ccliq(start_idx:end_idx,Nlevels:1:-1) / Reff(start_idx:end_idx,Nlevels:1:-1,I_CVCLIQ)) - elsewhere (mr_lsliq(:,Nlevels:1:-1) .gt. 0._wp) + elsewhere (mr_lsliq(start_idx:end_idx,Nlevels:1:-1) .gt. 0._wp) cospstateIN%DeffLiq(:,:) = 2._wp * 1.0e6 * Reff(start_idx:end_idx,Nlevels:1:-1,I_LSCLIQ) - elsewhere (mr_ccliq(:,Nlevels:1:-1) .gt. 0._wp) + elsewhere (mr_ccliq(start_idx:end_idx,Nlevels:1:-1) .gt. 0._wp) cospstateIN%DeffLiq(:,:) = 2._wp * 1.0e6 * Reff(start_idx:end_idx,Nlevels:1:-1,I_CVCLIQ) end where cospstateIN%DeffIce(:,:) = 0._wp ! Initialize for zero everywhere. - where ((mr_lsice(:,Nlevels:1:-1) .gt. 0._wp) .and. (mr_ccice(:,Nlevels:1:-1) .gt. 0._wp)) + where ((mr_lsice(start_idx:end_idx,Nlevels:1:-1) .gt. 0._wp) .and. (mr_ccice(start_idx:end_idx,Nlevels:1:-1) .gt. 0._wp)) cospstateIN%DeffIce(:,:) = 2._wp * 1.0e6 * (mr_lsice(start_idx:end_idx,Nlevels:1:-1) + mr_ccice(start_idx:end_idx,Nlevels:1:-1)) / (mr_lsice(start_idx:end_idx,Nlevels:1:-1) / Reff(start_idx:end_idx,Nlevels:1:-1,I_LSCICE) + mr_ccice(start_idx:end_idx,Nlevels:1:-1) / Reff(start_idx:end_idx,Nlevels:1:-1,I_CVCICE)) - elsewhere (mr_lsice(:,Nlevels:1:-1) .gt. 0._wp) + elsewhere (mr_lsice(start_idx:end_idx,Nlevels:1:-1) .gt. 0._wp) cospstateIN%DeffIce(:,:) = 2._wp * 1.0e6 * Reff(start_idx:end_idx,Nlevels:1:-1,I_LSCICE) - elsewhere (mr_ccice(:,Nlevels:1:-1) .gt. 0._wp) + elsewhere (mr_ccice(start_idx:end_idx,Nlevels:1:-1) .gt. 0._wp) cospstateIN%DeffIce(:,:) = 2._wp * 1.0e6 * Reff(start_idx:end_idx,Nlevels:1:-1,I_CVCICE) end where @@ -609,6 +638,7 @@ program cosp2_test !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Call COSP !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + print*,'3.' cosp_status = COSP_SIMULATOR(cospIN, cospstateIN, cospOUT,start_idx,end_idx,rttov_verbose) do ij=1,size(cosp_status,1) if (cosp_status(ij) .ne. '') print*,trim(cosp_status(ij)) @@ -1049,7 +1079,7 @@ end subroutine subsample_and_optics !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE construct_cospIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine construct_cospIN(npoints,ncolumns,nlevels,ninst_rttov,y) + subroutine construct_cospIN(npoints,ncolumns,nlevels,ninst_rttov,y,emis_grey) ! Inputs integer,intent(in) :: & npoints, & ! Number of horizontal gridpoints @@ -1058,7 +1088,10 @@ subroutine construct_cospIN(npoints,ncolumns,nlevels,ninst_rttov,y) ninst_rttov ! Number of RTTOV instruments ! Outputs type(cosp_optical_inputs),intent(out) :: y - + + real(kind=wp),intent(in),target, optional :: & + emis_grey + ! Dimensions y%Npoints = Npoints y%Ncolumns = Ncolumns @@ -1068,6 +1101,8 @@ subroutine construct_cospIN(npoints,ncolumns,nlevels,ninst_rttov,y) y%Nrefl = PARASOL_NREFL allocate(y%frac_out(npoints, ncolumns,nlevels)) + if (present(emis_grey)) y%emis_grey => emis_grey + if (Lmodis .or. Lmisr .or. Lisccp) then allocate(y%tau_067(npoints, ncolumns,nlevels),& y%emiss_11(npoints, ncolumns,nlevels)) @@ -1125,6 +1160,11 @@ subroutine construct_cospstateIN(npoints,nlevels,y) integer,intent(in) :: & npoints, & ! Number of horizontal gridpoints nlevels ! Number of vertical levels +! N_rttov_instruments + +! type(rttov_cfg), dimension(N_rttov_instruments),intent(in) :: & +! rttov_configs + ! Outputs type(cosp_column_inputs),intent(out) :: y @@ -1134,12 +1174,16 @@ subroutine construct_cospstateIN(npoints,nlevels,y) y%v_sfc(npoints),y%lat(npoints),y%lon(nPoints),y%rttov_sfcmask(nPoints), & y%co(npoints,nlevels),y%n2o(npoints,nlevels),y%ch4(npoints,nlevels), & y%co2(npoints,nlevels), & -! y%emis_sfc(npoints,nchan),y%refl_sfc(npoints,nchan), & y%cloudIce(nPoints,nLevels),y%cloudLiq(nPoints,nLevels),y%surfelev(nPoints),& y%DeffLiq(nPoints,nLevels),y%DeffIce(nPoints,nLevels), & y%fl_snow(nPoints,nLevels),y%fl_rain(nPoints,nLevels), & y%tca(nPoints,nLevels),y%hgt_matrix_half(nPoints,nlevels), & y%month(nPoints),y%time_frac(nPoints),y%sza(nPoints)) + + ! JKS - I should make this optional to save space. +! do i=1,N_rttov_instruments +! allocate(y%emis_in(npoints,rttov_configs(i) % nchan_out),y%refl_in(npoints,rttov_configs(i) % nchan_out)) +! end do end subroutine construct_cospstateIN @@ -1575,8 +1619,8 @@ subroutine destroy_cospstateIN(y) if (allocated(y%v_sfc)) deallocate(y%v_sfc) if (allocated(y%lat)) deallocate(y%lat) if (allocated(y%lon)) deallocate(y%lon) - if (allocated(y%emis_sfc)) deallocate(y%emis_sfc) - if (allocated(y%refl_sfc)) deallocate(y%refl_sfc) + if (allocated(y%emis_in)) deallocate(y%emis_in) + if (allocated(y%refl_in)) deallocate(y%refl_in) if (allocated(y%cloudIce)) deallocate(y%cloudIce) if (allocated(y%cloudLiq)) deallocate(y%cloudLiq) if (allocated(y%DeffLiq)) deallocate(y%DeffLiq) diff --git a/src/cosp.F90 b/src/cosp.F90 index f6bc421fee..4483403a80 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -128,8 +128,8 @@ MODULE MOD_COSP cloudLiq, & ! Cloud liquid water mixing ratio (kg/kg) DeffLiq, & ! Cloud liquid effective diameter (um) DeffIce, & ! Cloud ice effective diameter (um) - emis_sfc, & ! Surface emissivity (point,channel) (1) - refl_sfc, & ! Surface reflectance (point,channel) (1) + emis_in, & ! Surface emissivity (point,channel) (1) + refl_in, & ! Surface reflectance (point,channel) (1) fl_rain, & ! Precipitation (rain) flux (kg/m2/s) fl_snow ! Precipitation (snow) flux (kg/m2/s) end type cosp_column_inputs @@ -145,6 +145,8 @@ MODULE MOD_COSP Npart, & ! Number of cloud meteors for LIDAR simulators. Nrefl, & ! Number of reflectances for PARASOL simulator Ninst_rttov ! Number of RTTOV instruments + real(wp),pointer :: & + emis_grey => null() ! Greybody (spectrally flat) emissivity value for RTTOV real(wp) :: & emsfc_lw ! Surface emissivity @ 11micron real(wp),allocatable,dimension(:,:,:) :: & @@ -758,13 +760,14 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) rttovIN%ch4 => cospgridIN%ch4 rttovIN%n2o => cospgridIN%n2o rttovIN%co => cospgridIN%co -! rttovIN%surfem => cospgridIN%emis_sfc -! rttovIN%refl_sfc => cospgridIN%refl_sfc rttovIN%h_surf => cospgridIN%surfelev rttovIN%u_surf => cospgridIN%u_sfc rttovIN%v_surf => cospgridIN%v_sfc rttovIN%t_skin => cospgridIN%skt rttovIN%p_surf => cospgridIN%phalf(:,cospIN%Nlevels+1) + if (associated(cospIN%emis_grey)) rttovIN%emis_grey => cospIN%emis_grey +! rttovIN%surfem => cospgridIN%emis_in +! rttovIN%refl_in => cospgridIN%refl_in if (allocated(cospgridIN%q2m)) then rttovIN%q2m => cospgridIN%q2m(:) else @@ -2595,14 +2598,14 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, ! RTTOV if (Lrttov_column) then alloc_status = .true. -! if (.not. allocated(cospgridIN%emis_sfc)) then +! if (.not. allocated(cospgridIN%emis_in)) then ! nError=nError+1 -! errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%emis_sfc has not been allocated' +! errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%emis_in has not been allocated' ! alloc_status = .false. ! endif -! if (.not. allocated(cospgridIN%refl_sfc)) then +! if (.not. allocated(cospgridIN%refl_in)) then ! nError=nError+1 -! errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%refl_sfc has not been allocated' +! errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%refl_in has not been allocated' ! alloc_status = .false. ! endif if (.not. allocated(cospgridIN%hgt_matrix_half)) then @@ -3313,9 +3316,9 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, end do end if endif -! if (any(cospgridIN%emis_sfc .lt. 0. .OR. cospgridIN%emis_sfc .gt. 1)) then +! if (any(cospgridIN%emis_in .lt. 0. .OR. cospgridIN%emis_in .gt. 1)) then ! nError=nError+1 -! errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%emis_sfc contains values out of range' +! errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%emis_in contains values out of range' ! Lrttov_column = .false. ! if (allocated(cospOUT%rttov_outputs)) then ! do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument @@ -3332,9 +3335,9 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, ! end do ! end if ! endif -! if (any(cospgridIN%refl_sfc .lt. 0. .OR. cospgridIN%refl_sfc .gt. 1)) then +! if (any(cospgridIN%refl_in .lt. 0. .OR. cospgridIN%refl_in .gt. 1)) then ! nError=nError+1 -! errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%refl_sfc contains values out of range' +! errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%refl_in contains values out of range' ! Lrttov_column = .false. ! if (allocated(cospOUT%rttov_outputs)) then ! do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 63cf91901c..3b7ddb3187 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -723,9 +723,16 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, verbose) call cpu_time(driver_time(3)) + if (verbose) print*,'Beginning "cosp_rttov_setup_emissivity_reflectance".' - call cosp_rttov_setup_emissivity_reflectance() ! Config agnostic after allocate step. + if (associated(rttovIN % emis_grey)) then + call cosp_rttov_setup_emissivity_reflectance(emis_grey = rttovIN % emis_grey) ! Config agnostic after allocate step. + else + call cosp_rttov_setup_emissivity_reflectance() ! Config agnostic after allocate step. + end if call cpu_time(driver_time(4)) + + if (verbose) print*,'Beginning "cosp_rttov_call_direct".' call cosp_rttov_call_direct(rttovConfig % rttov_direct_nthreads, & rttovConfig % opts, & rttovConfig % coefs) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 3bfb1d43e2..6472b80dbc 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -133,6 +133,8 @@ module mod_cosp_rttov nPoints, & ! Number of profiles to simulate nLevels, & ! Number of levels nSubCols ! Number of subcolumns + real(kind=wp),pointer :: & + emis_grey => null() integer(kind=jpim),dimension(:),pointer :: & month ! real(wp),dimension(:),pointer :: & @@ -776,13 +778,30 @@ end subroutine cosp_rttov_construct_profiles ! ------------------------------------------------------ ! From RTTOV example files. Will need to be expanded on to pass in values. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_rttov_setup_emissivity_reflectance() - +! subroutine cosp_rttov_setup_emissivity_reflectance(emis_in,refl_in) + +! real(kind=jprb),intent(in),dimension(Npoints,Nchan),optional :: & +! emis_in, & ! User input emissivities +! refl_in ! User input reflectivities + +! real(kind=jprb),intent(in),optional :: emis_in(SIZE(emissivity % emis_in)) +! real(kind=jprb),intent(in),optional :: refl_in(SIZE(reflectance % refl_in)) + + ! Set emissivities/reflectivites here. +! if (present(emis_in)) emissivity(:) % emis_in = emis_in +! if (present(refl_in)) reflectance(:) % refl_in = refl_in + + subroutine cosp_rttov_setup_emissivity_reflectance(emis_grey) + + real(kind=wp),intent(in),pointer,optional :: emis_grey + ! In this example we have no values for input emissivities or reflectances ! so we initialise all inputs to zero call rttov_init_emis_refl(emissivity, reflectance) call rttov_error('error for emissivity/reflectance initialization' , lalloc = .true.) + if (present(emis_grey)) emissivity(:) % emis_in = emis_grey ! Use greybody emissivity. + ! Calculate emissivity within RTTOV where the input emissivity value is ! zero or less (all channels in this case) calcemis(:) = (emissivity(:) % emis_in <= 0._jprb) From 80c4e53fe74929d87b434d2572d72ede3a0df063 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Mon, 18 Sep 2023 13:47:45 -0600 Subject: [PATCH 090/159] Update and add CESM2 driver code. --- cospsimulator_intr.F90 | 4690 ++++++++++++++++++++++++ driver/src/cosp2_test.F90 | 6 +- src/cosp.F90 | 13 + src/simulator/rttov/cosp_rttovSTUB.F90 | 2 + 4 files changed, 4706 insertions(+), 5 deletions(-) create mode 100644 cospsimulator_intr.F90 diff --git a/cospsimulator_intr.F90 b/cospsimulator_intr.F90 new file mode 100644 index 0000000000..71819de237 --- /dev/null +++ b/cospsimulator_intr.F90 @@ -0,0 +1,4690 @@ +module cospsimulator_intr + ! ###################################################################################### + ! Purpose: CAM interface to + ! Name: CFMIP Observational Simulator Package Version 2 (COSP2) + ! What: Simulate ISCCP/CloudSat/CALIPSO/MISR/MODIS cloud products from + ! GCM inputs + ! Version: v2.1.4 (August 2019) + ! Authors: Dustin Swales (dustin.swales@noaa.gov) + ! + ! Modifications: + ! + ! ###################################################################################### + use shr_kind_mod, only: r8 => shr_kind_r8 + use spmd_utils, only: masterproc + use ppgrid, only: pcols, pver, pverp, begchunk, endchunk + use perf_mod, only: t_startf, t_stopf, t_adj_detailf + use cam_abortutils, only: endrun + use phys_control, only: cam_physpkg_is + use cam_logfile, only: iulog +#ifdef USE_COSP + use quickbeam, only: radar_cfg + use mod_quickbeam_optics, only: size_distribution + use mod_cosp, only: cosp_outputs,cosp_optical_inputs,cosp_column_inputs + use mod_cosp_config, only: pres_binCenters, pres_binEdges, tau_binCenters, & + tau_binEdges, cloudsat_binCenters, cloudsat_binEdges, calipso_binCenters, & + calipso_binEdges, misr_histHgtCenters, misr_histHgtEdges, PARASOL_SZA, & + R_UNDEF, PARASOL_NREFL, LIDAR_NCAT,SR_BINS, N_HYDRO, & + numMISRHgtBins, CLOUDSAT_DBZE_BINS, LIDAR_NTEMP, calipso_histBsct, & + numMODISTauBins, numMODISPresBins, numMODISReffIceBins, numMODISReffLiqBins, & + numISCCPTauBins, numISCCPPresBins, numMISRTauBins, reffICE_binEdges, & + reffICE_binCenters, reffLIQ_binEdges, reffLIQ_binCenters, LIDAR_NTYPE, & + nCloudsatPrecipClass, & + nsza_cosp => PARASOL_NREFL, & + nprs_cosp => npres, & + ntau_cosp => ntau, & + ntau_cosp_modis => ntau, & + nsr_cosp => SR_BINS, & + nhtmisr_cosp => numMISRHgtBins, & + nhydro => N_HYDRO, & + cloudsat_preclvl + use mod_cosp_stats, only: cosp_change_vertical_grid + use mod_cosp_rttov_interface, only: rttov_cfg ! JKS +#endif + implicit none + private + save + + ! Public functions/subroutines + public :: & + cospsimulator_intr_readnl, & + cospsimulator_intr_register,& + cospsimulator_intr_init, & + cospsimulator_intr_run + + ! ###################################################################################### + ! Public declarations + ! ###################################################################################### + ! Whether to do COSP calcs and I/O, default is false. If docosp is specified in + ! the atm_in namelist, this value is overwritten and cosp is run + logical, public :: docosp = .false. + + ! Frequency at which cosp is called, every cosp_nradsteps radiation timestep + integer, public :: cosp_nradsteps = 1! CAM namelist variable default, not in COSP namelist + +#ifdef USE_COSP + + ! ###################################################################################### + ! Local declarations + ! ###################################################################################### + integer, parameter :: & + nhtml_cosp = pver ! Mumber of model levels is pver + integer :: & + nscol_cosp, & ! Number of subcolumns, use namelist input Ncolumns to set. + nht_cosp ! Number of height for COSP radar and calipso simulator outputs. + ! *set to 40 if csat_vgrid=.true., else set to Nlr* + + ! ###################################################################################### + ! Bin-boundaries for mixed dimensions. Calculated in cospsetupvales OR in cosp_config.F90 + ! ###################################################################################### + real(r8), target :: prsmid_cosp(nprs_cosp) ! pressure midpoints of COSP ISCCP output + real(r8), target :: prslim_cosp(2,nprs_cosp) + real(r8), target :: taumid_cosp(ntau_cosp) ! optical depth midpoints of COSP ISCCP output + real(r8), target :: taulim_cosp(2,ntau_cosp) + real(r8), target :: srmid_cosp(nsr_cosp) ! sr midpoints of COSP lidar output + real(r8), target :: srlim_cosp(2,nsr_cosp) + real(r8), target :: sza_cosp(nsza_cosp) + real(r8), target :: dbzemid_cosp(CLOUDSAT_DBZE_BINS) ! dbze midpoints of COSP radar output + real(r8), target :: dbzelim_cosp(2,CLOUDSAT_DBZE_BINS) + real(r8), target :: htmisrmid_cosp(nhtmisr_cosp) ! htmisr midpoints of COSP misr simulator output + real(r8), target :: htmisrlim_cosp(2,nhtmisr_cosp) + real(r8), target :: taumid_cosp_modis(ntau_cosp_modis)! optical depth midpoints of COSP MODIS output + real(r8), target :: taulim_cosp_modis(2,ntau_cosp_modis) + real(r8), target :: reffICE_binEdges_cosp(2,numMODISReffIceBins) + real(r8), target :: reffLIQ_binEdges_cosp(2,numMODISReffLiqBins) + real(r8), target :: reffICE_binCenters_cosp(numMODISReffIceBins) + real(r8), target :: reffLIQ_binCenters_cosp(numMODISReffLiqBins) + + real(r8) :: htmlmid_cosp(nhtml_cosp) ! Model level height midpoints for output + integer :: prstau_cosp(nprs_cosp*ntau_cosp) ! ISCCP mixed output dimension index + integer :: prstau_cosp_modis(nprs_cosp*ntau_cosp_modis) ! MODIS mixed output dimension index + integer :: htmisrtau_cosp(nhtmisr_cosp*ntau_cosp) ! MISR mixed output dimension index + real(r8) :: prstau_prsmid_cosp(nprs_cosp*ntau_cosp) + real(r8) :: prstau_taumid_cosp(nprs_cosp*ntau_cosp) + real(r8) :: prstau_prsmid_cosp_modis(nprs_cosp*ntau_cosp_modis) + real(r8) :: prstau_taumid_cosp_modis(nprs_cosp*ntau_cosp_modis) + real(r8) :: htmisrtau_htmisrmid_cosp(nhtmisr_cosp*ntau_cosp) + real(r8) :: htmisrtau_taumid_cosp(nhtmisr_cosp*ntau_cosp) + real(r8),allocatable, public :: htdbze_dbzemid_cosp(:) ! (nht_cosp*CLOUDSAT_DBZE_BINS) + real(r8),allocatable, target :: htlim_cosp(:,:) ! height limits for COSP outputs (nht_cosp+1) + real(r8),allocatable, target :: htmid_cosp(:) ! height midpoints of COSP radar/lidar output (nht_cosp) + real(r8),allocatable :: htlim_cosp_1d(:) ! height limits for COSP outputs (nht_cosp+1) + real(r8),allocatable :: htdbze_htmid_cosp(:) ! (nht_cosp*CLOUDSAT_DBZE_BINS) + real(r8),allocatable :: htsr_htmid_cosp(:) ! (nht_cosp*nsr_cosp) + real(r8),allocatable :: htsr_srmid_cosp(:) ! (nht_cosp*nsr_cosp) + real(r8),allocatable :: htmlscol_htmlmid_cosp(:) ! (nhtml_cosp*nscol_cosp) + real(r8),allocatable :: htmlscol_scol_cosp(:) ! (nhtml_cosp*nscol_cosp) + integer, allocatable, target :: scol_cosp(:) ! sub-column number (nscol_cosp) + integer, allocatable :: htdbze_cosp(:) ! radar CFAD mixed output dimension index (nht_cosp*CLOUDSAT_DBZE_BINS) + integer, allocatable :: htsr_cosp(:) ! lidar CFAD mixed output dimension index (nht_cosp*nsr_cosp) + integer, allocatable :: htmlscol_cosp(:) ! html-subcolumn mixed output dimension index (nhtml_cosp*nscol_cosp) + + ! ###################################################################################### + ! Default namelists + ! The CAM and COSP namelists defaults are set below. Some of the COSP namelist + ! variables are part of the CAM namelist - they all begin with "cosp_" to keep their + ! names specific to COSP. I set their CAM namelist defaults here, not in namelist_defaults_cam.xml + ! Variables identified as namelist variables are defined in + ! ../models/atm/cam/bld/namelist_files/namelist_definition.xml + ! ###################################################################################### + ! CAM + logical :: cosp_amwg = .false. ! CAM namelist variable default, not in COSP namelist + logical :: cosp_lite = .false. ! CAM namelist variable default, not in COSP namelist + logical :: cosp_passive = .false. ! CAM namelist variable default, not in COSP namelist + logical :: cosp_active = .false. ! CAM namelist variable default, not in COSP namelist + logical :: cosp_isccp = .false. ! CAM namelist variable default, not in COSP namelist + logical :: cosp_lradar_sim = .false. ! CAM namelist variable default + logical :: cosp_llidar_sim = .false. ! CAM namelist variable default + logical :: cosp_lisccp_sim = .false. ! CAM namelist variable default + logical :: cosp_lmisr_sim = .false. ! CAM namelist variable default + logical :: cosp_lmodis_sim = .false. ! CAM namelist variable default + logical :: cosp_lrttov_sim = .false. ! CAM namelist variable default + logical :: cosp_histfile_aux = .false. ! CAM namelist variable default + logical :: cosp_lfrac_out = .false. ! CAM namelist variable default + logical :: cosp_runall = .false. ! flag to run all of the cosp simulator package + integer :: cosp_ncolumns = 50 ! CAM namelist variable default + integer :: cosp_histfile_num =1 ! CAM namelist variable default, not in COSP namelist + integer :: cosp_histfile_aux_num =-1 ! CAM namelist variable default, not in COSP namelist + + ! COSP + logical :: lradar_sim = .false. ! COSP namelist variable, can be changed from default by CAM namelist + logical :: llidar_sim = .false. ! + logical :: lparasol_sim = .false. ! + logical :: lgrLidar532 = .false. ! + logical :: latlid = .false. ! + logical :: lisccp_sim = .false. ! "" + logical :: lmisr_sim = .false. ! "" + logical :: lmodis_sim = .false. ! "" + logical :: lrttov_sim = .false. ! not running rttov, always set to .false. + logical :: lfrac_out = .false. ! COSP namelist variable, can be changed from default by CAM namelist + + ! ###################################################################################### + ! COSP parameters + ! ###################################################################################### + ! Note: Unless otherwise specified, these are parameters that cannot be set by the CAM namelist. + integer, parameter :: Npoints_it = 10000 ! Max # gridpoints to be processed in one iteration (10,000) + integer :: ncolumns = 50 ! Number of subcolumns in SCOPS (50), can be changed from default by CAM namelist + integer :: nlr = 40 ! Number of levels in statistical outputs + ! (only used if USE_VGRID=.true.) (40) + logical :: use_vgrid = .true. ! Use fixed vertical grid for outputs? + ! (if .true. then define # of levels with nlr) (.true.) + logical :: csat_vgrid = .true. ! CloudSat vertical grid? + ! (if .true. then the CloudSat standard grid is used. + ! If set, overides use_vgrid.) (.true.) + ! namelist variables for COSP input related to radar simulator + real(r8) :: radar_freq = 94.0_r8 ! CloudSat radar frequency (GHz) (94.0) + integer :: surface_radar = 0 ! surface=1, spaceborne=0 (0) + integer :: use_mie_tables = 0 ! use a precomputed lookup table? yes=1,no=0 (0) + integer :: use_gas_abs = 1 ! include gaseous absorption? yes=1,no=0 (1) + integer :: do_ray = 0 ! calculate/output Rayleigh refl=1, not=0 (0) + integer :: melt_lay = 0 ! melting layer model off=0, on=1 (0) + real(r8) :: k2 = -1 ! |K|^2, -1=use frequency dependent default (-1) + ! namelist variables for COSP input related to lidar simulator + integer, parameter :: Nprmts_max_hydro = 12 ! Max # params for hydrometeor size distributions (12) + integer, parameter :: Naero = 1 ! Number of aerosol species (Not used) (1) + integer, parameter :: Nprmts_max_aero = 1 ! Max # params for aerosol size distributions (not used) (1) + integer :: lidar_ice_type = 0 ! Ice particle shape in lidar calculations + ! (0=ice-spheres ; 1=ice-non-spherical) (0) + integer, parameter :: overlap = 3 ! overlap type: 1=max, 2=rand, 3=max/rand (3) + + !! namelist variables for COSP input related to ISCCP simulator + integer :: isccp_topheight = 1 ! 1 = adjust top height using both a computed infrared + ! brightness temperature and the visible + ! optical depth to adjust cloud top pressure. + ! Note that this calculation is most appropriate to compare + ! to ISCCP data during sunlit hours. + ! 2 = do not adjust top height, that is cloud top pressure + ! is the actual cloud top pressure in the model + ! 3 = adjust top height using only the computed infrared + ! brightness temperature. Note that this calculation is most + ! appropriate to compare to ISCCP IR only algortihm (i.e. + ! you can compare to nighttime ISCCP data with this option) (1) + integer :: isccp_topheight_direction = 2 ! direction for finding atmosphere pressure level with + ! interpolated temperature equal to the radiance + ! determined cloud-top temperature + ! 1 = find the *lowest* altitude (highest pressure) level + ! with interpolated temperature + ! equal to the radiance determined cloud-top temperature + ! 2 = find the *highest* altitude (lowest pressure) level + ! with interpolated temperature + ! equal to the radiance determined cloud-top temperature + ! ONLY APPLICABLE IF top_height EQUALS 1 or 3 + ! 1 = default setting in COSP v1.1, matches all versions of + ! ISCCP simulator with versions numbers 3.5.1 and lower + ! 2 = default setting in COSP v1.3. default since V4.0 of ISCCP simulator + + ! ###################################################################################### + ! Other variables + ! ###################################################################################### + logical,allocatable :: first_run_cosp(:) !.true. if run_cosp has been populated (allocatable->begchunk:endchunk) + logical,allocatable :: run_cosp(:,:) !.true. if cosp should be run by column and + ! chunk (allocatable->1:pcols,begchunk:endchunk) + ! pbuf indices + integer :: cld_idx, concld_idx, lsreffrain_idx, lsreffsnow_idx, cvreffliq_idx + integer :: cvreffice_idx, dpcldliq_idx, dpcldice_idx + integer :: shcldliq_idx, shcldice_idx, shcldliq1_idx, shcldice1_idx, dpflxprc_idx + integer :: dpflxsnw_idx, shflxprc_idx, shflxsnw_idx, lsflxprc_idx, lsflxsnw_idx + integer :: rei_idx, rel_idx +! integer :: ubot_idx, vbot_idx + + ! ###################################################################################### + ! Declarations specific to COSP2 + ! ###################################################################################### + type(radar_cfg) :: rcfg_cloudsat ! Radar configuration (Cloudsat) + type(radar_cfg), allocatable :: rcfg_cs(:) ! chunked version of rcfg_cloudsat + type(rttov_cfg), allocatable, target :: rttov_configs(:) ! Chunked RTTOV configuration + type(size_distribution) :: sd ! Size distribution used by radar simulator + type(size_distribution), allocatable :: sd_cs(:) ! chunked version of sd + character(len=64) :: cloudsat_micro_scheme = 'MMF_v3.5_single_moment' + + ! JKS hardcoding RTTOV features in initial functionality + character(len=256), dimension(50) :: rttov_instrument_namelists != 'None' ! Input of paths to RTTOV instrument namelists + + integer :: rttov_Ninstruments = 0 ! Default is zero + + integer,parameter :: & + I_LSCLIQ = 1, & ! Large-scale (stratiform) liquid + I_LSCICE = 2, & ! Large-scale (stratiform) ice + I_LSRAIN = 3, & ! Large-scale (stratiform) rain + I_LSSNOW = 4, & ! Large-scale (stratiform) snow + I_CVCLIQ = 5, & ! Convective liquid + I_CVCICE = 6, & ! Convective ice + I_CVRAIN = 7, & ! Convective rain + I_CVSNOW = 8, & ! Convective snow + I_LSGRPL = 9 ! Large-scale (stratiform) groupel + + ! Stratiform and convective clouds in frac_out (scops output). + integer, parameter :: & + I_LSC = 1, & ! Large-scale clouds + I_CVC = 2 ! Convective clouds + + ! Microphysical settings for the precipitation flux to mixing ratio conversion + real(r8),parameter,dimension(nhydro) :: & + ! LSL LSI LSR LSS CVL CVI CVR CVS LSG + N_ax = (/-1._r8, -1._r8, 8.e6_r8, 3.e6_r8, -1._r8, -1._r8, 8.e6_r8, 3.e6_r8, 4.e6_r8/),& + N_bx = (/-1._r8, -1._r8, 0.0_r8, 0.0_r8, -1._r8, -1._r8, 0.0_r8, 0.0_r8, 0.0_r8/),& + alpha_x = (/-1._r8, -1._r8, 0.0_r8, 0.0_r8, -1._r8, -1._r8, 0.0_r8, 0.0_r8, 0.0_r8/),& + c_x = (/-1._r8, -1._r8, 842.0_r8, 4.84_r8, -1._r8, -1._r8, 842.0_r8, 4.84_r8, 94.5_r8/),& + d_x = (/-1._r8, -1._r8, 0.8_r8, 0.25_r8, -1._r8, -1._r8, 0.8_r8, 0.25_r8, 0.5_r8/),& + g_x = (/-1._r8, -1._r8, 0.5_r8, 0.5_r8, -1._r8, -1._r8, 0.5_r8, 0.5_r8, 0.5_r8/),& + a_x = (/-1._r8, -1._r8, 524.0_r8, 52.36_r8, -1._r8, -1._r8, 524.0_r8, 52.36_r8, 209.44_r8/),& + b_x = (/-1._r8, -1._r8, 3.0_r8, 3.0_r8, -1._r8, -1._r8, 3.0_r8, 3.0_r8, 3.0_r8/),& + gamma_1 = (/-1._r8, -1._r8, 17.83725_r8, 8.284701_r8, -1._r8, -1._r8, 17.83725_r8, 8.284701_r8, 11.63230_r8/),& + gamma_2 = (/-1._r8, -1._r8, 6.0_r8, 6.0_r8, -1._r8, -1._r8, 6.0_r8, 6.0_r8, 6.0_r8/),& + gamma_3 = (/-1._r8, -1._r8, 2.0_r8, 2.0_r8, -1._r8, -1._r8, 2.0_r8, 2.0_r8, 2.0_r8/),& + gamma_4 = (/-1._r8, -1._r8, 6.0_r8, 6.0_r8, -1._r8, -1._r8, 6.0_r8, 6.0_r8, 6.0_r8/) + + type rttov_output_write + integer :: & + nchan_out +! integer,allocatable :: & +! channel_indices(:) + real(r8),allocatable :: & + bt_total(:,:), & + bt_clear(:,:), & + rad_total(:,:), & + rad_clear(:,:), & + rad_cloudy(:,:), & + refl_total(:,:), & + refl_clear(:,:), & + bt_total_pc(:,:), & + rad_total_pc(:,:) + end type rttov_output_write + +#endif + +CONTAINS + + ! ###################################################################################### + ! SUBROUTINE setcosp2values + ! ###################################################################################### +#ifdef USE_COSP + subroutine setcosp2values(Nlr_in,use_vgrid_in,csat_vgrid_in,Ncolumns_in,cosp_nradsteps_in) + use mod_cosp, only: cosp_init + use mod_cosp_config, only: vgrid_zl, vgrid_zu, vgrid_z + use mod_quickbeam_optics, only: hydro_class_init, quickbeam_optics_init + + use units, only: getunit, freeunit ! JKS testing + + + ! Inputs + integer, intent(in) :: Nlr_in ! Number of vertical levels for CALIPSO and Cloudsat products + integer, intent(in) :: Ncolumns_in ! Number of sub-columns + integer, intent(in) :: cosp_nradsteps_in ! How often to call COSP? + logical, intent(in) :: use_vgrid_in ! Logical switch to use interpolated, to Nlr_in, grid for CALIPSO and Cloudsat + logical, intent(in) :: csat_vgrid_in ! + + ! Local + logical :: ldouble=.false. + logical :: lsingle=.true. ! Default is to use single moment + integer :: i,k, unitn ! JKS testing + + character(len=256), allocatable :: rttov_instrument_namelists_final(:) +! type(character(len=256)), allocatable :: & +! rttov_instrument_namelists_final(:) ! Array of paths to RTTOV instrument namelists + + prsmid_cosp = pres_binCenters + prslim_cosp = pres_binEdges + taumid_cosp = tau_binCenters + taulim_cosp = tau_binEdges + srmid_cosp = calipso_binCenters + srlim_cosp = calipso_binEdges + sza_cosp = parasol_sza + dbzemid_cosp = cloudsat_binCenters + dbzelim_cosp = cloudsat_binEdges + htmisrmid_cosp = misr_histHgtCenters + htmisrlim_cosp = misr_histHgtEdges + taumid_cosp_modis = tau_binCenters + taulim_cosp_modis = tau_binEdges + reffICE_binCenters_cosp = reffICE_binCenters + reffICE_binEdges_cosp = reffICE_binEdges + reffLIQ_binCenters_cosp = reffLIQ_binCenters + reffLIQ_binEdges_cosp = reffLIQ_binEdges + + ! Initialize the distributional parameters for hydrometeors in radar simulator. In COSPv1.4, this was declared in + ! cosp_defs.f. + if (cloudsat_micro_scheme == 'MMF_v3.5_two_moment') then + ldouble = .true. + lsingle = .false. + endif + call hydro_class_init(lsingle,ldouble,sd) + call quickbeam_optics_init() + + ! DS2017: The setting up of the vertical grid for regridding the CALIPSO and Cloudsat products is + ! now donein cosp_init, but these fields are stored in cosp_config.F90. + ! Additionally all static fields used by the individual simulators are set up by calls + ! to _init functions in cosp_init. + ! DS2019: Add logicals, default=.false., for new Lidar simuldators (Earthcare (atlid) and ground-based + ! lidar at 532nm) + + ! JKS adding flexible namelist I/O + if (masterproc) then ! Write to the atm log. + write(iulog,*)'rttov_Ninstruments: ',rttov_Ninstruments + write(iulog,*)' ' + end if + + allocate(rttov_instrument_namelists_final(rttov_Ninstruments)) + rttov_instrument_namelists_final(:) = rttov_instrument_namelists(1:rttov_Ninstruments) + +! if (rttov_Ninstruments .eq. 1) then +! rttov_instrument_namelists_final(1) = rttov_instrument_namelists +! else +! rttov_instrument_namelists_final(1:rttov_Ninstruments) = rttov_instrument_namelists +! end if + + if (masterproc) then ! Write to the atm log. + write(iulog,*)'cosp_lrttov_sim: ',cosp_lrttov_sim + write(iulog,*)'Lrttov_sim: ',Lrttov_sim + write(iulog,*)'rttov_Ninstruments: ',rttov_Ninstruments + write(iulog,*)'rttov_instrument_namelists_final: ',rttov_instrument_namelists_final + write(iulog,*)' ' + end if + deallocate(rttov_instrument_namelists_final) + ! JKS end adding flexible namelist I/O + + ! JKS - hardcoding initial functionality. + rttov_Ninstruments = 1 !2 !3 + allocate(rttov_instrument_namelists_final(rttov_Ninstruments)) + rttov_instrument_namelists(:) = '' ! Initialize?? + rttov_instrument_namelists_final(1:1) = (/'instrument_nls/cosp2_rttov_inst1.txt'/) +! rttov_instrument_namelists_final(1:2) = (/'instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst3.txt'/) +! rttov_instrument_namelists_final(1:3) = (/'instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt'/) + + + ! rttov_Ninstruments and rttov_instrument_namelists should have been broadcast to all processors when namelists were read + +! allocate(rttov_instrument_namelists_final(rttov_Ninstruments)) +! rttov_instrument_namelists_final(:) = rttov_instrument_namelists(1:rttov_Ninstruments) + + if (masterproc) then ! Write to the atm log. + write(iulog,*)'cosp_lrttov_sim: ',cosp_lrttov_sim + write(iulog,*)'Lrttov_sim: ',Lrttov_sim + write(iulog,*)'rttov_Ninstruments: ',rttov_Ninstruments + write(iulog,*)'rttov_instrument_namelists_final: ',rttov_instrument_namelists_final + write(iulog,*)' ' + end if + + unitn = getunit() ! JKS handle many files. + + call COSP_INIT(Lisccp_sim, Lmodis_sim, Lmisr_sim, Lradar_sim, Llidar_sim, LgrLidar532, & + Latlid, Lparasol_sim, Lrttov_sim, radar_freq, k2, use_gas_abs, do_ray, & + isccp_topheight, isccp_topheight_direction, surface_radar, rcfg_cloudsat, & + use_vgrid_in, csat_vgrid_in, Nlr_in, pver, cloudsat_micro_scheme, & + rttov_Ninstruments, rttov_instrument_namelists_final, rttov_configs,unitn=unitn) ! JKS add functionality for multiple files + ! Could add mpi commands here to parallelize load coefficients if slow. + ! Yes, this should really only be run on the main processor, but I might need to bcast everything since the call is wrapped around all of COSP. + ! Could be done a few different ways. + call freeunit(unitn) ! JKS handle many files + deallocate(rttov_instrument_namelists_final) + + ! Set number of sub-columns, from namelist + nscol_cosp = Ncolumns_in + + if (use_vgrid_in) then !! using fixed vertical grid + if (csat_vgrid_in) then + nht_cosp = 40 + else + nht_cosp = Nlr_in + endif + endif + + ! Set COSP call frequency, from namelist. + cosp_nradsteps = cosp_nradsteps_in + + ! DJS2017: In COSP2, most of the bin boundaries, centers, and edges are declared in src/cosp_config.F90. + ! Above I just assign them accordingly in the USE statement. Other bin bounds needed by CAM + ! are calculated here. + ! Allocate + allocate(htlim_cosp(2,nht_cosp),htlim_cosp_1d(nht_cosp+1),htmid_cosp(nht_cosp),scol_cosp(nscol_cosp), & + htdbze_cosp(nht_cosp*CLOUDSAT_DBZE_BINS),htsr_cosp(nht_cosp*nsr_cosp),htmlscol_cosp(nhtml_cosp*nscol_cosp),& + htdbze_htmid_cosp(nht_cosp*CLOUDSAT_DBZE_BINS),htdbze_dbzemid_cosp(nht_cosp*CLOUDSAT_DBZE_BINS), & + htsr_htmid_cosp(nht_cosp*nsr_cosp),htsr_srmid_cosp(nht_cosp*nsr_cosp), & + htmlscol_htmlmid_cosp(nhtml_cosp*nscol_cosp),htmlscol_scol_cosp(nhtml_cosp*nscol_cosp)) + + ! DJS2017: Just pull from cosp_config + if (use_vgrid_in) then + htlim_cosp_1d(1) = vgrid_zu(1) + htlim_cosp_1d(2:nht_cosp+1) = vgrid_zl + endif + htmid_cosp = vgrid_z + htlim_cosp(1,:) = vgrid_zu + htlim_cosp(2,:) = vgrid_zl + + scol_cosp(:) = (/(k,k=1,nscol_cosp)/) + + ! Just using an index here, model height is a prognostic variable + htmlmid_cosp(:) = (/(k,k=1,nhtml_cosp)/) + + ! assign mixed dimensions an integer index for cam_history.F90 + do k=1,nprs_cosp*ntau_cosp + prstau_cosp(k) = k + end do + do k=1,nprs_cosp*ntau_cosp_modis + prstau_cosp_modis(k) = k + end do + do k=1,nht_cosp*CLOUDSAT_DBZE_BINS + htdbze_cosp(k) = k + end do + do k=1,nht_cosp*nsr_cosp + htsr_cosp(k) = k + end do + do k=1,nhtml_cosp*nscol_cosp + htmlscol_cosp(k) = k + end do + do k=1,nhtmisr_cosp*ntau_cosp + htmisrtau_cosp(k) = k + end do + + ! next, assign collapsed reference vectors for cam_history.F90 + ! convention for saving output = prs1,tau1 ... prs1,tau7 ; prs2,tau1 ... prs2,tau7 etc. + ! actual output is specified in cospsimulator1_intr.F90 + do k=1,nprs_cosp + prstau_taumid_cosp(ntau_cosp*(k-1)+1:k*ntau_cosp)=taumid_cosp(1:ntau_cosp) + prstau_prsmid_cosp(ntau_cosp*(k-1)+1:k*ntau_cosp)=prsmid_cosp(k) + prstau_taumid_cosp_modis(ntau_cosp_modis*(k-1)+1:k*ntau_cosp_modis)=taumid_cosp_modis(1:ntau_cosp_modis) + prstau_prsmid_cosp_modis(ntau_cosp_modis*(k-1)+1:k*ntau_cosp_modis)=prsmid_cosp(k) + enddo + + do k=1,nht_cosp + htdbze_dbzemid_cosp(CLOUDSAT_DBZE_BINS*(k-1)+1:k*CLOUDSAT_DBZE_BINS)=dbzemid_cosp(1:CLOUDSAT_DBZE_BINS) + htdbze_htmid_cosp(CLOUDSAT_DBZE_BINS*(k-1)+1:k*CLOUDSAT_DBZE_BINS)=htmid_cosp(k) + enddo + + do k=1,nht_cosp + htsr_srmid_cosp(nsr_cosp*(k-1)+1:k*nsr_cosp)=srmid_cosp(1:nsr_cosp) + htsr_htmid_cosp(nsr_cosp*(k-1)+1:k*nsr_cosp)=htmid_cosp(k) + enddo + + do k=1,nhtml_cosp + htmlscol_scol_cosp(nscol_cosp*(k-1)+1:k*nscol_cosp)=scol_cosp(1:nscol_cosp) + htmlscol_htmlmid_cosp(nscol_cosp*(k-1)+1:k*nscol_cosp)=htmlmid_cosp(k) + enddo + + do k=1,nhtmisr_cosp + htmisrtau_taumid_cosp(ntau_cosp*(k-1)+1:k*ntau_cosp)=taumid_cosp(1:ntau_cosp) + htmisrtau_htmisrmid_cosp(ntau_cosp*(k-1)+1:k*ntau_cosp)=htmisrmid_cosp(k) + enddo + + end subroutine setcosp2values +#endif + + ! ###################################################################################### + ! SUBROUTINE cospsimulator_intr_readnl + ! + ! PURPOSE: to read namelist variables and run setcospvalues subroutine.note: cldfrc_readnl + ! is a good template in cloud_fraction.F90. Make sure that this routine is reading in a + ! namelist. models/atm/cam/bld/build-namelist is the perl script to check. + ! ###################################################################################### + subroutine cospsimulator_intr_readnl(nlfile) + use namelist_utils, only: find_group_name + use units, only: getunit, freeunit +#ifdef SPMD + use mpishorthand, only: mpicom, mpilog, mpiint, mpichar +#endif + + character(len=*), intent(in) :: nlfile ! filepath for file containing namelist input (nlfile=atm_in) + + ! Local variables + integer :: unitn, ierr + character(len=*), parameter :: subname = 'cospsimulator_intr_readnl' + character(len=256), dimension(50) :: rttov_instrument_namelists ! Input of paths to RTTOV instrument namelists + + integer :: i ! JKS remove later +#ifdef USE_COSP + + ! Initialize + rttov_instrument_namelists(:) = '' + +!!! this list should include any variable that you might want to include in the namelist +!!! philosophy is to not include COSP output flags but just important COSP settings and cfmip controls. + namelist /cospsimulator_nl/ docosp, cosp_active, cosp_amwg, & + cosp_histfile_num, cosp_histfile_aux, cosp_histfile_aux_num, cosp_isccp, cosp_lfrac_out, & + cosp_lite, cosp_lradar_sim, cosp_llidar_sim, cosp_lisccp_sim, cosp_lmisr_sim, cosp_lmodis_sim, cosp_lrttov_sim, & + cosp_ncolumns, cosp_nradsteps, cosp_passive, cosp_runall, rttov_Ninstruments, rttov_instrument_namelists +! cosp_ncolumns, cosp_nradsteps, cosp_passive, cosp_runall, rttov_Ninstruments + + !! read in the namelist + if (masterproc) then + unitn = getunit() + open( unitn, file=trim(nlfile), status='old' ) !! presumably opens the namelist file "nlfile" + !! position the file to write to the cospsimulator portion of the cam_in namelist + call find_group_name(unitn, 'cospsimulator_nl', status=ierr) + if (ierr == 0) then + read(unitn, cospsimulator_nl, iostat=ierr) + if (ierr /= 0) then + call endrun(subname // ':: ERROR reading namelist') + end if + end if + close(unitn) + call freeunit(unitn) + end if + +#ifdef SPMD + ! Broadcast namelist variables + call mpibcast(docosp, 1, mpilog, 0, mpicom) + call mpibcast(cosp_amwg, 1, mpilog, 0, mpicom) + call mpibcast(cosp_lite, 1, mpilog, 0, mpicom) + call mpibcast(cosp_passive, 1, mpilog, 0, mpicom) + call mpibcast(cosp_active, 1, mpilog, 0, mpicom) + call mpibcast(cosp_isccp, 1, mpilog, 0, mpicom) + call mpibcast(cosp_runall, 1, mpilog, 0, mpicom) + call mpibcast(cosp_lfrac_out, 1, mpilog, 0, mpicom) + call mpibcast(cosp_lradar_sim, 1, mpilog, 0, mpicom) + call mpibcast(cosp_llidar_sim, 1, mpilog, 0, mpicom) + call mpibcast(cosp_lisccp_sim, 1, mpilog, 0, mpicom) + call mpibcast(cosp_lmisr_sim, 1, mpilog, 0, mpicom) + call mpibcast(cosp_lmodis_sim, 1, mpilog, 0, mpicom) + call mpibcast(cosp_lrttov_sim, 1, mpilog, 0, mpicom) + call mpibcast(cosp_ncolumns, 1, mpiint, 0, mpicom) + call mpibcast(cosp_histfile_num, 1, mpiint, 0, mpicom) + call mpibcast(cosp_histfile_aux_num,1, mpiint, 0, mpicom) + call mpibcast(cosp_histfile_aux, 1, mpilog, 0, mpicom) + call mpibcast(cosp_nradsteps, 1, mpiint, 0, mpicom) + call mpibcast(rttov_Ninstruments, 1, mpiint, 0, mpicom) ! JKS - Additional RTTOV variable. This should work. + + do i=1,rttov_Ninstruments ! JKS broadcast array of strings iteratively + print*,'In mpibcast loop. i = ',i + call mpibcast(rttov_instrument_namelists(i), len(rttov_instrument_namelists(i)), mpichar, 0, mpicom) ! JKS - Additional RTTOV variable, len could be 256 + end do +! call mpibcast(rttov_instrument_namelists, len(rttov_instrument_namelists(1))*rttov_Ninstruments, mpichar, 0, mpicom) ! JKS - Additional RTTOV variable, len could be 256 + + ! Example code from Dustin S. + ! call mpi_bcast(gas_namesLW(iChar),len(gas_namesLW(iChar)),MPI_CHARACTER,mpiroot, mpicomm, mpierr) + +#endif + +! It makes sense to broadcast the full string array since we can't allocate the shorter array until after the broadcasting step +! call mpibcast(rttov_Ninstruments, 1, mpiint, 0, mpicom) ! JKS - Additional RTTOV variable. This should work. +! call mpibcast(rttov_instrument_namelists, len(rttov_instrument_namelists(1))*rttov_Ninstruments, mpichar, 0, mpicom) ! JKS - Additional RTTOV variable, len could be 256 +! call mpibcast(rttov_instrument_namelists, len(rttov_instrument_namelists), mpichar, 0, mpicom) ! JKS - Additional RTTOV variable + ! First argument is the object to bcast, second is dimension, third is type. + + if (masterproc) then + if (docosp) then + write(iulog,*)'cosp_lrttov_sim: ', cosp_lrttov_sim + write(iulog,*)'lrttov_sim: ', lrttov_sim + write(iulog,*)'rttov_Ninstruments: ', cosp_ncolumns + write(iulog,*)'rttov_instrument_namelists: ', rttov_instrument_namelists + end if + end if + +! if (masterproc) then +! if (docosp) then +! write(iulog,*)'rttov_instrument_namelists(2): ', rttov_instrument_namelists +! end if +! end if + + if (cosp_lfrac_out) then + lfrac_out = .true. + end if + if (cosp_lradar_sim) then + lradar_sim = .true. + end if + if (cosp_llidar_sim) then + llidar_sim = .true. + lparasol_sim = .true. + end if + if (cosp_lisccp_sim) then + lisccp_sim = .true. + end if + if (cosp_lmisr_sim) then + lmisr_sim = .true. + end if + if (cosp_lmodis_sim) then + lmodis_sim = .true. + end if + if (cosp_lrttov_sim) then + lrttov_sim = .true. + end if + + if (masterproc) then + if (docosp) then + write(iulog,*)'lrttov_sim: ', lrttov_sim + end if + end if + + if (cosp_histfile_aux .and. cosp_histfile_aux_num == -1) then + cosp_histfile_aux_num = cosp_histfile_num + end if + + if (cosp_lite) then + llidar_sim = .true. + lparasol_sim = .true. + lisccp_sim = .true. + lmisr_sim = .true. + lmodis_sim = .true. + cosp_ncolumns = 10 + cosp_nradsteps = 3 + end if + + if (cosp_passive) then + lisccp_sim = .true. + lmisr_sim = .true. + lmodis_sim = .true. + cosp_ncolumns = 10 + cosp_nradsteps = 3 + end if + + if (cosp_active) then + lradar_sim = .true. + llidar_sim = .true. + lparasol_sim = .true. + cosp_ncolumns = 10 + cosp_nradsteps = 3 + end if + + if (cosp_isccp) then + lisccp_sim = .true. + cosp_ncolumns = 10 + cosp_nradsteps = 3 + end if + + if (cosp_runall) then + lradar_sim = .true. + llidar_sim = .true. + lparasol_sim = .true. + lisccp_sim = .true. + lmisr_sim = .true. + lmodis_sim = .true. + lfrac_out = .true. + lrttov_sim = .true. ! - JKS + end if + + !! if no simulators are turned on at all and docosp is, set cosp_amwg = .true. + if((docosp) .and. (.not.lradar_sim) .and. (.not.llidar_sim) .and. (.not.lisccp_sim) .and. & + (.not.lmisr_sim) .and. (.not.lmodis_sim) .and. (.not.lrttov_sim)) then + cosp_amwg = .true. + end if + if (cosp_amwg) then + lradar_sim = .true. + llidar_sim = .true. + lparasol_sim = .true. + lisccp_sim = .true. + lmisr_sim = .true. + lmodis_sim = .true. + cosp_ncolumns = 10 + cosp_nradsteps = 3 + end if + + !! reset COSP namelist variables based on input from cam namelist variables + if (cosp_ncolumns .ne. ncolumns) then + ncolumns = cosp_ncolumns + end if + + ! *NOTE* COSP is configured in CAM such that if a simulator is requested, all diagnostics + ! are output. So no need turn on/aff outputs if simulator is requested. + + ! Set vertical coordinate, subcolumn, and calculation frequency cosp options based on namelist inputs + call setcosp2values(nlr,use_vgrid,csat_vgrid,ncolumns,cosp_nradsteps) + + if (masterproc) then + if (docosp) then + write(iulog,*)'COSP configuration:' + write(iulog,*)' Number of COSP subcolumns = ', cosp_ncolumns + write(iulog,*)' Frequency at which cosp is called = ', cosp_nradsteps + write(iulog,*)' Enable radar simulator = ', lradar_sim + write(iulog,*)' Enable calipso simulator = ', llidar_sim + write(iulog,*)' Enable ISCCP simulator = ', lisccp_sim + write(iulog,*)' Enable MISR simulator = ', lmisr_sim + write(iulog,*)' Enable MODIS simulator = ', lmodis_sim + write(iulog,*)' Enable RTTOV simulator = ', lrttov_sim ! JKS - This isn't working for some reason. + write(iulog,*)' RADAR_SIM microphysics scheme = ', trim(cloudsat_micro_scheme) + write(iulog,*)' Write COSP output to history file = ', cosp_histfile_num + write(iulog,*)' Write COSP input fields = ', cosp_histfile_aux + write(iulog,*)' Write COSP input fields to history file = ', cosp_histfile_aux_num + write(iulog,*)' Write COSP subcolumn fields = ', cosp_lfrac_out + else + write(iulog,*)'COSP not enabled' + end if + end if +#endif + end subroutine cospsimulator_intr_readnl + + ! ###################################################################################### + ! SUBROUTINE cospsimulator_intr_register + ! ###################################################################################### + subroutine cospsimulator_intr_register() + + use cam_history_support, only: add_hist_coord + +#ifdef USE_COSP + integer :: i + character(len=8) :: & + fmt, & ! format descriptor for flexible RTTOV output + i_str + + fmt = '(I3.3)' ! an integer of width 3 with zeros at the left + + ! register non-standard variable dimensions + if (lisccp_sim .or. lmodis_sim) then + call add_hist_coord('cosp_prs', nprs_cosp, 'COSP Mean ISCCP pressure', & + 'hPa', prsmid_cosp, bounds_name='cosp_prs_bnds', bounds=prslim_cosp) + end if + + if (lisccp_sim .or. lmisr_sim) then + call add_hist_coord('cosp_tau', ntau_cosp, & + 'COSP Mean ISCCP optical depth', '1', taumid_cosp, & + bounds_name='cosp_tau_bnds', bounds=taulim_cosp) + end if + + if (lisccp_sim .or. llidar_sim .or. lradar_sim .or. lmisr_sim) then + call add_hist_coord('cosp_scol', nscol_cosp, 'COSP subcolumn', & + values=scol_cosp) + end if + + if (llidar_sim .or. lradar_sim) then + call add_hist_coord('cosp_ht', nht_cosp, & + 'COSP Mean Height for calipso and radar simulator outputs', 'm', & + htmid_cosp, bounds_name='cosp_ht_bnds', bounds=htlim_cosp, & + vertical_coord=.true.) + end if + + if (llidar_sim) then + call add_hist_coord('cosp_sr', nsr_cosp, & + 'COSP Mean Scattering Ratio for calipso simulator CFAD output', '1', & + srmid_cosp, bounds_name='cosp_sr_bnds', bounds=srlim_cosp) + end if + + if (llidar_sim) then + call add_hist_coord('cosp_sza', nsza_cosp, 'COSP Parasol SZA', & + 'degrees', sza_cosp) + end if + + if (lradar_sim) then + call add_hist_coord('cosp_dbze', CLOUDSAT_DBZE_BINS, & + 'COSP Mean dBZe for radar simulator CFAD output', 'dBZ', & + dbzemid_cosp, bounds_name='cosp_dbze_bnds', bounds=dbzelim_cosp) + end if + + if (lmisr_sim) then + call add_hist_coord('cosp_htmisr', nhtmisr_cosp, 'COSP MISR height', & + 'km', htmisrmid_cosp, & + bounds_name='cosp_htmisr_bnds', bounds=htmisrlim_cosp) + end if + + if (lmodis_sim) then + call add_hist_coord('cosp_tau_modis', ntau_cosp_modis, & + 'COSP Mean MODIS optical depth', '1', taumid_cosp_modis, & + bounds_name='cosp_tau_modis_bnds', bounds=taulim_cosp_modis) + call add_hist_coord('cosp_reffice',numMODISReffIceBins, & + 'COSP Mean MODIS effective radius (ice)', 'microns', reffICE_binCenters_cosp, & + bounds_name='cosp_reffice_bnds',bounds=reffICE_binEdges_cosp) + call add_hist_coord('cosp_reffliq',numMODISReffLiqBins, & + 'COSP Mean MODIS effective radius (liquid)', 'microns', reffLIQ_binCenters_cosp, & + bounds_name='cosp_reffliq_bnds',bounds=reffLIQ_binEdges_cosp) + end if + + ! JKS - For RTTOV, I will need to add history coordinates related to the channel outputs, which is determined during the init step + ! So I might need a separate subroutine that is called later but triggered by a logical set here? + ! Also, where is this subroutine called from? + + if (masterproc) then + if (docosp) then + write(iulog,*)'Reached RTTOV section in cospsimulator_intr_register' + write(iulog,*)'lrttov_sim: ', lrttov_sim + end if + end if + + ! Assume the rttov_configs object is accessible and set up here + if ((lrttov_sim) .and. (rttov_Ninstruments .gt. 0)) then + do i=1,rttov_Ninstruments + write (i_str,fmt) i ! converting integer to string i_str using a 'internal file' + + call add_hist_coord("RTTOV_CHAN_I"//trim(i_str), & ! This string needs to be 16 characters or less + rttov_configs(i) % nchan_out, & + 'RTTOV Channel Indices for Instrument '//trim(i_str), & + 'Channel Index', & + rttov_configs(i) % iChannel_out) + end do + end if + + if (masterproc) then + if (docosp) then + write(iulog,*)'Finished RTTOV section in cospsimulator_intr_register' + write(iulog,*)'lrttov_sim: ', lrttov_sim + end if + end if + +#endif + end subroutine cospsimulator_intr_register + + ! ###################################################################################### + ! SUBROUTINE cospsimulator_intr_init + ! ###################################################################################### + subroutine cospsimulator_intr_init() + +#ifdef USE_COSP + + use cam_history, only: addfld, add_default, horiz_only +#ifdef SPMD + use mpishorthand, only : mpir8, mpiint, mpicom +#endif + use netcdf, only : nf90_open, nf90_inq_varid, nf90_get_var, nf90_close, nf90_nowrite + use error_messages, only : handle_ncerr, alloc_err + + use physics_buffer, only: pbuf_get_index + + use mod_cosp_config, only : R_UNDEF + + integer :: ncid,latid,lonid,did,hrid,minid,secid, istat + integer :: i + character(len=8) :: & + fmt, & ! format descriptor for flexible RTTOV output + i_str + + fmt = '(I3.3)' ! an integer of width 3 with zeros at the left + + ! ISCCP OUTPUTS + if (lisccp_sim) then + !! addfld calls for all + !*cfMon,cfDa* clisccp2 (time,tau,plev,profile), CFMIP wants 7 p bins, 7 tau bins + call addfld('FISCCP1_COSP',(/'cosp_tau','cosp_prs'/),'A','percent', & + 'Grid-box fraction covered by each ISCCP D level cloud type',& + flag_xyfill=.true., fill_value=R_UNDEF) + + !*cfMon,cfDa* tclisccp (time,profile), CFMIP wants "gridbox mean cloud cover from ISCCP" + call addfld('CLDTOT_ISCCP', horiz_only,'A','percent', & + 'Total Cloud Fraction Calculated by the ISCCP Simulator ',flag_xyfill=.true., fill_value=R_UNDEF) + !*cfMon,cfDa* albisccp (time,profile) + ! Per CFMIP request - weight by ISCCP Total Cloud Fraction (divide by CLDTOT_ISSCP in history file to get weighted average) + call addfld('MEANCLDALB_ISCCP',horiz_only,'A','1','Mean cloud albedo*CLDTOT_ISCCP',flag_xyfill=.true., fill_value=R_UNDEF) + !*cfMon,cfDa* ctpisccp (time,profile) + ! Per CFMIP request - weight by ISCCP Total Cloud Fraction (divide by CLDTOT_ISSCP in history file to get weighted average) + call addfld('MEANPTOP_ISCCP',horiz_only,'A','Pa','Mean cloud top pressure*CLDTOT_ISCCP',flag_xyfill=.true., & + fill_value=R_UNDEF) + ! tauisccp (time,profile) + ! For averaging, weight by ISCCP Total Cloud Fraction (divide by CLDTOT_ISSCP in history file to get weighted average) + call addfld ('MEANTAU_ISCCP',horiz_only,'A','1','Mean optical thickness*CLDTOT_ISCCP',flag_xyfill=.true., & + fill_value=R_UNDEF) + ! meantbisccp (time,profile), at 10.5 um + call addfld ('MEANTB_ISCCP',horiz_only,'A','K','Mean Infrared Tb from ISCCP simulator',flag_xyfill=.true., & + fill_value=R_UNDEF) + ! meantbclrisccp (time,profile) + call addfld ('MEANTBCLR_ISCCP',horiz_only,'A','K','Mean Clear-sky Infrared Tb from ISCCP simulator', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! boxtauisccp (time,column,profile) + call addfld ('TAU_ISCCP',(/'cosp_scol'/),'I','1','Optical Depth in each Subcolumn',flag_xyfill=.true., fill_value=R_UNDEF) + ! boxptopisccp (time,column,profile) + call addfld ('CLDPTOP_ISCCP',(/'cosp_scol'/),'I','Pa','Cloud Top Pressure in each Subcolumn', & + flag_xyfill=.true., fill_value=R_UNDEF) + + !! add all isccp outputs to the history file specified by the CAM namelist variable cosp_histfile_num + call add_default ('FISCCP1_COSP',cosp_histfile_num,' ') + call add_default ('CLDTOT_ISCCP',cosp_histfile_num,' ') + call add_default ('MEANCLDALB_ISCCP',cosp_histfile_num,' ') + call add_default ('MEANPTOP_ISCCP',cosp_histfile_num,' ') + call add_default ('MEANTAU_ISCCP',cosp_histfile_num,' ') + call add_default ('MEANTB_ISCCP',cosp_histfile_num,' ') + call add_default ('MEANTBCLR_ISCCP',cosp_histfile_num,' ') + + end if + + ! CALIPSO SIMULATOR OUTPUTS + if (llidar_sim) then + !! addfld calls for all + !*cfMon,cfOff,cfDa,cf3hr* cllcalipso (time,profile) + call addfld('CLDLOW_CAL',horiz_only,'A','percent','Calipso Low-level Cloud Fraction',flag_xyfill=.true., fill_value=R_UNDEF) + !*cfMon,cfOff,cfDa,cf3hr* clmcalipso (time,profile) + call addfld('CLDMED_CAL',horiz_only,'A','percent','Calipso Mid-level Cloud Fraction',flag_xyfill=.true., fill_value=R_UNDEF) + !*cfMon,cfOff,cfDa,cf3hr* clhcalipso (time,profile) + call addfld('CLDHGH_CAL',horiz_only,'A','percent','Calipso High-level Cloud Fraction',flag_xyfill=.true., fill_value=R_UNDEF) + !*cfMon,cfOff,cfDa,cf3hr* cltcalipso (time,profile) + call addfld('CLDTOT_CAL',horiz_only,'A','percent','Calipso Total Cloud Fraction',flag_xyfill=.true., fill_value=R_UNDEF) + !*cfMon,cfOff,cfDa,cf3hr* clcalipso (time,height,profile) + call addfld('CLD_CAL',(/'cosp_ht'/),'A','percent','Calipso Cloud Fraction (532 nm)', flag_xyfill=.true., fill_value=R_UNDEF) + !*cfMon,cfOff,cfDa,cf3hr* parasol_refl (time,sza,profile) + call addfld ('RFL_PARASOL',(/'cosp_sza'/),'A','fraction','PARASOL-like mono-directional reflectance ', & + flag_xyfill=.true., fill_value=R_UNDEF) + !*cfOff,cf3hr* cfad_calipsosr532 (time,height,scat_ratio,profile), %11%, default is 40 vert levs, 15 SR bins + call addfld('CFAD_SR532_CAL',(/'cosp_sr','cosp_ht'/),'A','fraction', & + 'Calipso Scattering Ratio CFAD (532 nm)', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! beta_mol532 (time,height_mlev,profile) + call addfld ('MOL532_CAL',(/'lev'/),'A','m-1sr-1','Calipso Molecular Backscatter (532 nm) ', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! atb532 (time,height_mlev,column,profile) + call addfld ('ATB532_CAL',(/'cosp_scol','lev '/),'I','no_unit_log10(x)', & + 'Calipso Attenuated Total Backscatter (532 nm) in each Subcolumn', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! lclcalipsoliq (time,alt40,loc) !!+cosp1.4 + call addfld('CLD_CAL_LIQ', (/'cosp_ht'/), 'A','percent', 'Calipso Liquid Cloud Fraction', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! lclcalipsoice (time,alt40,loc) + call addfld('CLD_CAL_ICE', (/'cosp_ht'/), 'A','percent', 'Calipso Ice Cloud Fraction', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! lclcalipsoun (time,alt40,loc) + call addfld('CLD_CAL_UN', (/'cosp_ht'/),'A','percent', 'Calipso Undefined-Phase Cloud Fraction', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! lclcalipsotmp (time,alt40,loc) + call addfld('CLD_CAL_TMP', (/'cosp_ht'/), 'A','percent', 'NOT SURE WHAT THIS IS Cloud Fraction', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! lclcalipsotmpliq (time,alt40,loc) + call addfld('CLD_CAL_TMPLIQ', (/'cosp_ht'/), 'A','percent', 'NOT SURE WHAT THIS IS Cloud Fraction', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! lclcalipsotmpice (time,alt40,loc) + call addfld('CLD_CAL_TMPICE', (/'cosp_ht'/), 'A','percent', 'NOT SURE WHAT THIS IS Cloud Fraction', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! lclcalipsotmpun (time,alt40,loc) + call addfld('CLD_CAL_TMPUN', (/'cosp_ht'/), 'A','percent', 'NOT SURE WHAT THIS IS Cloud Fraction', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! lcltcalipsoice (time,loc) + call addfld('CLDTOT_CAL_ICE', horiz_only,'A','percent','Calipso Total Ice Cloud Fraction', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! lcltcalipsoliq (time,loc) + call addfld('CLDTOT_CAL_LIQ', horiz_only,'A','percent','Calipso Total Liquid Cloud Fraction', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! lcltcalipsoun (time,loc) + call addfld('CLDTOT_CAL_UN',horiz_only,'A','percent','Calipso Total Undefined-Phase Cloud Fraction', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! lclhcalipsoice (time,loc) + call addfld('CLDHGH_CAL_ICE',horiz_only,'A','percent','Calipso High-level Ice Cloud Fraction', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! lclhcalipsoliq (time,loc) + call addfld('CLDHGH_CAL_LIQ',horiz_only,'A','percent','Calipso High-level Liquid Cloud Fraction', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! lclhcalipsoun (time,loc) + call addfld('CLDHGH_CAL_UN',horiz_only,'A','percent','Calipso High-level Undefined-Phase Cloud Fraction', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! lclmcalipsoice (time,loc) + call addfld('CLDMED_CAL_ICE',horiz_only,'A','percent','Calipso Mid-level Ice Cloud Fraction', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! lclmcalipsoliq (time,loc) + call addfld('CLDMED_CAL_LIQ',horiz_only,'A','percent','Calipso Mid-level Liquid Cloud Fraction', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! lclmcalipsoun (time,loc) + call addfld('CLDMED_CAL_UN',horiz_only,'A','percent','Calipso Mid-level Undefined-Phase Cloud Fraction', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! lcllcalipsoice (time,loc) + call addfld('CLDLOW_CAL_ICE',horiz_only,'A','percent','Calipso Low-level Ice Cloud Fraction', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! lcllcalipsoliq (time,loc) + call addfld('CLDLOW_CAL_LIQ',horiz_only,'A','percent','Calipso Low-level Liquid Cloud Fraction', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! lcllcalipsoun (time,loc) !+cosp1.4 + call addfld('CLDLOW_CAL_UN',horiz_only,'A','percent','Calipso Low-level Undefined-Phase Cloud Fraction', & + flag_xyfill=.true., fill_value=R_UNDEF) + +! ! Calipso Opaque/thin cloud diagnostics +! call addfld('CLDOPQ_CAL', horiz_only, 'A', 'percent', 'CALIPSO Opaque Cloud Cover', & +! flag_xyfill=.true., fill_value=R_UNDEF) +! call addfld('CLDTHN_CAL', horiz_only, 'A', 'percent', 'CALIPSO Thin Cloud Cover', & +! flag_xyfill=.true., fill_value=R_UNDEF) +! call addfld('CLDZOPQ_CAL', horiz_only, 'A', 'm', 'CALIPSO z_opaque Altitude', & +! flag_xyfill=.true., fill_value=R_UNDEF) +! call addfld('CLDOPQ_CAL_2D', (/'cosp_ht'/), 'A', 'percent', 'CALIPSO Opaque Cloud Fraction', & +! flag_xyfill=.true., fill_value=R_UNDEF) +! call addfld('CLDTHN_CAL_2D', (/'cosp_ht'/), 'A', 'percent', 'CALIPSO Thin Cloud Fraction', & +! flag_xyfill=.true., fill_value=R_UNDEF) +! call addfld('CLDZOPQ_CAL_2D', (/'cosp_ht'/), 'A', 'percent', 'CALIPSO z_opaque Fraction', & +! flag_xyfill=.true., fill_value=R_UNDEF) +! call addfld('OPACITY_CAL_2D', (/'cosp_ht'/), 'A', 'percent', 'CALIPSO opacity Fraction', & +! flag_xyfill=.true., fill_value=R_UNDEF) +! call addfld('CLDOPQ_CAL_TMP', horiz_only, 'A', 'K', 'CALIPSO Opaque Cloud Temperature', & +! flag_xyfill=.true., fill_value=R_UNDEF) +! call addfld('CLDTHN_CAL_TMP', horiz_only, 'A', 'K', 'CALIPSO Thin Cloud Temperature', & +! flag_xyfill=.true., fill_value=R_UNDEF) +! call addfld('CLDZOPQ_CAL_TMP', horiz_only, 'A', 'K', 'CALIPSO z_opaque Temperature', & +! flag_xyfill=.true., fill_value=R_UNDEF) +! call addfld('CLDOPQ_CAL_Z', horiz_only, 'A', 'm', 'CALIPSO Opaque Cloud Altitude', & +! flag_xyfill=.true., fill_value=R_UNDEF) +! call addfld('CLDTHN_CAL_Z', horiz_only, 'A', 'm', 'CALIPSO Thin Cloud Altitude', & +! flag_xyfill=.true., fill_value=R_UNDEF) +! call addfld('CLDTHN_CAL_EMIS', horiz_only, 'A', '1', 'CALIPSO Thin Cloud Emissivity', & +! flag_xyfill=.true., fill_value=R_UNDEF) +! call addfld('CLDOPQ_CAL_SE', horiz_only, 'A', 'm', 'CALIPSO Opaque Cloud Altitude with respect to surface-elevation', & +! flag_xyfill=.true., fill_value=R_UNDEF) +! call addfld('CLDTHN_CAL_SE', horiz_only, 'A', 'm', 'CALIPSO Thin Cloud Altitude with respect to surface-elevation', & +! flag_xyfill=.true., fill_value=R_UNDEF) +! call addfld('CLDZOPQ_CAL_SE', horiz_only, 'A', 'm', 'CALIPSO z_opaque Altitude with respect to surface-elevation', & +! flag_xyfill=.true., fill_value=R_UNDEF) + + ! add_default calls for CFMIP experiments or else all fields are added to history file + ! except those with sub-column dimension/experimental variables + !! add all calipso outputs to the history file specified by the CAM namelist variable cosp_histfile_num + call add_default ('CLDLOW_CAL',cosp_histfile_num,' ') + call add_default ('CLDMED_CAL',cosp_histfile_num,' ') + call add_default ('CLDHGH_CAL',cosp_histfile_num,' ') + call add_default ('CLDTOT_CAL',cosp_histfile_num,' ') + call add_default ('CLD_CAL',cosp_histfile_num,' ') + call add_default ('RFL_PARASOL',cosp_histfile_num,' ') + call add_default ('CFAD_SR532_CAL',cosp_histfile_num,' ') + call add_default ('CLD_CAL_LIQ',cosp_histfile_num,' ') !+COSP1.4 + call add_default ('CLD_CAL_ICE',cosp_histfile_num,' ') + call add_default ('CLD_CAL_UN',cosp_histfile_num,' ') + call add_default ('CLDTOT_CAL_ICE',cosp_histfile_num,' ') + call add_default ('CLDTOT_CAL_LIQ',cosp_histfile_num,' ') + call add_default ('CLDTOT_CAL_UN',cosp_histfile_num,' ') + call add_default ('CLDHGH_CAL_ICE',cosp_histfile_num,' ') + call add_default ('CLDHGH_CAL_LIQ',cosp_histfile_num,' ') + call add_default ('CLDHGH_CAL_UN',cosp_histfile_num,' ') + call add_default ('CLDMED_CAL_ICE',cosp_histfile_num,' ') + call add_default ('CLDMED_CAL_LIQ',cosp_histfile_num,' ') + call add_default ('CLDMED_CAL_UN',cosp_histfile_num,' ') + call add_default ('CLDLOW_CAL_ICE',cosp_histfile_num,' ') + call add_default ('CLDLOW_CAL_LIQ',cosp_histfile_num,' ') + call add_default ('CLDLOW_CAL_UN',cosp_histfile_num,' ') +! call add_default ('CLDOPQ_CAL',cosp_histfile_num,' ') +! call add_default ('CLDTHN_CAL',cosp_histfile_num,' ') +! call add_default ('CLDZOPQ_CAL',cosp_histfile_num,' ') +! call add_default ('CLDOPQ_CAL_2D',cosp_histfile_num,' ') +! call add_default ('CLDTHN_CAL_2D',cosp_histfile_num,' ') +! call add_default ('CLDZOPQ_CAL_2D',cosp_histfile_num,' ') +! call add_default ('OPACITY_CAL_2D',cosp_histfile_num,' ') +! call add_default ('CLDOPQ_CAL_TMP',cosp_histfile_num,' ') +! call add_default ('CLDTHN_CAL_TMP',cosp_histfile_num,' ') +! call add_default ('CLDZOPQ_CAL_TMP',cosp_histfile_num,' ') +! call add_default ('CLDOPQ_CAL_Z',cosp_histfile_num,' ') +! call add_default ('CLDTHN_CAL_Z',cosp_histfile_num,' ') +! call add_default ('CLDTHN_CAL_EMIS',cosp_histfile_num,' ') +! call add_default ('CLDOPQ_CAL_SE',cosp_histfile_num,' ') +! call add_default ('CLDTHN_CAL_SE',cosp_histfile_num,' ') +! call add_default ('CLDZOPQ_CAL_SE',cosp_histfile_num,' ') + + if ((.not.cosp_amwg) .and. (.not.cosp_lite) .and. (.not.cosp_passive) .and. (.not.cosp_active) & + .and. (.not.cosp_isccp)) then + call add_default ('MOL532_CAL',cosp_histfile_num,' ') + end if + end if + + ! RADAR SIMULATOR OUTPUTS + if (lradar_sim) then + + allocate(sd_cs(begchunk:endchunk), rcfg_cs(begchunk:endchunk)) + do i = begchunk, endchunk + sd_cs(i) = sd + rcfg_cs(i) = rcfg_cloudsat + end do + + ! addfld calls + !*cfOff,cf3hr* cfad_dbze94 (time,height,dbze,profile), default is 40 vert levs, 15 dBZ bins + call addfld('CFAD_DBZE94_CS',(/'cosp_dbze','cosp_ht '/),'A','fraction',& + 'Radar Reflectivity Factor CFAD (94 GHz)',& + flag_xyfill=.true., fill_value=R_UNDEF) + !*cfOff,cf3hr* clcalipso2 (time,height,profile) + call addfld ('CLD_CAL_NOTCS',(/'cosp_ht'/),'A','percent','Cloud occurrence seen by CALIPSO but not CloudSat ', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! cltcalipsoradar (time,profile) + call addfld ('CLDTOT_CALCS',horiz_only,'A','percent',' Calipso and Radar Total Cloud Fraction ',flag_xyfill=.true., & + fill_value=R_UNDEF) + call addfld ('CLDTOT_CS',horiz_only,'A','percent',' Radar total cloud amount ',flag_xyfill=.true., fill_value=R_UNDEF) + call addfld ('CLDTOT_CS2',horiz_only,'A','percent', & + ' Radar total cloud amount without the data for the first kilometer above surface ', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! dbze94 (time,height_mlev,column,profile),! height_mlevel = height when vgrid_in = .true. (default) + call addfld ('DBZE_CS',(/'cosp_scol','lev '/),'I','dBZe',' Radar dBZe (94 GHz) in each Subcolumn',& + flag_xyfill=.true., fill_value=R_UNDEF) + + ! Cloudsat near-sfc precipitation diagnostics + call addfld('CS_NOPRECIP', horiz_only, 'A', '1', 'CloudSat No Rain Fraction', flag_xyfill=.true., fill_value=R_UNDEF) + call addfld('CS_RAINPOSS', horiz_only, 'A', '1', 'Cloudsat Rain Possible Fraction', flag_xyfill=.true., fill_value=R_UNDEF) + call addfld('CS_RAINPROB', horiz_only, 'A', '1', 'CloudSat Rain Probable Fraction', flag_xyfill=.true., fill_value=R_UNDEF) + call addfld('CS_RAINCERT', horiz_only, 'A', '1', 'CloudSat Rain Certain Fraction', flag_xyfill=.true., fill_value=R_UNDEF) + call addfld('CS_SNOWPOSS', horiz_only, 'A', '1', 'CloudSat Snow Possible Fraction', flag_xyfill=.true., fill_value=R_UNDEF) + call addfld('CS_SNOWCERT', horiz_only, 'A', '1', 'CloudSat Snow Certain Fraction', flag_xyfill=.true., fill_value=R_UNDEF) + call addfld('CS_MIXPOSS', horiz_only, 'A', '1', 'CloudSat Mixed Possible Fraction', flag_xyfill=.true., fill_value=R_UNDEF) + call addfld('CS_MIXCERT', horiz_only, 'A', '1', 'CloudSat Mixed Certain Fraction', flag_xyfill=.true., fill_value=R_UNDEF) + call addfld('CS_RAINHARD', horiz_only, 'A', '1', 'CloudSat Heavy Rain Fraction', flag_xyfill=.true., fill_value=R_UNDEF) + call addfld('CS_UN', horiz_only, 'A', '1', 'CloudSat Unclassified Precipitation Fraction',flag_xyfill=.true., fill_value=R_UNDEF) + call addfld('CS_PIA', horiz_only, 'A', 'dBZ', 'CloudSat Radar Path Integrated Attenuation', flag_xyfill=.true., fill_value=R_UNDEF) + ! Associated CAM microphysics + !call addfld('CAM_MP_CVRAIN',horiz_only, 'A', 'kg/kg','CAM Microphysics Convective Rain', flag_xyfill=.true., fill_value=R_UNDEF) + !call addfld('CAM_MP_CVSNOW',horiz_only, 'A', 'kg/kg','CAM Microphysics Convective Snow', flag_xyfill=.true., fill_value=R_UNDEF) + !call addfld('CAM_MP_LSRAIN',horiz_only, 'A', 'kg/kg','CAM Microphysics Large-Scale Rain', flag_xyfill=.true., fill_value=R_UNDEF) + !call addfld('CAM_MP_LSSNOW',horiz_only, 'A', 'kg/kg','CAM Microphysics Large-Scale Snow', flag_xyfill=.true., fill_value=R_UNDEF) + !call addfld('CAM_MP_LSGRPL',horiz_only, 'A', 'kg/kg','CAM Microphysics Large-Scale Graupel', flag_xyfill=.true., fill_value=R_UNDEF) + + + ! add_default calls for CFMIP experiments or else all fields are added to history file except those with sub-column dimension + !! add all radar outputs to the history file specified by the CAM namelist variable cosp_histfile_num + call add_default ('CFAD_DBZE94_CS',cosp_histfile_num,' ') + call add_default ('CLD_CAL_NOTCS', cosp_histfile_num,' ') + call add_default ('CLDTOT_CALCS', cosp_histfile_num,' ') + call add_default ('CLDTOT_CS', cosp_histfile_num,' ') + call add_default ('CLDTOT_CS2', cosp_histfile_num,' ') + call add_default ('CS_NOPRECIP', cosp_histfile_num,' ') + call add_default ('CS_RAINPOSS', cosp_histfile_num,' ') + call add_default ('CS_RAINPROB', cosp_histfile_num,' ') + call add_default ('CS_RAINCERT', cosp_histfile_num,' ') + call add_default ('CS_SNOWPOSS', cosp_histfile_num,' ') + call add_default ('CS_SNOWCERT', cosp_histfile_num,' ') + call add_default ('CS_MIXPOSS', cosp_histfile_num,' ') + call add_default ('CS_MIXCERT', cosp_histfile_num,' ') + call add_default ('CS_RAINHARD', cosp_histfile_num,' ') + call add_default ('CS_UN', cosp_histfile_num,' ') + call add_default ('CS_PIA', cosp_histfile_num,' ') + end if + + ! MISR SIMULATOR OUTPUTS + if (lmisr_sim) then + ! clMISR (time,tau,CTH_height_bin,profile) + call addfld ('CLD_MISR',(/'cosp_tau ','cosp_htmisr'/),'A','percent','Cloud Fraction from MISR Simulator', & + flag_xyfill=.true., fill_value=R_UNDEF) + !! add all misr outputs to the history file specified by the CAM namelist variable cosp_histfile_num + call add_default ('CLD_MISR',cosp_histfile_num,' ') + end if + + ! MODIS OUTPUT + if (lmodis_sim) then + ! float cltmodis ( time, loc ) + call addfld ('CLTMODIS',horiz_only,'A','%','MODIS Total Cloud Fraction',flag_xyfill=.true., fill_value=R_UNDEF) + ! float clwmodis ( time, loc ) + call addfld ('CLWMODIS',horiz_only,'A','%','MODIS Liquid Cloud Fraction',flag_xyfill=.true., fill_value=R_UNDEF) + ! float climodis ( time, loc ) + call addfld ('CLIMODIS',horiz_only,'A','%','MODIS Ice Cloud Fraction',flag_xyfill=.true., fill_value=R_UNDEF) + ! float clhmodis ( time, loc ) + call addfld ('CLHMODIS',horiz_only,'A','%','MODIS High Level Cloud Fraction',flag_xyfill=.true., fill_value=R_UNDEF) + ! float clmmodis ( time, loc ) + call addfld ('CLMMODIS',horiz_only,'A','%','MODIS Mid Level Cloud Fraction',flag_xyfill=.true., fill_value=R_UNDEF) + ! float cllmodis ( time, loc ) + call addfld ('CLLMODIS',horiz_only,'A','%','MODIS Low Level Cloud Fraction',flag_xyfill=.true., fill_value=R_UNDEF) + ! float tautmodis ( time, loc ) + call addfld ('TAUTMODIS',horiz_only,'A','1','MODIS Total Cloud Optical Thickness*CLTMODIS', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! float tauwmodis ( time, loc ) + call addfld ('TAUWMODIS',horiz_only,'A','1','MODIS Liquid Cloud Optical Thickness*CLWMODIS', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! float tauimodis ( time, loc ) + call addfld ('TAUIMODIS',horiz_only,'A','1','MODIS Ice Cloud Optical Thickness*CLIMODIS', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! float tautlogmodis ( time, loc ) + call addfld ('TAUTLOGMODIS',horiz_only,'A','1','MODIS Total Cloud Optical Thickness (Log10 Mean)*CLTMODIS', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! float tauwlogmodis ( time, loc ) + call addfld ('TAUWLOGMODIS',horiz_only,'A','1','MODIS Liquid Cloud Optical Thickness (Log10 Mean)*CLWMODIS', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! float tauilogmodis ( time, loc ) + call addfld ('TAUILOGMODIS',horiz_only,'A','1','MODIS Ice Cloud Optical Thickness (Log10 Mean)*CLIMODIS', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! float reffclwmodis ( time, loc ) + call addfld ('REFFCLWMODIS',horiz_only,'A','m','MODIS Liquid Cloud Particle Size*CLWMODIS', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! float reffclimodis ( time, loc ) + call addfld ('REFFCLIMODIS',horiz_only,'A','m','MODIS Ice Cloud Particle Size*CLIMODIS', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! float pctmodis ( time, loc ) + call addfld ('PCTMODIS',horiz_only,'A','Pa','MODIS Cloud Top Pressure*CLTMODIS',flag_xyfill=.true., fill_value=R_UNDEF) + ! float lwpmodis ( time, loc ) + call addfld ('LWPMODIS',horiz_only,'A','kg m-2','MODIS Cloud Liquid Water Path*CLWMODIS', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! float iwpmodis ( time, loc ) + call addfld ('IWPMODIS',horiz_only,'A','kg m-2','MODIS Cloud Ice Water Path*CLIMODIS',flag_xyfill=.true., fill_value=R_UNDEF) + ! float clmodis ( time, plev, tau, loc ) + call addfld ('CLMODIS',(/'cosp_tau_modis','cosp_prs '/),'A','%','MODIS Cloud Area Fraction', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! float clrimodis ( time, plev, tau, loc ) + call addfld ('CLRIMODIS',(/'cosp_tau_modis','cosp_reffice '/),'A','%','MODIS Cloud Area Fraction', & + flag_xyfill=.true., fill_value=R_UNDEF) + ! float clrlmodis ( time, plev, tau, loc ) + call addfld ('CLRLMODIS',(/'cosp_tau_modis','cosp_reffliq '/),'A','%','MODIS Cloud Area Fraction', & + flag_xyfill=.true., fill_value=R_UNDEF) + + !! add MODIS output to history file specified by the CAM namelist variable cosp_histfile_num + call add_default ('CLTMODIS',cosp_histfile_num,' ') + call add_default ('CLWMODIS',cosp_histfile_num,' ') + call add_default ('CLIMODIS',cosp_histfile_num,' ') + call add_default ('CLHMODIS',cosp_histfile_num,' ') + call add_default ('CLMMODIS',cosp_histfile_num,' ') + call add_default ('CLLMODIS',cosp_histfile_num,' ') + call add_default ('TAUTMODIS',cosp_histfile_num,' ') + call add_default ('TAUWMODIS',cosp_histfile_num,' ') + call add_default ('TAUIMODIS',cosp_histfile_num,' ') + call add_default ('TAUTLOGMODIS',cosp_histfile_num,' ') + call add_default ('TAUWLOGMODIS',cosp_histfile_num,' ') + call add_default ('TAUILOGMODIS',cosp_histfile_num,' ') + call add_default ('REFFCLWMODIS',cosp_histfile_num,' ') + call add_default ('REFFCLIMODIS',cosp_histfile_num,' ') + call add_default ('PCTMODIS',cosp_histfile_num,' ') + call add_default ('LWPMODIS',cosp_histfile_num,' ') + call add_default ('IWPMODIS',cosp_histfile_num,' ') + call add_default ('CLMODIS',cosp_histfile_num,' ') + call add_default ('CLRIMODIS',cosp_histfile_num,' ') + call add_default ('CLRLMODIS',cosp_histfile_num,' ') + end if + + ! SUB-COLUMN OUTPUT + if (lfrac_out) then + ! frac_out (time,height_mlev,column,profile) + call addfld ('SCOPS_OUT',(/'cosp_scol','lev '/),'I','0=nocld,1=strcld,2=cnvcld','SCOPS Subcolumn output', & + flag_xyfill=.true., fill_value=R_UNDEF) + !! add scops ouptut to history file specified by the CAM namelist variable cosp_histfile_num + call add_default ('SCOPS_OUT',cosp_histfile_num,' ') + ! save sub-column outputs from ISCCP if ISCCP is run + if (lisccp_sim) then + call add_default ('TAU_ISCCP',cosp_histfile_num,' ') + call add_default ('CLDPTOP_ISCCP',cosp_histfile_num,' ') + end if + ! save sub-column outputs from calipso if calipso is run + if (llidar_sim) then + call add_default ('ATB532_CAL',cosp_histfile_num,' ') + end if + ! save sub-column outputs from radar if radar is run + if (lradar_sim) then + call add_default ('DBZE_CS',cosp_histfile_num,' ') + end if + end if + + if (masterproc) then + if (docosp) then + write(iulog,*)'Reached RTTOV section in cospsimulator_intr_init' + write(iulog,*)'lrttov_sim: ', lrttov_sim + end if + end if + + ! RTTOV + if (lrttov_sim) then + do i=1,rttov_Ninstruments + write (i_str,fmt) i ! converting integer to string i_str using a 'internal file' + if (not(rttov_configs(i) % Lrttov_pc)) then + if (rttov_configs(i) % Lrttov_bt) then + ! Just add one variable for now. + call addfld ("rttov_bt_total_inst"//trim(i_str), & + (/"RTTOV_CHAN_I"//trim(i_str)/), & + 'A', & ! A - 'average', I - 'instantaneous' + 'Degrees Kelvin', & ! Units + 'RTTOV All-sky Brightness Temperature', & + flag_xyfill=.true., & + fill_value=R_UNDEF) + call add_default ("rttov_bt_total_inst"//trim(i_str),cosp_histfile_num,' ') + end if + + if (rttov_configs(i) % Lrttov_bt .and. ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer))) then + call addfld ("rttov_bt_clear_inst"//trim(i_str), & + (/"RTTOV_CHAN_I"//trim(i_str)/), & + 'A', & + 'Degrees Kelvin', & + 'RTTOV Clear-sky Brightness Temperature', & + flag_xyfill=.true., & + fill_value=R_UNDEF) + call add_default ("rttov_bt_clear_inst"//trim(i_str),cosp_histfile_num,' ') + end if + + if (rttov_configs(i) % Lrttov_rad) then + call addfld ("rttov_rad_total_inst"//trim(i_str), & + (/"RTTOV_CHAN_I"//trim(i_str)/), & + 'A', & + 'mW/cm-1/sr/m2', & + 'RTTOV All-sky Radiance', & + flag_xyfill=.true., & + fill_value=R_UNDEF) + call add_default ("rttov_rad_total_inst"//trim(i_str),cosp_histfile_num,' ') + end if + + if (rttov_configs(i) % Lrttov_rad .and. ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer))) then + call addfld ("rttov_rad_clear_inst"//trim(i_str), & + (/"RTTOV_CHAN_I"//trim(i_str)/), & + 'A', & + 'mW/cm-1/sr/m2', & + 'RTTOV Clear-sky Radiance', & + flag_xyfill=.true., & + fill_value=R_UNDEF) + call add_default ("rttov_rad_clear_inst"//trim(i_str),cosp_histfile_num,' ') + call addfld ("rttov_rad_cloudy_inst"//trim(i_str), & + (/"RTTOV_CHAN_I"//trim(i_str)/), & + 'A', & + 'mW/cm-1/sr/m2', & + 'RTTOV Cloudy-sky Radiance', & + flag_xyfill=.true., & + fill_value=R_UNDEF) + call add_default ("rttov_rad_cloudy_inst"//trim(i_str),cosp_histfile_num,' ') + end if + + if (rttov_configs(i) % Lrttov_refl) then + call addfld ("rttov_refl_total_inst"//trim(i_str), & + (/"RTTOV_CHAN_I"//trim(i_str)/), & + 'A', & + '1', & + 'RTTOV All-sky Reflectance', & + flag_xyfill=.true., & + fill_value=R_UNDEF) + call add_default ("rttov_refl_total_inst"//trim(i_str),cosp_histfile_num,' ') + end if + + if (rttov_configs(i) % Lrttov_refl .and. ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer))) then + call addfld ("rttov_refl_clear_inst"//trim(i_str), & + (/"RTTOV_CHAN_I"//trim(i_str)/), & + 'A', & + '1', & + 'RTTOV Clear-sky Reflectance', & + flag_xyfill=.true., & + fill_value=R_UNDEF) + call add_default ("rttov_refl_clear_inst"//trim(i_str),cosp_histfile_num,' ') + end if + else + if (rttov_configs(i) % Lrttov_bt) then + call addfld ("rttov_btpc_clr_inst"//trim(i_str), & + (/"RTTOV_CHAN_I"//trim(i_str)/), & + 'A', & + 'Degrees Kelvin', & + 'PC-RTTOV Clear-sky Brightness Temperature', & + flag_xyfill=.true., & + fill_value=R_UNDEF) + call add_default ("rttov_btpc_clr_inst"//trim(i_str),cosp_histfile_num,' ') + end if + + if (rttov_configs(i) % Lrttov_rad) then + call addfld ("rttov_radpc_clr_inst"//trim(i_str), & + (/"RTTOV_CHAN_I"//trim(i_str)/), & + 'A', & + 'mW/cm-1/sr/m2', & + 'PC-RTTOV Clear-sky Radiance', & + flag_xyfill=.true., & + fill_value=R_UNDEF) + call add_default ("rttov_radpc_clr_inst"//trim(i_str),cosp_histfile_num,' ') + end if + end if + end do + end if + + if (masterproc) then + if (docosp) then + write(iulog,*)'Finished RTTOV section in cospsimulator_intr_init' + write(iulog,*)'lrttov_sim: ', lrttov_sim + end if + end if + + !! ADDFLD, ADD_DEFAULT, OUTFLD CALLS FOR COSP OUTPUTS IF RUNNING COSP OFF-LINE + !! Note: A suggestion was to add all of the CAM variables needed to add to make it possible to run COSP off-line + !! These fields are available and can be called from the namelist though. Here, when the cosp_runall mode is invoked + !! all of the inputs are saved on the cam history file. This is good de-bugging functionality we should maintain. + if (cosp_histfile_aux) then + call addfld ('PS_COSP', horiz_only, 'I','Pa', 'PS_COSP', & + flag_xyfill=.true., fill_value=R_UNDEF) + call addfld ('TS_COSP', horiz_only, 'I','K', 'TS_COSP', & + flag_xyfill=.true., fill_value=R_UNDEF) + call addfld ('P_COSP', (/ 'lev'/), 'I','Pa', 'P_COSP', & + flag_xyfill=.true., fill_value=R_UNDEF) + call addfld ('PH_COSP', (/ 'lev'/), 'I','Pa', 'PH_COSP', & + flag_xyfill=.true., fill_value=R_UNDEF) + call addfld ('ZLEV_COSP', (/ 'lev'/), 'I','m', 'ZLEV_COSP', & + flag_xyfill=.true., fill_value=R_UNDEF) + call addfld ('ZLEV_HALF_COSP', (/ 'lev'/), 'I','m', 'ZLEV_HALF_COSP', & + flag_xyfill=.true., fill_value=R_UNDEF) + call addfld ('T_COSP', (/ 'lev'/), 'I','K', 'T_COSP', & + flag_xyfill=.true., fill_value=R_UNDEF) + call addfld ('RH_COSP', (/ 'lev'/), 'I','percent','RH_COSP', & + flag_xyfill=.true., fill_value=R_UNDEF) + call addfld ('Q_COSP', (/ 'lev'/), 'I','kg/kg', 'Q_COSP', & + flag_xyfill=.true., fill_value=R_UNDEF) + call addfld ('TAU_067', (/'cosp_scol','lev '/), 'I','1', 'Subcolumn 0.67micron optical depth', & + flag_xyfill=.true., fill_value=R_UNDEF) + call addfld ('EMISS_11', (/'cosp_scol','lev '/), 'I','1', 'Subcolumn 11micron emissivity', & + flag_xyfill=.true., fill_value=R_UNDEF) + call addfld ('MODIS_fracliq', (/'cosp_scol','lev '/), 'I','1', 'Fraction of tau from liquid water', & + flag_xyfill=.true., fill_value=R_UNDEF) + call addfld ('MODIS_asym', (/'cosp_scol','lev '/), 'I','1', 'Assymetry parameter (MODIS)', & + flag_xyfill=.true., fill_value=R_UNDEF) + call addfld ('MODIS_ssa', (/'cosp_scol','lev '/), 'I','1', 'Single-scattering albedo (MODIS)', & + flag_xyfill=.true., fill_value=R_UNDEF) + call addfld ('CAL_betatot', (/'cosp_scol','lev '/), 'I','1', 'Backscatter coefficient (CALIPSO)', & + flag_xyfill=.true., fill_value=R_UNDEF) + call addfld ('CAL_betatot_ice', (/'cosp_scol','lev '/), 'I','1', 'Backscatter coefficient (CALIPSO)', & + flag_xyfill=.true., fill_value=R_UNDEF) + call addfld ('CAL_betatot_liq', (/'cosp_scol','lev '/), 'I','1', 'Backscatter coefficient (CALIPSO)', & + flag_xyfill=.true., fill_value=R_UNDEF) + call addfld ('CAL_tautot', (/'cosp_scol','lev '/), 'I','1', 'Vertically integrated ptical-depth (CALIPSO)', & + flag_xyfill=.true., fill_value=R_UNDEF) + call addfld ('CAL_tautot_ice', (/'cosp_scol','lev '/), 'I','1', 'Vertically integrated ptical-depth (CALIPSO)', & + flag_xyfill=.true., fill_value=R_UNDEF) + call addfld ('CAL_tautot_liq', (/'cosp_scol','lev '/), 'I','1', 'Vertically integrated ptical-depth (CALIPSO)', & + flag_xyfill=.true., fill_value=R_UNDEF) + call addfld ('CS_z_vol', (/'cosp_scol','lev '/), 'I','1', 'Effective reflectivity factor (CLOUDSAT)', & + flag_xyfill=.true., fill_value=R_UNDEF) + call addfld ('CS_kr_vol', (/'cosp_scol','lev '/), 'I','1', 'Attenuation coefficient (hydro) (CLOUDSAT)', & + flag_xyfill=.true., fill_value=R_UNDEF) + call addfld ('CS_g_vol', (/'cosp_scol','lev '/), 'I','1', 'Attenuation coefficient (gases) (CLOUDSAT)', & + flag_xyfill=.true., fill_value=R_UNDEF) + + call add_default ('PS_COSP', cosp_histfile_aux_num,' ') + call add_default ('TS_COSP', cosp_histfile_aux_num,' ') + call add_default ('P_COSP', cosp_histfile_aux_num,' ') + call add_default ('PH_COSP', cosp_histfile_aux_num,' ') + call add_default ('ZLEV_COSP', cosp_histfile_aux_num,' ') + call add_default ('ZLEV_HALF_COSP', cosp_histfile_aux_num,' ') + call add_default ('T_COSP', cosp_histfile_aux_num,' ') + call add_default ('RH_COSP', cosp_histfile_aux_num,' ') + call add_default ('TAU_067', cosp_histfile_aux_num,' ') + call add_default ('EMISS_11', cosp_histfile_aux_num,' ') + call add_default ('MODIS_fracliq', cosp_histfile_aux_num,' ') + call add_default ('MODIS_asym', cosp_histfile_aux_num,' ') + call add_default ('MODIS_ssa', cosp_histfile_aux_num,' ') + call add_default ('CAL_betatot', cosp_histfile_aux_num,' ') + call add_default ('CAL_betatot_ice', cosp_histfile_aux_num,' ') + call add_default ('CAL_betatot_liq', cosp_histfile_aux_num,' ') + call add_default ('CAL_tautot', cosp_histfile_aux_num,' ') + call add_default ('CAL_tautot_ice', cosp_histfile_aux_num,' ') + call add_default ('CAL_tautot_liq', cosp_histfile_aux_num,' ') + call add_default ('CS_z_vol', cosp_histfile_aux_num,' ') + call add_default ('CS_kr_vol', cosp_histfile_aux_num,' ') + call add_default ('CS_g_vol', cosp_histfile_aux_num,' ') + end if + + rei_idx = pbuf_get_index('REI') + rel_idx = pbuf_get_index('REL') + cld_idx = pbuf_get_index('CLD') + concld_idx = pbuf_get_index('CONCLD') + lsreffrain_idx = pbuf_get_index('LS_REFFRAIN') + lsreffsnow_idx = pbuf_get_index('LS_REFFSNOW') + cvreffliq_idx = pbuf_get_index('CV_REFFLIQ') + cvreffice_idx = pbuf_get_index('CV_REFFICE') + dpcldliq_idx = pbuf_get_index('DP_CLDLIQ') + dpcldice_idx = pbuf_get_index('DP_CLDICE') + shcldliq_idx = pbuf_get_index('SH_CLDLIQ') + shcldice_idx = pbuf_get_index('SH_CLDICE') + shcldliq1_idx = pbuf_get_index('SH_CLDLIQ1') + shcldice1_idx = pbuf_get_index('SH_CLDICE1') + dpflxprc_idx = pbuf_get_index('DP_FLXPRC') + dpflxsnw_idx = pbuf_get_index('DP_FLXSNW') + shflxprc_idx = pbuf_get_index('SH_FLXPRC') + shflxsnw_idx = pbuf_get_index('SH_FLXSNW') + lsflxprc_idx = pbuf_get_index('LS_FLXPRC') + lsflxsnw_idx = pbuf_get_index('LS_FLXSNW') +! ubot_idx = pbuf_get_index('U10') ! alternate option is 10m winds (U10 and V10) +! vbot_idx = pbuf_get_index('V10') + + allocate(first_run_cosp(begchunk:endchunk)) + first_run_cosp(begchunk:endchunk)=.true. + allocate(run_cosp(1:pcols,begchunk:endchunk)) + run_cosp(1:pcols,begchunk:endchunk)=.false. + +#endif + end subroutine cospsimulator_intr_init + + ! ###################################################################################### + ! SUBROUTINE cospsimulator_intr_run + ! ###################################################################################### + subroutine cospsimulator_intr_run(state,pbuf, cam_in,emis,coszrs,cld_swtau_in,snow_tau_in,snow_emis_in) + use physics_types, only: physics_state + use physics_buffer, only: physics_buffer_desc, pbuf_get_field, pbuf_old_tim_idx + use camsrfexch, only: cam_in_t + use constituents, only: cnst_get_ind + use rad_constituents, only: rad_cnst_get_gas + use wv_saturation, only: qsat_water + use interpolate_data, only: lininterp_init,lininterp,lininterp_finish,interp_type + use physconst, only: pi, gravit + use cam_history, only: outfld,hist_fld_col_active + use cam_history_support, only: max_fieldname_len + use cmparray_mod, only: CmpDayNite, ExpDayNite +#ifdef USE_COSP + use mod_cosp_config, only: R_UNDEF,parasol_nrefl, Nlvgrid, vgrid_zl, vgrid_zu + use mod_cosp, only: cosp_simulator + use mod_quickbeam_optics, only: size_distribution + use time_manager, only: get_curr_date ! Gets the date/time valid at the end of the timestep. Should be fine. +#endif + + ! ###################################################################################### + ! Inputs + ! ###################################################################################### + type(physics_state), intent(in),target :: state + type(physics_buffer_desc), pointer :: pbuf(:) + type(cam_in_t), intent(in) :: cam_in + real(r8), intent(in) :: emis(pcols,pver) ! cloud longwave emissivity + real(r8), intent(in) :: coszrs(pcols) ! cosine solar zenith angle (to tell if day or night) + real(r8), intent(in),optional :: cld_swtau_in(pcols,pver) ! RRTM cld_swtau_in, read in using this variable + real(r8), intent(in),optional :: snow_tau_in(pcols,pver) ! RRTM grid-box mean SW snow optical depth, used for CAM5 simulations + real(r8), intent(in),optional :: snow_emis_in(pcols,pver) ! RRTM grid-box mean LW snow optical depth, used for CAM5 simulations + +#ifdef USE_COSP + ! ###################################################################################### + ! Local variables + ! ###################################################################################### + integer :: lchnk ! chunk identifier + integer :: ncol ! number of active atmospheric columns + integer :: i,k,ip,it,ipt,ih,id,ihd,is,ihs,isc,ihsc,ihm,ihmt,ihml,itim_old,ifld + + ! Variables for day/nite and orbital subsetting + ! Gathered indicies of day and night columns + ! chunk_column_index = IdxDay(daylight_column_index) + integer :: Nday ! Number of daylight columns + integer :: Nno ! Number of columns not using for simulator + integer, dimension(pcols) :: IdxDay ! Indices of daylight columns + integer, dimension(pcols) :: IdxNo ! Indices of columns not using for simulator + real(r8) :: tmp(pcols) ! tempororary variable for array expansion + real(r8) :: tmp1(pcols,pver) ! tempororary variable for array expansion + real(r8) :: tmp2(pcols,pver) ! tempororary variable for array expansion + real(r8) :: lon_cosp_day(pcols) ! tempororary variable for sunlit lons + real(r8) :: lat_cosp_day(pcols) ! tempororary variable for sunlit lats + real(r8) :: ptop_day(pcols,pver) ! tempororary variable for sunlit ptop + real(r8) :: pmid_day(pcols,pver) ! tempororary variable for sunlit pmid + real(r8) :: ztop_day(pcols,pver) ! tempororary variable for sunlit ztop + real(r8) :: zmid_day(pcols,pver) ! tempororary variable for sunlit zmid + real(r8) :: t_day(pcols,pver) ! tempororary variable for sunlit t + real(r8) :: rh_day(pcols,pver) ! tempororary variable for sunlit rh + real(r8) :: q_day(pcols,pver) ! tempororary variable for sunlit q + real(r8) :: concld_day(pcols,pver) ! tempororary variable for sunlit concld + real(r8) :: cld_day(pcols,pver) ! tempororary variable for sunlit cld + real(r8) :: ps_day(pcols) ! tempororary variable for sunlit ps + real(r8) :: ts_day(pcols) ! tempororary variable for sunlit ts + real(r8) :: landmask_day(pcols) ! tempororary variable for sunlit landmask + real(r8) :: o3_day(pcols,pver) ! tempororary variable for sunlit o3 + real(r8) :: us_day(pcols) ! tempororary variable for sunlit us + real(r8) :: vs_day(pcols) ! tempororary variable for sunlit vs + real(r8) :: mr_lsliq_day(pcols,pver) ! tempororary variable for sunlit mr_lsliq + real(r8) :: mr_lsice_day(pcols,pver) ! tempororary variable for sunlit mr_lsice + real(r8) :: mr_ccliq_day(pcols,pver) ! tempororary variable for sunlit mr_ccliq + real(r8) :: mr_ccice_day(pcols,pver) ! tempororary variable for sunlit mr_ccice + real(r8) :: rain_ls_interp_day(pcols,pver) ! tempororary variable for sunlit rain_ls_interp + real(r8) :: snow_ls_interp_day(pcols,pver) ! tempororary variable for sunlit snow_ls_interp + real(r8) :: grpl_ls_interp_day(pcols,pver) ! tempororary variable for sunlit grpl_ls_interp + real(r8) :: rain_cv_interp_day(pcols,pver) ! tempororary variable for sunlit rain_cv_interp + real(r8) :: snow_cv_interp_day(pcols,pver) ! tempororary variable for sunlit snow_cv_interp + real(r8) :: reff_cosp_day(pcols,pver,nhydro) ! tempororary variable for sunlit reff_cosp(:,:,:) + real(r8) :: dtau_s_day(pcols,pver) ! tempororary variable for sunlit dtau_s + real(r8) :: dtau_c_day(pcols,pver) ! tempororary variable for sunlit dtau_c + real(r8) :: dtau_s_snow_day(pcols,pver) ! tempororary variable for sunlit dtau_s_snow + real(r8) :: dem_s_day(pcols,pver) ! tempororary variable for sunlit dem_s + real(r8) :: dem_c_day(pcols,pver) ! tempororary variable for sunlit dem_c + real(r8) :: dem_s_snow_day(pcols,pver) ! tempororary variable for sunlit dem_s_snow + + ! Constants for optical depth calculation (from radcswmx.F90) + real(r8), parameter :: abarl = 2.817e-02_r8 ! A coefficient for extinction optical depth + real(r8), parameter :: bbarl = 1.305_r8 ! b coefficient for extinction optical depth + real(r8), parameter :: abari = 3.448e-03_r8 ! A coefficient for extinction optical depth + real(r8), parameter :: bbari = 2.431_r8 ! b coefficient for extinction optical depth + real(r8), parameter :: cldmin = 1.0e-80_r8 ! note: cldmin much less than cldmin from cldnrh + real(r8), parameter :: cldeps = 0.0_r8 + + ! Microphysics variables + integer, parameter :: ncnstmax=4 ! number of constituents + character(len=8), dimension(ncnstmax), parameter :: & ! constituent names + cnst_names = (/'CLDLIQ', 'CLDICE','NUMLIQ','NUMICE'/) + integer :: ncnst ! number of constituents (can vary) + integer :: ixcldliq ! cloud liquid amount index for state%q + integer :: ixcldice ! cloud ice amount index + integer :: ixnumliq ! cloud liquid number index + integer :: ixnumice ! cloud ice water index + + ! COSP-related local vars + type(cosp_outputs) :: cospOUT ! COSP simulator outputs + type(cosp_optical_inputs) :: cospIN ! COSP optical (or derived?) fields needed by simulators + type(cosp_column_inputs) :: cospstateIN ! COSP model fields needed by simulators + + ! COSP input variables that depend on CAM + ! 1) Npoints = number of gridpoints COSP will process (without subsetting, Npoints=ncol) + ! 2) Nlevels = number of model levels (Nlevels=pver) + real(r8), parameter :: time = 1.0_r8 ! time ! Time since start of run [days], set to 1 bc running over single CAM timestep + real(r8), parameter :: time_bnds(2)=(/0.5_r8,1.5_r8/) ! time_bnds ! Time boundaries - new in cosp v1.3, set following cosp_test.f90 line 121 + integer :: Npoints ! Number of gridpoints COSP will process + integer :: Nlevels ! Nlevels + logical :: use_reff ! True if effective radius to be used by radar simulator + ! (always used by lidar) + logical :: use_precipitation_fluxes ! True if precipitation fluxes are input to the algorithm + real(r8), parameter :: emsfc_lw = 0.99_r8 ! longwave emissivity of surface at 10.5 microns + ! set value same as in cloudsimulator.F90 + + ! Local vars related to calculations to go from CAM input to COSP input + ! cosp convective value includes both deep and shallow convection + real(r8) :: ptop(pcols,pver) ! top interface pressure (Pa) + real(r8) :: ztop(pcols,pver) ! top interface height asl (m) + real(r8) :: pbot(pcols,pver) ! bottom interface pressure (Pa) + real(r8) :: zbot(pcols,pver) ! bottom interface height asl (m) + real(r8) :: zmid(pcols,pver) ! middle interface height asl (m) + real(r8) :: lat_cosp(pcols) ! lat for cosp (degrees_north) + real(r8) :: lon_cosp(pcols) ! lon for cosp (degrees_east) + real(r8) :: landmask(pcols) ! landmask (0 or 1) + real(r8) :: mr_lsliq(pcols,pver) ! mixing_ratio_large_scale_cloud_liquid (kg/kg) + real(r8) :: mr_lsice(pcols,pver) ! mixing_ratio_large_scale_cloud_ice (kg/kg) + real(r8) :: mr_ccliq(pcols,pver) ! mixing_ratio_convective_cloud_liquid (kg/kg) + real(r8) :: mr_ccice(pcols,pver) ! mixing_ratio_convective_cloud_ice (kg/kg) + real(r8) :: rain_cv(pcols,pverp) ! interface flux_convective_cloud_rain (kg m^-2 s^-1) + real(r8) :: snow_cv(pcols,pverp) ! interface flux_convective_cloud_snow (kg m^-2 s^-1) + real(r8) :: rain_cv_interp(pcols,pver) ! midpoint flux_convective_cloud_rain (kg m^-2 s^-1) + real(r8) :: snow_cv_interp(pcols,pver) ! midpoint flux_convective_cloud_snow (kg m^-2 s^-1) + real(r8) :: grpl_ls_interp(pcols,pver) ! midpoint ls grp flux, should be 0 + real(r8) :: rain_ls_interp(pcols,pver) ! midpoint ls rain flux (kg m^-2 s^-1) + real(r8) :: snow_ls_interp(pcols,pver) ! midpoint ls snow flux + real(r8) :: reff_cosp(pcols,pver,nhydro) ! effective radius for cosp input + real(r8) :: rh(pcols,pver) ! relative_humidity_liquid_water (%) + real(r8) :: es(pcols,pver) ! saturation vapor pressure + real(r8) :: qs(pcols,pver) ! saturation mixing ratio (kg/kg), saturation specific humidity + real(r8) :: cld_swtau(pcols,pver) ! incloud sw tau for input to COSP + real(r8) :: dtau_s(pcols,pver) ! dtau_s - Optical depth of stratiform cloud at 0.67 um + real(r8) :: dtau_c(pcols,pver) ! dtau_c - Optical depth of convective cloud at 0.67 um + real(r8) :: dtau_s_snow(pcols,pver) ! dtau_s_snow - Grid-box mean Optical depth of stratiform snow at 0.67 um + real(r8) :: dem_s(pcols,pver) ! dem_s - Longwave emis of stratiform cloud at 10.5 um + real(r8) :: dem_c(pcols,pver) ! dem_c - Longwave emis of convective cloud at 10.5 um + real(r8) :: dem_s_snow(pcols,pver) ! dem_s_snow - Grid-box mean Optical depth of stratiform snow at 10.5 um + integer :: cam_sunlit(pcols) ! cam_sunlit - Sunlit flag(1-sunlit/0-dark). + integer :: nSunLit,nNoSunLit ! Number of sunlit (not sunlit) scenes. + integer :: rttov_sfcmask(pcols) ! Mask for RTTOV surface type (0=ocean, 1=land, 2=seaice) +! integer :: rttov_sza(pcols) ! Solar Zenith Angle calculated from coszrs ! JKS remove + ! ###################################################################################### + ! Simulator output info + ! ###################################################################################### + integer, parameter :: nf_radar=17 ! number of radar outputs + integer, parameter :: nf_calipso=28 ! number of calipso outputs + integer, parameter :: nf_isccp=9 ! number of isccp outputs + integer, parameter :: nf_misr=1 ! number of misr outputs + integer, parameter :: nf_modis=20 ! number of modis outputs + integer, parameter :: nf_rttov=9 ! JKS - I don't think I can do this so simply. 9 possible outputs + the channel indices? + + ! Cloudsat outputs + character(len=max_fieldname_len),dimension(nf_radar),parameter :: & + fname_radar = (/'CFAD_DBZE94_CS', 'CLD_CAL_NOTCS ', 'DBZE_CS ', & + 'CLDTOT_CALCS ', 'CLDTOT_CS ', 'CLDTOT_CS2 ', & + 'CS_NOPRECIP ', 'CS_RAINPOSS ', 'CS_RAINPROB ', & + 'CS_RAINCERT ', 'CS_SNOWPOSS ', 'CS_SNOWCERT ', & + 'CS_MIXPOSS ', 'CS_MIXCERT ', 'CS_RAINHARD ', & + 'CS_UN ', 'CS_PIA '/)!, 'CAM_MP_CVRAIN ', & + !'CAM_MP_CVSNOW ', 'CAM_MP_LSRAIN ', 'CAM_MP_LSSNOW ', & + !'CAM_MP_LSGRPL '/) + + ! CALIPSO outputs + character(len=max_fieldname_len),dimension(nf_calipso),parameter :: & + fname_calipso=(/'CLDLOW_CAL ','CLDMED_CAL ','CLDHGH_CAL ','CLDTOT_CAL ','CLD_CAL ',& + 'RFL_PARASOL ','CFAD_SR532_CAL ','ATB532_CAL ','MOL532_CAL ','CLD_CAL_LIQ ',& + 'CLD_CAL_ICE ','CLD_CAL_UN ','CLD_CAL_TMP ','CLD_CAL_TMPLIQ ','CLD_CAL_TMPICE ',& + 'CLD_CAL_TMPUN ','CLDTOT_CAL_ICE ','CLDTOT_CAL_LIQ ','CLDTOT_CAL_UN ','CLDHGH_CAL_ICE ',& + 'CLDHGH_CAL_LIQ ','CLDHGH_CAL_UN ','CLDMED_CAL_ICE ','CLDMED_CAL_LIQ ','CLDMED_CAL_UN ',& + 'CLDLOW_CAL_ICE ','CLDLOW_CAL_LIQ ','CLDLOW_CAL_UN '/)!, & +! 'CLDOPQ_CAL ','CLDTHN_CAL ','CLDZOPQ_CAL ','CLDOPQ_CAL_2D ','CLDTHN_CAL_2D ',& +! 'CLDZOPQ_CAL_2D ','OPACITY_CAL_2D ','CLDOPQ_CAL_TMP ','CLDTHN_CAL_TMP ','CLDZOPQ_CAL_TMP',& +! 'CLDOPQ_CAL_Z ','CLDTHN_CAL_Z ','CLDTHN_CAL_EMIS','CLDOPQ_CAL_SE ','CLDTHN_CAL_SE ',& +! 'CLDZOPQ_CAL_SE' /) + ! ISCCP outputs + character(len=max_fieldname_len),dimension(nf_isccp),parameter :: & + fname_isccp=(/'FISCCP1_COSP ','CLDTOT_ISCCP ','MEANCLDALB_ISCCP',& + 'MEANPTOP_ISCCP ','TAU_ISCCP ','CLDPTOP_ISCCP ','MEANTAU_ISCCP ',& + 'MEANTB_ISCCP ','MEANTBCLR_ISCCP '/) + ! MISR outputs + character(len=max_fieldname_len),dimension(nf_misr),parameter :: & + fname_misr=(/'CLD_MISR '/) + ! MODIS outputs + character(len=max_fieldname_len),dimension(nf_modis) :: & + fname_modis=(/'CLTMODIS ','CLWMODIS ','CLIMODIS ','CLHMODIS ','CLMMODIS ',& + 'CLLMODIS ','TAUTMODIS ','TAUWMODIS ','TAUIMODIS ','TAUTLOGMODIS',& + 'TAUWLOGMODIS','TAUILOGMODIS','REFFCLWMODIS','REFFCLIMODIS',& + 'PCTMODIS ','LWPMODIS ','IWPMODIS ','CLMODIS ','CLRIMODIS ',& + 'CLRLMODIS '/) + + character(len=8) :: & + fmt, & ! format descriptor for flexible RTTOV output + i_str + + ! JKS RTTOV outputs? + character(len=max_fieldname_len),dimension(rttov_Ninstruments,nf_rttov) :: & + fname_rttov + + logical :: run_radar(nf_radar,pcols) ! logical telling you if you should run radar simulator + logical :: run_calipso(nf_calipso,pcols) ! logical telling you if you should run calipso simulator + logical :: run_isccp(nf_isccp,pcols) ! logical telling you if you should run isccp simulator + logical :: run_misr(nf_misr,pcols) ! logical telling you if you should run misr simulator + logical :: run_modis(nf_modis,pcols) ! logical telling you if you should run modis simulator + logical :: run_rttov(rttov_Ninstruments,nf_rttov,pcols) ! logical telling you if you should run rttov simulator + + ! CAM pointers to get variables from radiation interface (get from rad_cnst_get_gas) + real(r8), pointer, dimension(:,:) :: q ! specific humidity (kg/kg) + real(r8), pointer, dimension(:,:) :: o3 ! Mass mixing ratio 03 + real(r8), pointer, dimension(:,:) :: co2 ! Mass mixing ratio C02 + real(r8), pointer, dimension(:,:) :: ch4 ! Mass mixing ratio CH4 + real(r8), pointer, dimension(:,:) :: n2o ! Mass mixing ratio N20 + real(r8), pointer, dimension(:,:) :: co ! Mass mixing ratio CO +! real(r8), pointer, dimension(:,:) :: so2 ! Mass mixing ratio SO2 - JKS + + ! CAM pointers to get variables from the physics buffer + real(r8), pointer, dimension(:,:) :: cld ! cloud fraction, tca - total_cloud_amount (0-1) + real(r8), pointer, dimension(:,:) :: concld ! concld fraction, cca - convective_cloud_amount (0-1) + real(r8), pointer, dimension(:,:) :: rel ! liquid effective drop radius (microns) + real(r8), pointer, dimension(:,:) :: rei ! ice effective drop size (microns) + real(r8), pointer, dimension(:,:) :: ls_reffrain ! rain effective drop radius (microns) + real(r8), pointer, dimension(:,:) :: ls_reffsnow ! snow effective drop size (microns) + real(r8), pointer, dimension(:,:) :: cv_reffliq ! convective cld liq effective drop radius (microns) + real(r8), pointer, dimension(:,:) :: cv_reffice ! convective cld ice effective drop size (microns) + + !! precip flux pointers (use for cam4 or cam5) + ! Added pointers; pbuff in zm_conv_intr.F90, calc in zm_conv.F90 + real(r8), pointer, dimension(:,:) :: dp_flxprc ! deep interface gbm flux_convective_cloud_rain+snow (kg m^-2 s^-1) + real(r8), pointer, dimension(:,:) :: dp_flxsnw ! deep interface gbm flux_convective_cloud_snow (kg m^-2 s^-1) + ! More pointers; pbuf in convect_shallow.F90, calc in hk_conv.F90/convect_shallow.F90 (CAM4), uwshcu.F90 (CAM5) + real(r8), pointer, dimension(:,:) :: sh_flxprc ! shallow interface gbm flux_convective_cloud_rain+snow (kg m^-2 s^-1) + real(r8), pointer, dimension(:,:) :: sh_flxsnw ! shallow interface gbm flux_convective_cloud_snow (kg m^-2 s^-1) + ! More pointers; pbuf in stratiform.F90, getting from pbuf here + ! a) added as output to pcond subroutine in cldwat.F90 and to nmicro_pcond subroutine in cldwat2m_micro.F90 + real(r8), pointer, dimension(:,:) :: ls_flxprc ! stratiform interface gbm flux_cloud_rain+snow (kg m^-2 s^-1) + real(r8), pointer, dimension(:,:) :: ls_flxsnw ! stratiform interface gbm flux_cloud_snow (kg m^-2 s^-1) + + !! cloud mixing ratio pointers (note: large-scale in state) + ! More pointers; pbuf in convect_shallow.F90 (cam4) or stratiform.F90 (cam5) + ! calc in hk_conv.F90 (CAM4 should be 0!), uwshcu.F90 but then affected by micro so values from stratiform.F90 (CAM5) + real(r8), pointer, dimension(:,:) :: sh_cldliq ! shallow gbm cloud liquid water (kg/kg) + real(r8), pointer, dimension(:,:) :: sh_cldice ! shallow gbm cloud ice water (kg/kg) + ! More pointers; pbuf in zm_conv_intr.F90, calc in zm_conv.F90, 0 for CAM4 and CAM5 (same convection scheme) + real(r8), pointer, dimension(:,:) :: dp_cldliq ! deep gbm cloud liquid water (kg/kg) + real(r8), pointer, dimension(:,:) :: dp_cldice ! deep gmb cloud ice water (kg/kg) + + ! Surface wind pointers for RTTOV +! real(r8), pointer, dimension(:) :: ubot ! Lowest model level zonal wind +! real(r8), pointer, dimension(:) :: vbot ! Lowest model level meridional wind + + ! Output CAM variables + ! Notes: + ! 1) use pcols (maximum number of columns that code could use, maybe 16) + ! pcols vs. ncol. ncol is the number of columns a chunk is actually using, pcols is maximum number + ! 2) Mixed variables rules/notes, need to collapse because CAM history does not support increased dimensionality + ! MIXED DIMS: ntau_cosp*nprs_cosp, CLOUDSAT_DBZE_BINS*nht_cosp, nsr_cosp*nht_cosp, nscol_cosp*nhtml_cosp, ntau_cosp*nhtmisr_cosp + ! a) always making mixed variables VERTICAL*OTHER, e.g., pressure*tau or ht*dbze + ! b) always collapsing output as V1_1/V2_1...V1_1/V2_N ; V1_2/V2_1 ...V1_2/V2_N etc. to V1_N/V2_1 ... V1_N/V2_N + ! c) here, need vars for both multi-dimensional output from COSP, and two-dimensional output from CAM + ! 3) ntime=1, nprofile=ncol + ! 4) dimensions listed in COSP units are from netcdf output from cosp test case, and are not necessarily in the + ! correct order. In fact, most of them are not as I discovered after trying to run COSP in-line. + ! BE says this could be because FORTRAN and C (netcdf defaults to C) have different conventions. + ! 5) !! Note: after running COSP, it looks like height_mlev is actually the model levels after all!! + real(r8) :: clisccp2(pcols,ntau_cosp,nprs_cosp) ! clisccp2 (time,tau,plev,profile) + real(r8) :: cfad_dbze94(pcols,CLOUDSAT_DBZE_BINS,nht_cosp) ! cfad_dbze94 (time,height,dbze,profile) + real(r8) :: cfad_lidarsr532(pcols,nsr_cosp,nht_cosp) ! cfad_lidarsr532 (time,height,scat_ratio,profile) + real(r8) :: dbze94(pcols,nscol_cosp,nhtml_cosp) ! dbze94 (time,height_mlev,column,profile) + real(r8) :: atb532(pcols,nscol_cosp,nhtml_cosp) ! atb532 (time,height_mlev,column,profile) + real(r8) :: clMISR(pcols,ntau_cosp,nhtmisr_cosp) ! clMISR (time,tau,CTH_height_bin,profile) + real(r8) :: frac_out(pcols,nscol_cosp,nhtml_cosp) ! frac_out (time,height_mlev,column,profile) + real(r8) :: cldtot_isccp(pcols) ! CAM tclisccp (time,profile) + real(r8) :: meancldalb_isccp(pcols) ! CAM albisccp (time,profile) + real(r8) :: meanptop_isccp(pcols) ! CAM ctpisccp (time,profile) + real(r8) :: cldlow_cal(pcols) ! CAM cllcalipso (time,profile) + real(r8) :: cldmed_cal(pcols) ! CAM clmcalipso (time,profile) + real(r8) :: cldhgh_cal(pcols) ! CAM clhcalipso (time,profile) + real(r8) :: cldtot_cal(pcols) ! CAM cltcalipso (time,profile) + real(r8) :: cldtot_cal_ice(pcols) ! CAM (time,profile) !!+cosp1.4 + real(r8) :: cldtot_cal_liq(pcols) ! CAM (time,profile) + real(r8) :: cldtot_cal_un(pcols) ! CAM (time,profile) + real(r8) :: cldhgh_cal_ice(pcols) ! CAM (time,profile) + real(r8) :: cldhgh_cal_liq(pcols) ! CAM (time,profile) + real(r8) :: cldhgh_cal_un(pcols) ! CAM (time,profile) + real(r8) :: cldmed_cal_ice(pcols) ! CAM (time,profile) + real(r8) :: cldmed_cal_liq(pcols) ! CAM (time,profile) + real(r8) :: cldmed_cal_un(pcols) ! CAM (time,profile) + real(r8) :: cldlow_cal_ice(pcols) ! CAM (time,profile) + real(r8) :: cldlow_cal_liq(pcols) ! CAM (time,profile) + real(r8) :: cldlow_cal_un(pcols) ! CAM (time,profile) !+cosp1.4 + real(r8) :: cld_cal(pcols,nht_cosp) ! CAM clcalipso (time,height,profile) + real(r8) :: cld_cal_liq(pcols,nht_cosp) ! CAM (time,height,profile) !+cosp1.4 + real(r8) :: cld_cal_ice(pcols,nht_cosp) ! CAM (time,height,profile) + real(r8) :: cld_cal_un(pcols,nht_cosp) ! CAM (time,height,profile) + real(r8) :: cld_cal_tmp(pcols,nht_cosp) ! CAM (time,height,profile) + real(r8) :: cld_cal_tmpliq(pcols,nht_cosp) ! CAM (time,height,profile) + real(r8) :: cld_cal_tmpice(pcols,nht_cosp) ! CAM (time,height,profile) + real(r8) :: cld_cal_tmpun(pcols,nht_cosp) ! CAM (time,height,profile) !+cosp1.4 +! real(r8) :: cldopaq_cal(pcols) +! real(r8) :: cldthin_cal(pcols) +! real(r8) :: cldopaqz_cal(pcols) +! real(r8) :: cldopaq_cal_temp(pcols) +! real(r8) :: cldthin_cal_temp(pcols) +! real(r8) :: cldzopaq_cal_temp(pcols) +! real(r8) :: cldopaq_cal_z(pcols) +! real(r8) :: cldthin_cal_z(pcols) +! real(r8) :: cldthin_cal_emis(pcols) +! real(r8) :: cldopaq_cal_se(pcols) +! real(r8) :: cldthin_cal_se(pcols) +! real(r8) :: cldzopaq_cal_se(pcols) +! real(r8) :: cldopaq_cal_2d(pcols,nht_cosp) +! real(r8) :: cldthin_cal_2d(pcols,nht_cosp) +! real(r8) :: cldzopaq_cal_2d(pcols,nht_cosp) +! real(r8) :: opacity_cal_2d(pcols,nht_cosp) + real(r8) :: cfad_dbze94_cs(pcols,nht_cosp*CLOUDSAT_DBZE_BINS)! CAM cfad_dbze94 (time,height,dbze,profile) + real(r8) :: cfad_sr532_cal(pcols,nht_cosp*nsr_cosp) ! CAM cfad_lidarsr532 (time,height,scat_ratio,profile) + real(r8) :: tau_isccp(pcols,nscol_cosp) ! CAM boxtauisccp (time,column,profile) + real(r8) :: cldptop_isccp(pcols,nscol_cosp) ! CAM boxptopisccp (time,column,profile) + real(r8) :: meantau_isccp(pcols) ! CAM tauisccp (time,profile) + real(r8) :: meantb_isccp(pcols) ! CAM meantbisccp (time,profile) + real(r8) :: meantbclr_isccp(pcols) ! CAM meantbclrisccp (time,profile) + real(r8) :: dbze_cs(pcols,nhtml_cosp*nscol_cosp) ! CAM dbze94 (time,height_mlev,column,profile) + real(r8) :: cldtot_calcs(pcols) ! CAM cltlidarradar (time,profile) + real(r8) :: cldtot_cs(pcols) ! CAM cltradar (time,profile) + real(r8) :: cldtot_cs2(pcols) ! CAM cltradar2 (time,profile) + real(r8) :: ptcloudsatflag0(pcols) + real(r8) :: ptcloudsatflag1(pcols) + real(r8) :: ptcloudsatflag2(pcols) + real(r8) :: ptcloudsatflag3(pcols) + real(r8) :: ptcloudsatflag4(pcols) + real(r8) :: ptcloudsatflag5(pcols) + real(r8) :: ptcloudsatflag6(pcols) + real(r8) :: ptcloudsatflag7(pcols) + real(r8) :: ptcloudsatflag8(pcols) + real(r8) :: ptcloudsatflag9(pcols) + real(r8) :: cloudsatpia(pcols) + real(r8) :: cld_cal_notcs(pcols,nht_cosp) ! CAM clcalipso2 (time,height,profile) + real(r8) :: atb532_cal(pcols,nhtml_cosp*nscol_cosp) ! CAM atb532 (time,height_mlev,column,profile) + real(r8) :: mol532_cal(pcols,nhtml_cosp) ! CAM beta_mol532 (time,height_mlev,profile) + real(r8) :: cld_misr(pcols,nhtmisr_cosp*ntau_cosp) ! CAM clMISR (time,tau,CTH_height_bin,profile) + real(r8) :: refl_parasol(pcols,nsza_cosp) ! CAM parasol_refl (time,sza,profile) + real(r8) :: scops_out(pcols,nhtml_cosp*nscol_cosp) ! CAM frac_out (time,height_mlev,column,profile) + real(r8) :: cltmodis(pcols) + real(r8) :: clwmodis(pcols) + real(r8) :: climodis(pcols) + real(r8) :: clhmodis(pcols) + real(r8) :: clmmodis(pcols) + real(r8) :: cllmodis(pcols) + real(r8) :: tautmodis(pcols) + real(r8) :: tauwmodis(pcols) + real(r8) :: tauimodis(pcols) + real(r8) :: tautlogmodis(pcols) + real(r8) :: tauwlogmodis(pcols) + real(r8) :: tauilogmodis(pcols) + real(r8) :: reffclwmodis(pcols) + real(r8) :: reffclimodis(pcols) + real(r8) :: pctmodis(pcols) + real(r8) :: lwpmodis(pcols) + real(r8) :: iwpmodis(pcols) + real(r8) :: clmodis_cam(pcols,ntau_cosp_modis*nprs_cosp) + real(r8) :: clmodis(pcols,ntau_cosp_modis,nprs_cosp) + real(r8) :: clrimodis_cam(pcols,ntau_cosp*numMODISReffIceBins) + real(r8) :: clrimodis(pcols,ntau_cosp,numMODISReffIceBins) + real(r8) :: clrlmodis_cam(pcols,ntau_cosp*numMODISReffLiqBins) + real(r8) :: clrlmodis(pcols,ntau_cosp,numMODISReffLiqBins) + !real(r8) :: tau067_out(pcols,nhtml_cosp*nscol_cosp),emis11_out(pcols,nhtml_cosp*nscol_cosp) + real(r8),dimension(pcols,nhtml_cosp*nscol_cosp) :: & + tau067_out,emis11_out,fracliq_out,cal_betatot,cal_betatot_ice, & + cal_betatot_liq,cal_tautot,cal_tautot_ice,cal_tautot_liq,cs_gvol_out,cs_krvol_out,cs_zvol_out,& + asym34_out,ssa34_out + + type(rttov_output_write),dimension(rttov_Ninstruments) :: rttov_outputs_cp + + type(interp_type) :: interp_wgts + integer, parameter :: extrap_method = 1 ! sets extrapolation method to boundary value (1) + + ! COSPv2 stuff + character(len=256),dimension(100) :: cosp_status + integer :: nerror + + ! Variables for determining the time. + integer :: yr, mon, day ! year, month, and day components of a date + integer :: ncsec ! current time of day [seconds] + + ! Create the fname string array for RTTOV + fmt = '(I3.3)' ! an integer of width 3 with zeros at the left + do i=1,rttov_Ninstruments + write (i_str,fmt) i ! converting integer to string i_str using a 'internal file' + do k=1,nf_rttov + fname_rttov(i,:) = (/"rttov_bt_total_inst"//trim(i_str), & + "rttov_bt_clear_inst"//trim(i_str), & + "rttov_rad_total_inst"//trim(i_str), & + "rttov_rad_clear_inst"//trim(i_str), & + "rttov_rad_cloudy_inst"//trim(i_str), & + "rttov_refl_total_inst"//trim(i_str), & + "rttov_refl_clear_inst"//trim(i_str), & + "rttov_btpc_clr_inst"//trim(i_str), & + "rttov_radpc_clr_inst"//trim(i_str) /) + end do + end do + + call t_startf("allocate rttov_outputs_cp") + ! Allocate the DDT for the RTTOV outputs (bleh?) + if (lrttov_sim) then + do i=1,rttov_Ninstruments + rttov_outputs_cp(i) % nchan_out = rttov_configs(i) % nchan_out + ! Only allocate output if the output has been requested? + + if (not(rttov_configs(i) % Lrttov_pc)) then + if (rttov_configs(i) % Lrttov_bt) then + allocate(rttov_outputs_cp(i) % bt_total(pcols,rttov_configs(i) % nchan_out)) + end if + if (rttov_configs(i) % Lrttov_bt .and. ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer))) then + allocate(rttov_outputs_cp(i) % bt_clear(pcols,rttov_configs(i) % nchan_out)) + end if + if (rttov_configs(i) % Lrttov_rad) then + allocate(rttov_outputs_cp(i) % rad_total(pcols,rttov_configs(i) % nchan_out)) + end if + if (rttov_configs(i) % Lrttov_rad .and. ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer))) then + allocate(rttov_outputs_cp(i) % rad_clear(pcols,rttov_configs(i) % nchan_out)) + allocate(rttov_outputs_cp(i) % rad_cloudy(pcols,rttov_configs(i) % nchan_out)) + end if + if (rttov_configs(i) % Lrttov_refl) then + allocate(rttov_outputs_cp(i) % refl_total(pcols,rttov_configs(i) % nchan_out)) + end if + if (rttov_configs(i) % Lrttov_refl .and. ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer))) then + allocate(rttov_outputs_cp(i) % refl_clear(pcols,rttov_configs(i) % nchan_out)) + end if + else + if (rttov_configs(i) % Lrttov_bt) then + allocate(rttov_outputs_cp(i) % bt_total_pc(pcols,rttov_configs(i) % nchan_out)) + end if + if (rttov_configs(i) % Lrttov_rad) then + allocate(rttov_outputs_cp(i) % rad_total_pc(pcols,rttov_configs(i) % nchan_out)) + end if + end if + end do + end if + call t_stopf("allocate rttov_outputs_cp") + + + call t_startf("init_and_stuff") + ! ###################################################################################### + ! Initialization + ! ###################################################################################### + ! Find the chunk and ncol from the state vector + lchnk = state%lchnk ! state variable contains a number of columns, one chunk + ncol = state%ncol ! number of columns in the chunk + + ! Initialize temporary variables as R_UNDEF - need to do this otherwise array expansion puts garbage in history + ! file for columns over which COSP did make calculations. + tmp(1:pcols) = R_UNDEF + tmp1(1:pcols,1:pver) = R_UNDEF + tmp2(1:pcols,1:pver) = R_UNDEF + + ! Initialize CAM variables as R_UNDEF, important for history files because it will exclude these from averages + ! (multi-dimensional output that will be collapsed) + ! initialize over all pcols, not just ncol. missing values needed in chunks where ncol 0.0_r8) .and. (run_cosp(i,lchnk))) then + cam_sunlit(i) = 1 + nSunLit = nSunLit+1 + else + nNoSunLit = nNoSunlit+1 + endif + enddo + endif + call t_stopf("init_and_stuff") + + ! ###################################################################################### + ! ###################################################################################### + ! END TRANSLATE CAM VARIABLES TO COSP INPUT VARIABLES + ! ###################################################################################### + ! ###################################################################################### + + ! ###################################################################################### + ! Construct COSP output derived type. + ! ###################################################################################### + + if (masterproc) then + if (docosp) then + write(iulog,*)'Starting RTTOV construct_cosp_outputs section in cospsimulator_intr_run' + end if + end if + + call t_startf("construct_cosp_outputs") + call construct_cosp_outputs(ncol,nscol_cosp,pver,Nlvgrid,rttov_Ninstruments,rttov_configs,cospOUT) + call t_stopf("construct_cosp_outputs") + print*,'post "construct_cosp_outputs" ' + print*,'associated(cospOUT % rttov_outputs(1) % refl_total): ',associated(cospOUT % rttov_outputs(1) % refl_total) + print*,'associated(cospOUT % rttov_outputs(1) % refl_clear): ',associated(cospOUT % rttov_outputs(1) % refl_clear) + + if (masterproc) then + if (docosp) then + write(iulog,*)'Finished RTTOV construct_cosp_outputs section in cospsimulator_intr_run' + end if + end if + + if (masterproc) then + if (docosp) then + write(iulog,*)'size(ch4): ',size(ch4) + write(iulog,*)'size(n2o): ',size(n2o) + end if + end if + + ! ###################################################################################### + ! Construct and populate COSP input types + ! ###################################################################################### + ! Model state + call t_startf("construct_cospstateIN") + call construct_cospstateIN(ncol,pver,cospstateIN) + cospstateIN%lat = lat_cosp(1:ncol) + cospstateIN%lon = lon_cosp(1:ncol) + cospstateIN%at = state%t(1:ncol,1:pver) + cospstateIN%qv = q(1:ncol,1:pver) + cospstateIN%tca = cld(1:ncol,1:pver) + cospstateIN%o3 = o3(1:ncol,1:pver) + cospstateIN%co2 = co2(1:ncol,1:pver) + cospstateIN%ch4 = ch4(1:ncol,1:pver) + cospstateIN%n2o = n2o(1:ncol,1:pver) + cospstateIN%co = 0._r8 +! For winds take the total 10m wind from cam_in and divide it such that the quadrature sum is the same. + cospstateIN%u_sfc = cam_in%u10(1:ncol) * (2**(-1/2)) + cospstateIN%v_sfc = cam_in%u10(1:ncol) * (2**(-1/2)) + cospstateIN%sunlit = cam_sunlit(1:ncol) + cospstateIN%skt = cam_in%ts(1:ncol) + cospstateIN%land = landmask(1:ncol) ! This is just a 0 or 1 logical. + cospstateIN%pfull = state%pmid(1:ncol,1:pver) + cospstateIN%phalf(1:ncol,1) = 0._r8 + cospstateIN%phalf(1:ncol,2:pver+1) = pbot(1:ncol,pver:1:-1) + cospstateIN%hgt_matrix = zmid(1:ncol,1:pver) + cospstateIN%hgt_matrix_half(1:ncol,1:pver) = zbot(1:ncol,pver:1:-1) + cospstateIN%surfelev(1:ncol) = zbot(1:ncol,1) + + cospstateIN%rttov_sfcmask = rttov_sfcmask(1:ncol) + +! cospstateIN%month(1:ncol) = 1 ! Arbitrary filler for now. +! cospstateIN%time_frac(1:ncol) = 0._r8 ! Arbitrary filler ! Time (UTC) expressed as a fraction on [0,1] + + ! Set time + call get_curr_date(yr, mon, day, ncsec) + +! rttov_sza = acosd(coszrs) + if (masterproc) then + if (docosp) then + write(iulog,*)'ncol: ',ncol + write(iulog,*)'mon: ',mon + write(iulog,*)'ncsec: ',ncsec + write(iulog,*)'coszrs: ',coszrs + write(iulog,*)'shape(coszrs): ',shape(coszrs) +! write(iulog,*)'rttov_sza: ',rttov_sza +! write(iulog,*)'shape(rttov_sza): ',shape(rttov_sza) + write(iulog,*)'shape(cospstateIN%sza): ',shape(cospstateIN%sza) + end if + end if + + ! JKS trying to figure out what is going on. +! if (ncol .ne. size(rttov_sza)) write(iulog,*)'ncol: ',ncol,'size(rttov_sza): ',size(rttov_sza) + + cospstateIN%month(1:ncol) = mon + cospstateIN%time_frac(1:ncol) = ncsec / (86400._r8) ! Seconds/day = 86,400 = 24 * 60 * 60 + + cospstateIN%sza(1:ncol) = acosd(coszrs(1:ncol)) ! Hokey because we get the SZA by taking the arcosine of cos(sza), but this seems to be the variable the radiation scheme can pass. + + if (masterproc) then + if (docosp) then + write(iulog,*)'cospstateIN%month: ',cospstateIN%month + write(iulog,*)'cospstateIN%time_frac: ',cospstateIN%time_frac + write(iulog,*)'coszrs: ',coszrs + write(iulog,*)'cospstateIN%sza: ',cospstateIN%sza + write(iulog,*)'cospstateIN%lat: ',cospstateIN%lat + write(iulog,*)'cospstateIN%lon: ',cospstateIN%lon + end if + end if + + ! JKS + ! Combine large-scale and convective cloud mixing ratios for RTTOV. Could pass in separately for cloud categories + cospstateIN%cloudIce = mr_lsice(1:ncol,1:pver) + mr_ccice(1:ncol,1:pver) + cospstateIN%cloudLiq = mr_lsliq(1:ncol,1:pver) + mr_ccliq(1:ncol,1:pver) + + + ! Combine large-scale and convective cloud effective radii into effective diameters for RTTOV + ! Reff(Npoints,Nlevels,N_HYDRO) + ! The weighted Reff is given by: Reff_net = (M_1 + M_2) / (M_1/Reff_1 + M_2/Reff_2) + cospstateIN%DeffLiq(:,:) = 0._r8 ! Initialize for zero everywhere. + where ((mr_lsliq(1:ncol,1:pver) .gt. 0._r8) .and. (mr_ccliq(1:ncol,1:pver) .gt. 0._r8)) + cospstateIN%DeffLiq(:,:) = 2._r8 * 1.0e6 * (mr_lsliq(1:ncol,1:pver) + mr_ccliq(1:ncol,1:pver)) / (mr_lsliq(1:ncol,1:pver) / reff_cosp(1:ncol,1:pver,I_LSCLIQ) + mr_ccliq(1:ncol,1:pver) / reff_cosp(1:ncol,1:pver,I_CVCLIQ)) + elsewhere (mr_lsliq(1:ncol,1:pver) .gt. 0._r8) + cospstateIN%DeffLiq(:,:) = 2._r8 * 1.0e6 * reff_cosp(1:ncol,1:pver,I_LSCLIQ) + elsewhere (mr_ccliq(:,Nlevels:1:-1) .gt. 0._r8) + cospstateIN%DeffLiq(:,:) = 2._r8 * 1.0e6 * reff_cosp(1:ncol,1:pver,I_CVCLIQ) + end where + + cospstateIN%DeffIce(:,:) = 0._r8 ! Initialize for zero everywhere. + where ((mr_lsice(1:ncol,1:pver) .gt. 0._r8) .and. (mr_ccice(1:ncol,1:pver) .gt. 0._r8)) + cospstateIN%DeffIce(:,:) = 2._r8 * 1.0e6 * (mr_lsice(1:ncol,1:pver) + mr_ccice(1:ncol,1:pver)) / (mr_lsice(1:ncol,1:pver) / reff_cosp(1:ncol,1:pver,I_LSCICE) + mr_ccice(1:ncol,1:pver) / reff_cosp(1:ncol,1:pver,I_CVCICE)) + elsewhere (mr_lsice(1:ncol,1:pver) .gt. 0._r8) + cospstateIN%DeffIce(:,:) = 2._r8 * 1.0e6 * reff_cosp(1:ncol,1:pver,I_LSCICE) + elsewhere (mr_ccice(1:ncol,1:pver) .gt. 0._r8) + cospstateIN%DeffIce(:,:) = 2._r8 * 1.0e6 * reff_cosp(1:ncol,1:pver,I_CVCICE) + end where + + ! RTTOV doesn't consider precip flux, but I think it was used previously. Here for completeness. Could pass in separately for cloud categories. + ! Graupel goes in the snow category, arbitrarily. +! cospstateIN%fl_rain = fl_lsrain(1:ncol,1:pver) + fl_ccrain(1:ncol,1:pver) +! cospstateIN%fl_snow = fl_lssnow(1:ncol,1:pver) + fl_ccsnow(1:ncol,1:pver) + & +! fl_lsgrpl(1:ncol,1:pver) + + ! JKS - this is commented because the cam_in values are not populated + ! 2-meter (ref height) temperature and moisture are optional, so they have to be explicitly allocated if used. +! allocate(cospstateIN%t2m(ncol),cospstateIN%q2m(ncol)) +! cospstateIN%t2m = cam_in%tref(1:ncol) +! cospstateIN%q2m = cam_in%qref(1:ncol) + + + + call t_stopf("construct_cospstateIN") + + if (masterproc) then + if (docosp) then + write(iulog,*)'size(cospstateIN%ch4): ',size(cospstateIN%ch4) + write(iulog,*)'size(cospstateIN%n2o): ',size(cospstateIN%n2o) +! write(iulog,*)'cospstateIN%t2m: ',cospstateIN%t2m +! write(iulog,*)'cospstateIN%q2m: ',cospstateIN%q2m + + write(iulog,*)'cam_in%tref: ',cam_in%tref + write(iulog,*)'cam_in%qref: ',cam_in%qref + write(iulog,*)'cam_in%u10: ',cam_in%u10 + end if + end if + + if (masterproc) then + if (docosp) then + write(iulog,*)'Finished RTTOV construct_cospstateIN section in cospsimulator_intr_run' + end if + end if + + ! Optical inputs + call t_startf("construct_cospIN") + call construct_cospIN(ncol,nscol_cosp,pver,rttov_Ninstruments,cospIN,emis_grey=1.0_r8) ! JKS apply unitary blackbody surface emissivity to be consistent with CESM physics + cospIN%emsfc_lw = emsfc_lw + if (lradar_sim) cospIN%rcfg_cloudsat = rcfg_cs(lchnk) + if (lrttov_sim) cospIN%cfg_rttov => rttov_configs + call t_stopf("construct_cospIN") + + if (masterproc) then + if (docosp) then + write(iulog,*)'Finished RTTOV construct_cospIN section in cospsimulator_intr_run' + end if + end if + + ! *NOTE* Fields passed into subsample_and_optics are ordered from TOA-2-SFC. + if (lradar_sim .or. (llidar_sim .or. (lisccp_sim .or. (lmisr_sim .or. lmodis_sim)))) then ! RTTOV does not use subsample_and_optics + call t_startf("subsample_and_optics") + call subsample_and_optics(ncol,pver,nscol_cosp,nhydro,overlap, & + use_precipitation_fluxes,lidar_ice_type,sd_cs(lchnk),cld(1:ncol,1:pver),& + concld(1:ncol,1:pver),rain_ls_interp(1:ncol,1:pver), & + snow_ls_interp(1:ncol,1:pver),grpl_ls_interp(1:ncol,1:pver), & + rain_cv_interp(1:ncol,1:pver),snow_cv_interp(1:ncol,1:pver), & + mr_lsliq(1:ncol,1:pver),mr_lsice(1:ncol,1:pver), & + mr_ccliq(1:ncol,1:pver),mr_ccice(1:ncol,1:pver), & + reff_cosp(1:ncol,1:pver,:),dtau_c(1:ncol,1:pver), & + dtau_s(1:ncol,1:pver),dem_c(1:ncol,1:pver), & + dem_s(1:ncol,1:pver),dtau_s_snow(1:ncol,1:pver), & + dem_s_snow(1:ncol,1:pver),state%ps(1:ncol),cospstateIN,cospIN) + call t_stopf("subsample_and_optics") + end if + + ! ###################################################################################### + ! Call COSP + ! ###################################################################################### + print*,'pre "COSP_SIMULATOR" ' + print*,'associated(cospOUT % rttov_outputs(1) % refl_total): ',associated(cospOUT % rttov_outputs(1) % refl_total) + print*,'associated(cospOUT % rttov_outputs(1) % refl_clear): ',associated(cospOUT % rttov_outputs(1) % refl_clear) + call t_startf("cosp_simulator") + cosp_status = COSP_SIMULATOR(cospIN, cospstateIN, cospOUT, start_idx=1, stop_idx=ncol,debug=.false.) + +! if (masterproc) then +! if (docosp) then +! write(iulog,*)'ERROR(rttov_simulator): cospIN%Npoints: ',cospIN%Npoints,', cospIN%Nlevels: ',cospIN%Nlevels +! write(iulog,*)'ERROR(rttov_simulator): size(cospstateIN%pfull,2): ',size(cospstateIN%pfull,2) +! write(iulog,*)'ERROR(rttov_simulator): size(cospstateIN%at,2): ',size(cospstateIN%at,2) +! write(iulog,*)'ERROR(rttov_simulator): size(cospstateIN%qv,2): ',size(cospstateIN%qv,2) +! write(iulog,*)'ERROR(rttov_simulator): size(cospstateIN%hgt_matrix_half,2): ',size(cospstateIN%hgt_matrix_half,2) +! write(iulog,*)'ERROR(rttov_simulator): size(cospstateIN%phalf,2): ',size(cospstateIN%phalf,2) +! write(iulog,*)'ERROR(rttov_simulator): cospstateIN%hgt_matrix_half(1,:): ',cospstateIN%hgt_matrix_half(1,:) +! end if +! end if + + ! Check status flags + nerror = 0 + do i = 1, ubound(cosp_status, 1) + if (len_trim(cosp_status(i)) > 0) then + write(iulog,*) "cosp_simulator: ERROR: "//trim(cosp_status(i)) + nerror = nerror + 1 + end if + end do + if (nerror > 0) then + call endrun('cospsimulator_intr_run: error return from cosp_simulator') + end if + call t_stopf("cosp_simulator") + + ! ###################################################################################### + ! Write COSP inputs to output file for offline use. + ! ###################################################################################### + call t_startf("cosp_histfile_aux") + if (cosp_histfile_aux) then + ! 1D outputs + call outfld('PS_COSP', state%ps(1:ncol), ncol,lchnk) + call outfld('TS_COSP', cospstateIN%skt, ncol,lchnk) + + ! 2D outputs + call outfld('P_COSP', cospstateIN%pfull, ncol,lchnk) + call outfld('PH_COSP', cospstateIN%phalf, ncol,lchnk) + call outfld('ZLEV_COSP', cospstateIN%hgt_matrix, ncol,lchnk) + call outfld('ZLEV_HALF_COSP', cospstateIN%hgt_matrix_half, ncol,lchnk) + call outfld('T_COSP', cospstateIN%at, ncol,lchnk) + call outfld('RH_COSP', cospstateIN%qv, ncol,lchnk) + call outfld('Q_COSP', q(1:ncol,1:pver), ncol,lchnk) + + ! 3D outputs, but first compress to 2D + do i=1,ncol + do ihml=1,nhtml_cosp + do isc=1,nscol_cosp + ihsc = (ihml-1)*nscol_cosp+isc + tau067_out(i,ihsc) = cospIN%tau_067(i,isc,ihml) + emis11_out(i,ihsc) = cospIN%emiss_11(i,isc,ihml) + ssa34_out(i,ihsc) = cospIN%ss_alb(i,isc,ihml) + asym34_out(i,ihsc) = cospIN%asym(i,isc,ihml) + fracLiq_out(i,ihsc) = cospIN%fracLiq(i,isc,ihml) + end do + end do + end do + call outfld('TAU_067', tau067_out, pcols,lchnk) + call outfld('EMISS_11', emis11_out, pcols,lchnk) + call outfld('MODIS_asym', asym34_out, pcols,lchnk) + call outfld('MODIS_ssa', ssa34_out, pcols,lchnk) + call outfld('MODIS_fracliq',fracLiq_out,pcols,lchnk) + end if + call t_stopf("cosp_histfile_aux") + + ! ###################################################################################### + ! Set dark-scenes to fill value. Only done for passive simulators and when cosp_runall=F + ! ###################################################################################### + call t_startf("sunlit_passive") + if (.not. cosp_runall) then + ! ISCCP simulator + if (lisccp_sim) then + ! 1D + where(cam_sunlit(1:ncol) .eq. 0) + cospOUT%isccp_totalcldarea(1:ncol) = R_UNDEF + cospOUT%isccp_meanptop(1:ncol) = R_UNDEF + cospOUT%isccp_meantaucld(1:ncol) = R_UNDEF + cospOUT%isccp_meanalbedocld(1:ncol) = R_UNDEF + cospOUT%isccp_meantb(1:ncol) = R_UNDEF + cospOUT%isccp_meantbclr(1:ncol) = R_UNDEF + end where + ! 2D + do i=1,nscol_cosp + where (cam_sunlit(1:ncol) .eq. 0) + cospOUT%isccp_boxtau(1:ncol,i) = R_UNDEF + cospOUT%isccp_boxptop(1:ncol,i) = R_UNDEF + end where + enddo + ! 3D + do i=1,nprs_cosp + do k=1,ntau_cosp + where(cam_sunlit(1:ncol) .eq. 0) + cospOUT%isccp_fq(1:ncol,k,i) = R_UNDEF + end where + end do + end do + endif + + ! MISR simulator + if (lmisr_sim) then + do i=1,nhtmisr_cosp + do k=1,ntau_cosp + where(cam_sunlit(1:ncol) .eq. 0) + cospOUT%misr_fq(1:ncol,k,i) = R_UNDEF + end where + end do + end do + end if + + ! MODIS simulator + if (lmodis_sim) then + ! 1D + where(cam_sunlit(1:ncol) .eq. 0) + cospOUT%modis_Cloud_Fraction_Total_Mean(1:ncol) = R_UNDEF + cospOUT%modis_Cloud_Fraction_Water_Mean(1:ncol) = R_UNDEF + cospOUT%modis_Cloud_Fraction_Ice_Mean(1:ncol) = R_UNDEF + cospOUT%modis_Cloud_Fraction_High_Mean(1:ncol) = R_UNDEF + cospOUT%modis_Cloud_Fraction_Mid_Mean(1:ncol) = R_UNDEF + cospOUT%modis_Cloud_Fraction_Low_Mean(1:ncol) = R_UNDEF + cospOUT%modis_Optical_Thickness_Total_Mean(1:ncol) = R_UNDEF + cospOUT%modis_Optical_Thickness_Water_Mean(1:ncol) = R_UNDEF + cospOUT%modis_Optical_Thickness_Ice_Mean(1:ncol) = R_UNDEF + cospOUT%modis_Optical_Thickness_Total_LogMean(1:ncol) = R_UNDEF + cospOUT%modis_Optical_Thickness_Water_LogMean(1:ncol) = R_UNDEF + cospOUT%modis_Optical_Thickness_Ice_LogMean(1:ncol) = R_UNDEF + cospOUT%modis_Cloud_Particle_Size_Water_Mean(1:ncol) = R_UNDEF + cospOUT%modis_Cloud_Particle_Size_Ice_Mean(1:ncol) = R_UNDEF + cospOUT%modis_Cloud_Top_Pressure_Total_Mean(1:ncol) = R_UNDEF + cospOUT%modis_Liquid_Water_Path_Mean(1:ncol) = R_UNDEF + cospOUT%modis_Ice_Water_Path_Mean(1:ncol) = R_UNDEF + endwhere + ! 3D + do i=1,ntau_cosp_modis + do k=1,nprs_cosp + where(cam_sunlit(1:ncol) .eq. 0) + cospOUT%modis_Optical_Thickness_vs_Cloud_Top_Pressure(1:ncol,i,k) = R_UNDEF + end where + enddo + do k=1,numMODISReffIceBins + where(cam_sunlit(1:ncol) .eq. 0) + cospOUT%modis_Optical_Thickness_vs_ReffICE(1:ncol,i,k) = R_UNDEF + end where + end do + do k=1,numMODISReffLiqBins + where(cam_sunlit(1:ncol) .eq. 0) + cospOUT%modis_Optical_Thickness_vs_ReffLIQ(1:ncol,i,k) = R_UNDEF + end where + enddo + enddo + end if + end if + call t_stopf("sunlit_passive") + + ! ###################################################################################### + ! Copy COSP outputs to CAM fields. + ! ###################################################################################### + call t_startf("output_copying") + if (allocated(cospIN%frac_out)) & + frac_out(1:ncol,1:nscol_cosp,1:nhtml_cosp) = cospIN%frac_out ! frac_out (time,height_mlev,column,profile) + + ! Cloudsat + if (lradar_sim) then + cfad_dbze94(1:ncol,1:CLOUDSAT_DBZE_BINS,1:nht_cosp) = cospOUT%cloudsat_cfad_ze ! cfad_dbze94 (time,height,dbze,profile) + dbze94(1:ncol,1:nscol_cosp,1:nhtml_cosp) = cospOUT%cloudsat_Ze_tot ! dbze94 (time,height_mlev,column,profile) + cldtot_cs(1:ncol) = 0._r8!cospOUT%cloudsat_radar_tcc ! CAM version of cltradar (time,profile) ! NOT COMPUTED IN COSP2 + cldtot_cs2(1:ncol) = 0._r8!cospOUT%cloudsat_radar_tcc2 ! CAM version of cltradar2 (time,profile) ! NOT COMPUTED IN COSP2 + ! *NOTE* These two fields are joint-simulator products, but in CAM they are controlled + ! by the radar simulator control. + cldtot_calcs(1:ncol) = cospOUT%radar_lidar_tcc ! CAM version of cltlidarradar (time,profile) + cld_cal_notcs(1:ncol,1:nht_cosp) = cospOUT%lidar_only_freq_cloud ! CAM version of clcalipso2 (time,height,profile) + + ! Cloudsat near-surface precipitation diagnostics + ptcloudsatflag0(1:ncol) = cospOUT%cloudsat_precip_cover(:,1) + ptcloudsatflag1(1:ncol) = cospOUT%cloudsat_precip_cover(:,2) + ptcloudsatflag2(1:ncol) = cospOUT%cloudsat_precip_cover(:,3) + ptcloudsatflag3(1:ncol) = cospOUT%cloudsat_precip_cover(:,4) + ptcloudsatflag4(1:ncol) = cospOUT%cloudsat_precip_cover(:,5) + ptcloudsatflag5(1:ncol) = cospOUT%cloudsat_precip_cover(:,6) + ptcloudsatflag6(1:ncol) = cospOUT%cloudsat_precip_cover(:,7) + ptcloudsatflag7(1:ncol) = cospOUT%cloudsat_precip_cover(:,8) + ptcloudsatflag8(1:ncol) = cospOUT%cloudsat_precip_cover(:,9) + ptcloudsatflag9(1:ncol) = cospOUT%cloudsat_precip_cover(:,10) + cloudsatpia(1:ncol) = cospOUT%cloudsat_pia + + ! Output the mixing-ratio for all hydrometeor types in Cloudsat near-surface precipitation diagnostics + ! *NOTE* These fields are simply the native CAM mixing-ratios for each hydrometeor type used in the + ! CAM6 microphysics scheme, interpolated to the same vertical grid used by the Cloudsat + ! simulator. These fields are not part of the radar simulator standard output, as these fields + ! are entirely dependent on the host models microphysics, not the retrieval. + + + endif + + ! CALIPSO + if (llidar_sim) then + cldlow_cal(1:ncol) = cospOUT%calipso_cldlayer(:,1) ! CAM version of cllcalipso (time,profile) + cldmed_cal(1:ncol) = cospOUT%calipso_cldlayer(:,2) ! CAM version of clmcalipso (time,profile) + cldhgh_cal(1:ncol) = cospOUT%calipso_cldlayer(:,3) ! CAM version of clhcalipso (time,profile) + cldtot_cal(1:ncol) = cospOUT%calipso_cldlayer(:,4) ! CAM version of cltcalipso (time,profile) + cldlow_cal_ice(1:ncol) = cospOUT%calipso_cldlayerphase(:,1,1) ! CAM version of cllcalipsoice !+cosp1.4 + cldmed_cal_ice(1:ncol) = cospOUT%calipso_cldlayerphase(:,2,1) ! CAM version of clmcalipsoice + cldhgh_cal_ice(1:ncol) = cospOUT%calipso_cldlayerphase(:,3,1) ! CAM version of clhcalipsoice + cldtot_cal_ice(1:ncol) = cospOUT%calipso_cldlayerphase(:,4,1) ! CAM version of cltcalipsoice + cldlow_cal_liq(1:ncol) = cospOUT%calipso_cldlayerphase(:,1,2) ! CAM version of cllcalipsoliq + cldmed_cal_liq(1:ncol) = cospOUT%calipso_cldlayerphase(:,2,2) ! CAM version of clmcalipsoliq + cldhgh_cal_liq(1:ncol) = cospOUT%calipso_cldlayerphase(:,3,2) ! CAM version of clhcalipsoliq + cldtot_cal_liq(1:ncol) = cospOUT%calipso_cldlayerphase(:,4,2) ! CAM version of cltcalipsoliq + cldlow_cal_un(1:ncol) = cospOUT%calipso_cldlayerphase(:,1,3) ! CAM version of cllcalipsoun + cldmed_cal_un(1:ncol) = cospOUT%calipso_cldlayerphase(:,2,3) ! CAM version of clmcalipsoun + cldhgh_cal_un(1:ncol) = cospOUT%calipso_cldlayerphase(:,3,3) ! CAM version of clhcalipsoun + cldtot_cal_un(1:ncol) = cospOUT%calipso_cldlayerphase(:,4,3) ! CAM version of cltcalipsoun, !+cosp1.4 + cld_cal_ice(1:ncol,1:nht_cosp) = cospOUT%calipso_lidarcldphase(:,:,1) ! CAM version of clcalipsoice !+cosp1.4 + cld_cal_liq(1:ncol,1:nht_cosp) = cospOUT%calipso_lidarcldphase(:,:,2) ! CAM version of clcalipsoliq + cld_cal_un(1:ncol,1:nht_cosp) = cospOUT%calipso_lidarcldphase(:,:,3) ! CAM version of clcalipsoun + cld_cal_tmp(1:ncol,1:nht_cosp) = cospOUT%calipso_lidarcldtmp(:,:,1) ! CAM version of clcalipsotmp + cld_cal_tmpliq(1:ncol,1:nht_cosp) = cospOUT%calipso_lidarcldtmp(:,:,2) ! CAM version of clcalipsotmpice + cld_cal_tmpice(1:ncol,1:nht_cosp) = cospOUT%calipso_lidarcldtmp(:,:,3) ! CAM version of clcalipsotmpliq + cld_cal_tmpun(1:ncol,1:nht_cosp) = cospOUT%calipso_lidarcldtmp(:,:,4) ! CAM version of clcalipsotmpun, !+cosp1.4 + cld_cal(1:ncol,1:nht_cosp) = cospOUT%calipso_lidarcld(:,1:nht_cosp) ! CAM version of clcalipso (time,height,profile) + mol532_cal(1:ncol,1:nhtml_cosp) = cospOUT%calipso_beta_mol ! CAM version of beta_mol532 (time,height_mlev,profile) + atb532(1:ncol,1:nscol_cosp,1:nhtml_cosp) = cospOUT%calipso_beta_tot ! atb532 (time,height_mlev,column,profile) + cfad_lidarsr532(1:ncol,1:nsr_cosp,1:nht_cosp) = cospOUT%calipso_cfad_sr(:,:,:) ! cfad_lidarsr532 (time,height,scat_ratio,profile) + ! PARASOL. In COSP2, the Parasol simulator is independent of the calipso simulator. + refl_parasol(1:ncol,1:nsza_cosp) = cospOUT%parasolGrid_refl ! CAM version of parasolrefl (time,sza,profile) + ! CALIPSO Opaque cloud diagnostics +! cldopaq_cal(1:pcols) = cospOUT%calipso_cldtype(:,1) +! cldthin_cal(1:pcols) = cospOUT%calipso_cldtype(:,2) +! cldopaqz_cal(1:pcols) = cospOUT%calipso_cldtype(:,3) +! cldopaq_cal_temp(1:pcols) = cospOUT%calipso_cldtypetemp(:,1) +! cldthin_cal_temp(1:pcols) = cospOUT%calipso_cldtypetemp(:,2) +! cldzopaq_cal_temp(1:pcols) = cospOUT%calipso_cldtypetemp(:,3) +! cldopaq_cal_z(1:pcols) = cospOUT%calipso_cldtypemeanz(:,1) +! cldthin_cal_z(1:pcols) = cospOUT%calipso_cldtypemeanz(:,2) +! cldthin_cal_emis(1:pcols) = cospOUT%calipso_cldthinemis +! cldopaq_cal_se(1:pcols) = cospOUT%calipso_cldtypemeanzse(:,1) +! cldthin_cal_se(1:pcols) = cospOUT%calipso_cldtypemeanzse(:,2) +! cldzopaq_cal_se(1:pcols) = cospOUT%calipso_cldtypemeanzse(:,3) +! cldopaq_cal_2d(1:pcols,1:nht_cosp) = cospOUT%calipso_lidarcldtype(:,:,1) +! cldthin_cal_2d(1:pcols,1:nht_cosp) = cospOUT%calipso_lidarcldtype(:,:,2) +! cldzopaq_cal_2d(1:pcols,1:nht_cosp) = cospOUT%calipso_lidarcldtype(:,:,3) +! opacity_cal_2d(1:pcols,1:nht_cosp) = cospOUT%calipso_lidarcldtype(:,:,4) + endif + + ! ISCCP + if (lisccp_sim) then + clisccp2(1:ncol,1:ntau_cosp,1:nprs_cosp) = cospOUT%isccp_fq ! CAM version of clisccp2 (time,tau,plev,profile) + tau_isccp(1:ncol,1:nscol_cosp) = cospOUT%isccp_boxtau ! CAM version of boxtauisccp (time,column,profile) + cldptop_isccp(1:ncol,1:nscol_cosp) = cospOUT%isccp_boxptop ! CAM version of boxptopisccp (time,column,profile) + cldtot_isccp(1:ncol) = cospOUT%isccp_totalcldarea ! CAM version of tclisccp (time, profile) + meanptop_isccp(1:ncol) = cospOUT%isccp_meanptop ! CAM version of ctpisccp (time, profile) + meantau_isccp(1:ncol) = cospOUT%isccp_meantaucld ! CAM version of meantbisccp (time, profile) + meancldalb_isccp(1:ncol) = cospOUT%isccp_meanalbedocld ! CAM version of albisccp (time, profile) + meantb_isccp(1:ncol) = cospOUT%isccp_meantb ! CAM version of meantbisccp (time, profile) + meantbclr_isccp(1:ncol) = cospOUT%isccp_meantbclr ! CAM version of meantbclrisccp (time, profile) + endif + + ! MISR + if (lmisr_sim) then + clMISR(1:ncol,1:ntau_cosp,1:nhtmisr_cosp) = cospOUT%misr_fq ! CAM version of clMISR (time,tau,CTH_height_bin,profile) + endif + + ! MODIS + if (lmodis_sim) then + cltmodis(1:ncol) = cospOUT%modis_Cloud_Fraction_Total_Mean + clwmodis(1:ncol) = cospOUT%modis_Cloud_Fraction_Water_Mean + climodis(1:ncol) = cospOUT%modis_Cloud_Fraction_Ice_Mean + clhmodis(1:ncol) = cospOUT%modis_Cloud_Fraction_High_Mean + clmmodis(1:ncol) = cospOUT%modis_Cloud_Fraction_Mid_Mean + cllmodis(1:ncol) = cospOUT%modis_Cloud_Fraction_Low_Mean + tautmodis(1:ncol) = cospOUT%modis_Optical_Thickness_Total_Mean + tauwmodis(1:ncol) = cospOUT%modis_Optical_Thickness_Water_Mean + tauimodis(1:ncol) = cospOUT%modis_Optical_Thickness_Ice_Mean + tautlogmodis(1:ncol) = cospOUT%modis_Optical_Thickness_Total_LogMean + tauwlogmodis(1:ncol) = cospOUT%modis_Optical_Thickness_Water_LogMean + tauilogmodis(1:ncol) = cospOUT%modis_Optical_Thickness_Ice_LogMean + reffclwmodis(1:ncol) = cospOUT%modis_Cloud_Particle_Size_Water_Mean + reffclimodis(1:ncol) = cospOUT%modis_Cloud_Particle_Size_Ice_Mean + pctmodis(1:ncol) = cospOUT%modis_Cloud_Top_Pressure_Total_Mean + lwpmodis(1:ncol) = cospOUT%modis_Liquid_Water_Path_Mean + iwpmodis(1:ncol) = cospOUT%modis_Ice_Water_Path_Mean + clmodis(1:ncol,1:ntau_cosp_modis,1:nprs_cosp) = cospOUT%modis_Optical_Thickness_vs_Cloud_Top_Pressure + clrimodis(1:ncol,1:ntau_cosp_modis,1:numMODISReffIceBins) = cospOUT%modis_Optical_Thickness_vs_ReffICE + clrlmodis(1:ncol,1:ntau_cosp_modis,1:numMODISReffLiqBins) = cospOUT%modis_Optical_Thickness_vs_ReffLIQ + endif + + if (masterproc) then + if (docosp) then + write(iulog,*)'Reached writing RTTOV section in cospsimulator_intr_run' + write(iulog,*)'lrttov_sim: ', lrttov_sim + end if + end if + + ! RTTOV + if (lrttov_sim) then + do i=1,rttov_Ninstruments ! Not sure if this logical stuff is needed or not? + if (rttov_configs(i) % Lrttov_pc) then + if (rttov_configs(i) % Lrttov_bt) then + rttov_outputs_cp(i) % bt_total_pc(1:ncol,1:rttov_outputs_cp(i) % nchan_out) = cospOUT % rttov_outputs(i) % bt_total_pc + end if + if (rttov_configs(i) % Lrttov_rad) then + rttov_outputs_cp(i) % rad_total_pc(1:ncol,1:rttov_outputs_cp(i) % nchan_out) = cospOUT % rttov_outputs(i) % rad_total_pc + end if + else + if (rttov_configs(i) % Lrttov_bt) then + rttov_outputs_cp(i) % bt_total(1:ncol,1:rttov_outputs_cp(i) % nchan_out) = cospOUT % rttov_outputs(i) % bt_total + if ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer)) then + rttov_outputs_cp(i) % bt_clear(1:ncol,1:rttov_outputs_cp(i) % nchan_out) = cospOUT % rttov_outputs(i) % bt_clear + end if + end if + if (rttov_configs(i) % Lrttov_rad) then + rttov_outputs_cp(i) % rad_total(1:ncol,1:rttov_outputs_cp(i) % nchan_out) = cospOUT % rttov_outputs(i) % rad_total + if ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer)) then + rttov_outputs_cp(i) % rad_clear(1:ncol,1:rttov_outputs_cp(i) % nchan_out) = cospOUT % rttov_outputs(i) % rad_clear + rttov_outputs_cp(i) % rad_cloudy(1:ncol,1:rttov_outputs_cp(i) % nchan_out) = cospOUT % rttov_outputs(i) % rad_cloudy + end if + end if + if (rttov_configs(i) % Lrttov_refl) then + rttov_outputs_cp(i) % refl_total(1:ncol,1:rttov_outputs_cp(i) % nchan_out) = cospOUT % rttov_outputs(i) % refl_total + if ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer)) then + rttov_outputs_cp(i) % refl_clear(1:ncol,1:rttov_outputs_cp(i) % nchan_out) = cospOUT % rttov_outputs(i) % refl_clear + end if + end if + end if + end do + endif + + if (masterproc) then + if (docosp) then + write(iulog,*)'Finished writing RTTOV section in cospsimulator_intr_run' + write(iulog,*)'lrttov_sim: ', lrttov_sim + end if + end if + + ! Use high-dimensional output to populate CAM collapsed output variables + ! see above for mixed dimension definitions + ! i am using the convention of starting vertical coordinates at the surface, up to down, COSP convention, not CAM. + do i=1,ncol + if (lradar_sim) then + ! CAM cfad_dbze94 (time,height,dbze,profile) + do ih=1,nht_cosp + do id=1,CLOUDSAT_DBZE_BINS + ihd=(ih-1)*CLOUDSAT_DBZE_BINS+id + cfad_dbze94_cs(i,ihd) = cfad_dbze94(i,id,ih) ! cfad_dbze94_cs(pcols,nht_cosp*CLOUDSAT_DBZE_BINS) + end do + end do + ! CAM dbze94 (time,height_mlev,column,profile) + do ihml=1,nhtml_cosp + do isc=1,nscol_cosp + ihsc=(ihml-1)*nscol_cosp+isc + dbze_cs(i,ihsc) = dbze94(i,isc,ihml) ! dbze_cs(pcols,pver*nscol_cosp) + end do + end do + endif + + if (llidar_sim) then + ! CAM cfad_lidarsr532 (time,height,scat_ratio,profile) + do ih=1,nht_cosp + do is=1,nsr_cosp + ihs=(ih-1)*nsr_cosp+is + cfad_sr532_cal(i,ihs) = cfad_lidarsr532(i,is,ih) ! cfad_sr532_cal(pcols,nht_cosp*nsr_cosp) + end do + end do + ! CAM atb532 (time,height_mlev,column,profile) FIX + do ihml=1,nhtml_cosp + do isc=1,nscol_cosp + ihsc=(ihml-1)*nscol_cosp+isc + atb532_cal(i,ihsc) = atb532(i,isc,ihml) ! atb532_cal(pcols,nht_cosp*nscol_cosp) + end do + end do + endif + + if (lmisr_sim) then + ! CAM clMISR (time,tau,CTH_height_bin,profile) + do ihm=1,nhtmisr_cosp + do it=1,ntau_cosp + ihmt=(ihm-1)*ntau_cosp+it + cld_misr(i,ihmt) = clMISR(i,it,ihm) + end do + end do + endif + + if (lmodis_sim) then + ! CAM clmodis + do ip=1,nprs_cosp + do it=1,ntau_cosp_modis + ipt=(ip-1)*ntau_cosp_modis+it + clmodis_cam(i,ipt) = clmodis(i,it,ip) + end do + end do + ! CAM clrimodis + do ip=1,numMODISReffIceBins + do it=1,ntau_cosp_modis + ipt=(ip-1)*ntau_cosp_modis+it + clrimodis_cam(i,ipt) = clrimodis(i,it,ip) + end do + end do + ! CAM clrlmodis + do ip=1,numMODISReffLiqBins + do it=1,ntau_cosp_modis + ipt=(ip-1)*ntau_cosp_modis+it + clrlmodis_cam(i,ipt) = clrlmodis(i,it,ip) + end do + end do + endif + + ! Subcolums + do ihml=1,nhtml_cosp + do isc=1,nscol_cosp + ihsc=(ihml-1)*nscol_cosp+isc + scops_out(i,ihsc) = frac_out(i,isc,ihml) ! scops_out(pcols,nht_cosp*nscol_cosp) + end do + end do + end do + call t_stopf("output_copying") + + ! ###################################################################################### + ! Clean up + ! ###################################################################################### + +! call t_startf("rttov_cleanup") +! call rttov_cleanup(cospIN) ! Just break things to get diagnostics. Not really code. - JKS +! call t_stopf("rttov_cleanup") + call t_startf("destroy_cospIN") + call destroy_cospIN(cospIN) + call t_stopf("destroy_cospIN") + call t_startf("destroy_cospstateIN") + call destroy_cospstateIN(cospstateIN) + call t_stopf("destroy_cospstateIN") + call t_startf("destroy_cospOUT") + call destroy_cosp_outputs(cospOUT) + call t_stopf("destroy_cospOUT") + + ! ###################################################################################### + ! OUTPUT + ! ###################################################################################### + call t_startf("writing_output") + ! ISCCP OUTPUTS + if (lisccp_sim) then + call outfld('FISCCP1_COSP',clisccp2, pcols,lchnk) + call outfld('CLDTOT_ISCCP',cldtot_isccp, pcols,lchnk) + !! weight meancldalb_isccp by the cloud fraction + !! where there is no isccp cloud fraction, set meancldalb_isccp = R_UNDEF + !! weight meanptop_isccp by the cloud fraction + !! where there is no isccp cloud fraction, set meanptop_isccp = R_UNDEF + !! weight meantau_isccp by the cloud fraction + !! where there is no isccp cloud fraction, set meantau_isccp = R_UNDEF + where (cldtot_isccp(:ncol) .eq. R_UNDEF) + meancldalb_isccp(:ncol) = R_UNDEF + meanptop_isccp(:ncol) = R_UNDEF + meantau_isccp(:ncol) = R_UNDEF + elsewhere + meancldalb_isccp(:ncol) = meancldalb_isccp(:ncol)*cldtot_isccp(:ncol) + meanptop_isccp(:ncol) = meanptop_isccp(:ncol)*cldtot_isccp(:ncol) + meantau_isccp(:ncol) = meantau_isccp(:ncol)*cldtot_isccp(:ncol) + end where + call outfld('MEANCLDALB_ISCCP',meancldalb_isccp,pcols,lchnk) + call outfld('MEANPTOP_ISCCP', meanptop_isccp, pcols,lchnk) + call outfld('MEANTAU_ISCCP', meantau_isccp, pcols,lchnk) + call outfld('MEANTB_ISCCP', meantb_isccp, pcols,lchnk) + call outfld('MEANTBCLR_ISCCP', meantbclr_isccp, pcols,lchnk) + end if + + ! CALIPSO SIMULATOR OUTPUTS + if (llidar_sim) then + call outfld('CLDLOW_CAL', cldlow_cal, pcols,lchnk) + call outfld('CLDMED_CAL', cldmed_cal, pcols,lchnk) + call outfld('CLDHGH_CAL', cldhgh_cal, pcols,lchnk) + call outfld('CLDTOT_CAL', cldtot_cal, pcols,lchnk) + call outfld('CLDTOT_CAL_ICE',cldtot_cal_ice, pcols,lchnk) !+1.4 + call outfld('CLDTOT_CAL_LIQ',cldtot_cal_liq, pcols,lchnk) + call outfld('CLDTOT_CAL_UN', cldtot_cal_un, pcols,lchnk) + call outfld('CLDHGH_CAL_ICE',cldhgh_cal_ice, pcols,lchnk) + call outfld('CLDHGH_CAL_LIQ',cldhgh_cal_liq, pcols,lchnk) + call outfld('CLDHGH_CAL_UN', cldhgh_cal_un, pcols,lchnk) + call outfld('CLDMED_CAL_ICE',cldmed_cal_ice, pcols,lchnk) + call outfld('CLDMED_CAL_LIQ',cldmed_cal_liq, pcols,lchnk) + call outfld('CLDMED_CAL_UN', cldmed_cal_un, pcols,lchnk) + call outfld('CLDLOW_CAL_ICE',cldlow_cal_ice, pcols,lchnk) + call outfld('CLDLOW_CAL_LIQ',cldlow_cal_liq, pcols,lchnk) + call outfld('CLDLOW_CAL_UN', cldlow_cal_un, pcols,lchnk) !+1.4 + where (cld_cal(:ncol,:nht_cosp) .eq. R_UNDEF) + !! setting missing values to 0 (clear air). + !! I'm not sure why COSP produces a mix of R_UNDEF and realvalue in the nht_cosp dimension. + cld_cal(:ncol,:nht_cosp) = 0.0_r8 + end where + call outfld('CLD_CAL', cld_cal, pcols,lchnk) !! fails check_accum if 'A' + call outfld('MOL532_CAL', mol532_cal, pcols,lchnk) + + where (cfad_sr532_cal(:ncol,:nht_cosp*nsr_cosp) .eq. R_UNDEF) + !! fails check_accum if this is set... with ht_cosp set relative to sea level, mix of R_UNDEF and realvalue + !! cfad_sr532_cal(:ncol,:nht_cosp*nsr_cosp) = R_UNDEF + cfad_sr532_cal(:ncol,:nht_cosp*nsr_cosp) = 0.0_r8 + end where + call outfld('CFAD_SR532_CAL',cfad_sr532_cal ,pcols,lchnk) + + where (refl_parasol(:ncol,:nsza_cosp) .eq. R_UNDEF) + !! setting missing values to 0 (clear air). + refl_parasol(:ncol,:nsza_cosp) = 0 + end where + call outfld('RFL_PARASOL',refl_parasol ,pcols,lchnk) !! + + where (cld_cal_liq(:ncol,:nht_cosp) .eq. R_UNDEF) !+cosp1.4 + !! setting missing values to 0 (clear air), likely below sea level + cld_cal_liq(:ncol,:nht_cosp) = 0.0_r8 + end where + call outfld('CLD_CAL_LIQ',cld_cal_liq ,pcols,lchnk) !! + + where (cld_cal_ice(:ncol,:nht_cosp) .eq. R_UNDEF) + !! setting missing values to 0 (clear air), likely below sea level + cld_cal_ice(:ncol,:nht_cosp) = 0.0_r8 + end where + call outfld('CLD_CAL_ICE',cld_cal_ice ,pcols,lchnk) !! + + where (cld_cal_un(:ncol,:nht_cosp) .eq. R_UNDEF) + !! setting missing values to 0 (clear air), likely below sea level + cld_cal_un(:ncol,:nht_cosp) = 0.0_r8 + end where + call outfld('CLD_CAL_UN',cld_cal_un ,pcols,lchnk) !! + + where (cld_cal_tmp(:ncol,:nht_cosp) .eq. R_UNDEF) + !! setting missing values to 0 (clear air), likely below sea level + cld_cal_tmp(:ncol,:nht_cosp) = 0.0_r8 + end where + call outfld('CLD_CAL_TMP',cld_cal_tmp ,pcols,lchnk) !! + + where (cld_cal_tmpliq(:ncol,:nht_cosp) .eq. R_UNDEF) + !! setting missing values to 0 (clear air), likely below sea level + cld_cal_tmpliq(:ncol,:nht_cosp) = 0.0_r8 + end where + call outfld('CLD_CAL_TMPLIQ',cld_cal_tmpliq ,pcols,lchnk) !! + + where (cld_cal_tmpice(:ncol,:nht_cosp) .eq. R_UNDEF) + !! setting missing values to 0 (clear air), likely below sea level + cld_cal_tmpice(:ncol,:nht_cosp) = 0.0_r8 + end where + call outfld('CLD_CAL_TMPICE',cld_cal_tmpice ,pcols,lchnk) !! + + where (cld_cal_tmpun(:ncol,:nht_cosp) .eq. R_UNDEF) + !! setting missing values to 0 (clear air), likely below sea level + cld_cal_tmpun(:ncol,:nht_cosp) = 0.0_r8 + end where + call outfld('CLD_CAL_TMPUN',cld_cal_tmpun ,pcols,lchnk) !! !+cosp1.4 + + ! Opaque cloud diagnostics +! call outfld('CLDOPQ_CAL', cldopaq_cal, pcols, lchnk) +! call outfld('CLDTHN_CAL', cldthin_cal, pcols, lchnk) +! call outfld('CLDZOPQ_CAL', cldopaqz_cal, pcols, lchnk) +! call outfld('CLDOPQ_CAL_TMP', cldopaq_cal_temp, pcols, lchnk) +! call outfld('CLDTHN_CAL_TMP', cldthin_cal_temp, pcols, lchnk) +! call outfld('CLDZOPQ_CAL_TMP', cldzopaq_cal_temp, pcols, lchnk) +! call outfld('CLDOPQ_CAL_Z', cldopaq_cal_z, pcols, lchnk) +! call outfld('CLDTHN_CAL_Z', cldthin_cal_z, pcols, lchnk) +! call outfld('CLDTHN_CAL_EMIS', cldthin_cal_emis, pcols, lchnk) +! call outfld('CLDOPQ_CAL_SE', cldopaq_cal_se, pcols, lchnk) +! call outfld('CLDTHN_CAL_SE', cldthin_cal_se, pcols, lchnk) +! call outfld('CLDZOPQ_CAL_SE', cldzopaq_cal_se, pcols, lchnk) +! ! +! where (cldopaq_cal_2d(:ncol,:nht_cosp) .eq. R_UNDEF) +! cldopaq_cal_2d(:ncol,:nht_cosp) = 0.0_r8 +! end where +! call outfld('CLDOPQ_CAL_2D', cldopaq_cal_2d, pcols, lchnk) +! ! +! where (cldthin_cal_2d(:ncol,:nht_cosp) .eq. R_UNDEF) +! cldthin_cal_2d(:ncol,:nht_cosp) = 0.0_r8 +! end where +! call outfld('CLDTHN_CAL_2D', cldthin_cal_2d, pcols, lchnk) +! ! +! where (cldzopaq_cal_2d(:ncol,:nht_cosp) .eq. R_UNDEF) +! cldzopaq_cal_2d(:ncol,:nht_cosp) = 0.0_r8 +! end where +! call outfld('CLDZOPQ_CAL_2D', cldzopaq_cal_2d, pcols, lchnk) +! ! +! where (opacity_cal_2d(:ncol,:nht_cosp) .eq. R_UNDEF) +! opacity_cal_2d(:ncol,:nht_cosp) = 0.0_r8 +! end where +! call outfld('OPACITY_CAL_2D', opacity_cal_2d, pcols, lchnk) + + end if + + ! RADAR SIMULATOR OUTPUTS + if (lradar_sim) then + where (cfad_dbze94_cs(:ncol,:nht_cosp*CLOUDSAT_DBZE_BINS) .eq. R_UNDEF) + !! fails check_accum if this is set... with ht_cosp set relative to sea level, mix of R_UNDEF and realvalue + ! cfad_dbze94_cs(:ncol,:nht_cosp*CLOUDSAT_DBZE_BINS) = R_UNDEF + cfad_dbze94_cs(:ncol,:nht_cosp*CLOUDSAT_DBZE_BINS) = 0.0_r8 + end where + call outfld('CFAD_DBZE94_CS',cfad_dbze94_cs, pcols, lchnk) + call outfld('CLDTOT_CALCS', cldtot_calcs, pcols, lchnk) + call outfld('CLDTOT_CS', cldtot_cs, pcols, lchnk) + call outfld('CLDTOT_CS2', cldtot_cs2, pcols, lchnk) + call outfld('CLD_CAL_NOTCS', cld_cal_notcs, pcols, lchnk) + call outfld('CS_NOPRECIP', ptcloudsatflag0, pcols, lchnk) + call outfld('CS_RAINPOSS', ptcloudsatflag1, pcols, lchnk) + call outfld('CS_RAINPROB', ptcloudsatflag2, pcols, lchnk) + call outfld('CS_RAINCERT', ptcloudsatflag3, pcols, lchnk) + call outfld('CS_SNOWPOSS', ptcloudsatflag4, pcols, lchnk) + call outfld('CS_SNOWCERT', ptcloudsatflag5, pcols, lchnk) + call outfld('CS_MIXPOSS', ptcloudsatflag6, pcols, lchnk) + call outfld('CS_MIXCERT', ptcloudsatflag7, pcols, lchnk) + call outfld('CS_RAINHARD', ptcloudsatflag8, pcols, lchnk) + call outfld('CS_UN', ptcloudsatflag9, pcols, lchnk) + call outfld('CS_PIA', cloudsatpia, pcols, lchnk) + end if + + ! MISR SIMULATOR OUTPUTS + if (lmisr_sim) then + call outfld('CLD_MISR',cld_misr ,pcols,lchnk) + end if + + ! MODIS SIMULATOR OUTPUTS + if (lmodis_sim) then + call outfld('CLTMODIS',cltmodis ,pcols,lchnk) + call outfld('CLWMODIS',clwmodis ,pcols,lchnk) + call outfld('CLIMODIS',climodis ,pcols,lchnk) + call outfld('CLHMODIS',clhmodis ,pcols,lchnk) + call outfld('CLMMODIS',clmmodis ,pcols,lchnk) + call outfld('CLLMODIS',cllmodis ,pcols,lchnk) + + !! where there is no cloud fraction or no retrieval, set to R_UNDEF, + !! otherwise weight retrieval by cloud fraction + where ((cltmodis(:ncol) .eq. R_UNDEF) .or. (tautmodis(:ncol) .eq. R_UNDEF)) + tautmodis(:ncol) = R_UNDEF + elsewhere + !! weight by the cloud fraction cltmodis + tautmodis(:ncol) = tautmodis(:ncol)*cltmodis(:ncol) + end where + call outfld('TAUTMODIS',tautmodis ,pcols,lchnk) + + where ((tauwmodis(:ncol) .eq. R_UNDEF) .or. (clwmodis(:ncol) .eq. R_UNDEF)) + tauwmodis(:ncol) = R_UNDEF + elsewhere + !! weight by the cloud fraction clwmodis + tauwmodis(:ncol) = tauwmodis(:ncol)*clwmodis(:ncol) + end where + call outfld('TAUWMODIS',tauwmodis ,pcols,lchnk) + + where ((tauimodis(:ncol) .eq. R_UNDEF) .or. (climodis(:ncol) .eq. R_UNDEF)) + tauimodis(:ncol) = R_UNDEF + elsewhere + !! weight by the cloud fraction climodis + tauimodis(:ncol) = tauimodis(:ncol)*climodis(:ncol) + end where + call outfld('TAUIMODIS',tauimodis ,pcols,lchnk) + + where ((tautlogmodis(:ncol) .eq. R_UNDEF) .or. (cltmodis(:ncol) .eq. R_UNDEF)) + tautlogmodis(:ncol) = R_UNDEF + elsewhere + !! weight by the cloud fraction cltmodis + tautlogmodis(:ncol) = tautlogmodis(:ncol)*cltmodis(:ncol) + end where + call outfld('TAUTLOGMODIS',tautlogmodis ,pcols,lchnk) + + where ((tauwlogmodis(:ncol) .eq. R_UNDEF) .or. (clwmodis(:ncol) .eq. R_UNDEF)) + tauwlogmodis(:ncol) = R_UNDEF + elsewhere + !! weight by the cloud fraction clwmodis + tauwlogmodis(:ncol) = tauwlogmodis(:ncol)*clwmodis(:ncol) + end where + call outfld('TAUWLOGMODIS',tauwlogmodis ,pcols,lchnk) + + where ((tauilogmodis(:ncol) .eq. R_UNDEF) .or. (climodis(:ncol) .eq. R_UNDEF)) + tauilogmodis(:ncol) = R_UNDEF + elsewhere + !! weight by the cloud fraction climodis + tauilogmodis(:ncol) = tauilogmodis(:ncol)*climodis(:ncol) + end where + call outfld('TAUILOGMODIS',tauilogmodis ,pcols,lchnk) + + where ((reffclwmodis(:ncol) .eq. R_UNDEF) .or. (clwmodis(:ncol) .eq. R_UNDEF)) + reffclwmodis(:ncol) = R_UNDEF + elsewhere + !! weight by the cloud fraction clwmodis + reffclwmodis(:ncol) = reffclwmodis(:ncol)*clwmodis(:ncol) + end where + call outfld('REFFCLWMODIS',reffclwmodis ,pcols,lchnk) + + where ((reffclimodis(:ncol) .eq. R_UNDEF) .or. (climodis(:ncol) .eq. R_UNDEF)) + reffclimodis(:ncol) = R_UNDEF + elsewhere + !! weight by the cloud fraction climodis + reffclimodis(:ncol) = reffclimodis(:ncol)*climodis(:ncol) + end where + call outfld('REFFCLIMODIS',reffclimodis ,pcols,lchnk) + + where ((pctmodis(:ncol) .eq. R_UNDEF) .or. ( cltmodis(:ncol) .eq. R_UNDEF)) + pctmodis(:ncol) = R_UNDEF + elsewhere + !! weight by the cloud fraction cltmodis + pctmodis(:ncol) = pctmodis(:ncol)*cltmodis(:ncol) + end where + call outfld('PCTMODIS',pctmodis ,pcols,lchnk) + + where ((lwpmodis(:ncol) .eq. R_UNDEF) .or. (clwmodis(:ncol) .eq. R_UNDEF)) + lwpmodis(:ncol) = R_UNDEF + elsewhere + !! weight by the cloud fraction clwmodis + lwpmodis(:ncol) = lwpmodis(:ncol)*clwmodis(:ncol) + end where + call outfld('LWPMODIS',lwpmodis ,pcols,lchnk) + + where ((iwpmodis(:ncol) .eq. R_UNDEF) .or. (climodis(:ncol) .eq. R_UNDEF)) + iwpmodis(:ncol) = R_UNDEF + elsewhere + !! weight by the cloud fraction climodis + iwpmodis(:ncol) = iwpmodis(:ncol)*climodis(:ncol) + end where + call outfld('IWPMODIS',iwpmodis ,pcols,lchnk) + + call outfld('CLMODIS',clmodis_cam ,pcols,lchnk) + call outfld('CLRIMODIS',clrimodis_cam ,pcols,lchnk) + call outfld('CLRLMODIS',clrlmodis_cam ,pcols,lchnk) + end if + + if (masterproc) then + if (docosp) then + write(iulog,*)'Reached outfld RTTOV section in cospsimulator_intr_run' + write(iulog,*)'lrttov_sim: ', lrttov_sim + end if + end if + + ! RTTOV + if (lrttov_sim) then + do i=1,rttov_Ninstruments + write (i_str,fmt) i ! converting integer to string i_str using a 'internal file' + if (rttov_configs(i) % Lrttov_pc) then + if (rttov_configs(i) % Lrttov_bt) then + call outfld("rttov_btpc_clr_inst"//trim(i_str),rttov_outputs_cp(i) % bt_total_pc,pcols,lchnk) + end if + if (rttov_configs(i) % Lrttov_rad) then + call outfld("rttov_radpc_clr_inst"//trim(i_str),rttov_outputs_cp(i) % rad_total_pc,pcols,lchnk) + end if + else + if (rttov_configs(i) % Lrttov_bt) then + call outfld("rttov_bt_total_inst"//trim(i_str),rttov_outputs_cp(i) % bt_total,pcols,lchnk) + if ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer)) then + call outfld("rttov_bt_clear_inst"//trim(i_str),rttov_outputs_cp(i) % bt_clear,pcols,lchnk) + end if + end if + if (rttov_configs(i) % Lrttov_rad) then + call outfld("rttov_rad_total_inst"//trim(i_str),rttov_outputs_cp(i) % rad_total,pcols,lchnk) + if ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer)) then + call outfld("rttov_rad_clear_inst"//trim(i_str),rttov_outputs_cp(i) % rad_clear,pcols,lchnk) + call outfld("rttov_rad_cloudy_inst"//trim(i_str),rttov_outputs_cp(i) % rad_cloudy,pcols,lchnk) + end if + end if + if (rttov_configs(i) % Lrttov_refl) then + call outfld("rttov_refl_total_inst"//trim(i_str),rttov_outputs_cp(i) % refl_total,pcols,lchnk) + if ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer)) then + call outfld("rttov_refl_clear_inst"//trim(i_str),rttov_outputs_cp(i) % refl_clear,pcols,lchnk) + end if + end if + end if + end do + endif + + ! Deallocate the DDT for the RTTOV outputs + do i=1,rttov_Ninstruments + if (allocated(rttov_outputs_cp(i) % bt_total)) deallocate(rttov_outputs_cp(i) % bt_total) + if (allocated(rttov_outputs_cp(i) % bt_clear)) deallocate(rttov_outputs_cp(i) % bt_clear) + if (allocated(rttov_outputs_cp(i) % rad_total)) deallocate(rttov_outputs_cp(i) % rad_total) + if (allocated(rttov_outputs_cp(i) % rad_clear)) deallocate(rttov_outputs_cp(i) % rad_clear) + if (allocated(rttov_outputs_cp(i) % rad_cloudy)) deallocate(rttov_outputs_cp(i) % rad_cloudy) + if (allocated(rttov_outputs_cp(i) % refl_total)) deallocate(rttov_outputs_cp(i) % refl_total) + if (allocated(rttov_outputs_cp(i) % refl_clear)) deallocate(rttov_outputs_cp(i) % refl_clear) + if (allocated(rttov_outputs_cp(i) % bt_total_pc)) deallocate(rttov_outputs_cp(i) % bt_total_pc) + if (allocated(rttov_outputs_cp(i) % rad_total_pc)) deallocate(rttov_outputs_cp(i) % rad_total_pc) + end do + + if (masterproc) then + if (docosp) then + write(iulog,*)'Finished outfld RTTOV section in cospsimulator_intr_run' + write(iulog,*)'lrttov_sim: ', lrttov_sim + end if + end if + + ! SUB-COLUMN OUTPUT + if (lfrac_out) then + call outfld('SCOPS_OUT',scops_out ,pcols,lchnk)!!!-1.00000E+30 !! fails check_accum if 'A' + if (lisccp_sim) then + call outfld('TAU_ISCCP', tau_isccp, pcols,lchnk) !! fails check_accum if 'A' + call outfld('CLDPTOP_ISCCP',cldptop_isccp,pcols,lchnk) !! fails check_accum if 'A' + end if + if (llidar_sim) then + call outfld('ATB532_CAL',atb532_cal,pcols,lchnk) !! fails check_accum if 'A' + end if + if (lradar_sim) then + call outfld('DBZE_CS',dbze_cs,pcols,lchnk) !! fails check_accum if 'A' + end if + end if + call t_stopf("writing_output") +#endif + end subroutine cospsimulator_intr_run + +#ifdef USE_COSP + ! ###################################################################################### + ! SUBROUTINE subsample_and_optics + ! ###################################################################################### + subroutine subsample_and_optics(nPoints, nLevels, nColumns, nHydro,overlap, & + use_precipitation_fluxes, lidar_ice_type, sd, tca, cca,& + fl_lsrainIN, fl_lssnowIN, fl_lsgrplIN, fl_ccrainIN, & + fl_ccsnowIN, mr_lsliq, mr_lsice, mr_ccliq, mr_ccice, & + reffIN, dtau_c, dtau_s, dem_c, dem_s, dtau_s_snow, & + dem_s_snow, sfcP, cospstateIN, cospIN) + ! Dependencies + use cosp_kinds, only: wp + use mod_rng, only: rng_state, init_rng + use mod_cosp_config, only: R_UNDEF + use mod_scops, only: scops + use mod_prec_scops, only: prec_scops + use mod_cosp_utils, only: cosp_precip_mxratio + use mod_quickbeam_optics, only: quickbeam_optics, gases + use cosp_optics, only: cosp_simulator_optics,lidar_optics,modis_optics, & + modis_optics_partition + use mod_cosp_config, only: Nlvgrid, vgrid_zl, vgrid_zu + use mod_cosp_stats, only: cosp_change_vertical_grid + ! Inputs + logical,intent(in) :: & + use_precipitation_fluxes + integer,intent(in) :: & + nPoints, & ! Number of gridpoints + nLevels, & ! Number of vertical levels + nColumns, & ! Number of subcolumns + nHydro, & ! Number pf hydrometeor types + overlap, & ! Overlap assumption (1/2/3) + lidar_ice_type ! Ice type assumption used by lidar optics + real(wp),intent(in),dimension(nPoints,nLevels) :: & + tca, & ! Total cloud amount (0-1) + cca, & ! Convective cloud amount (0-1) + mr_lsliq, & ! Mixing ratio (kg/kg) + mr_lsice, & ! Mixing ratio (kg/kg) + mr_ccliq, & ! Mixing ratio (kg/kg) + mr_ccice, & ! Mixing ratio (kg/kg) + dtau_c, & ! 0.67-micron optical depth (convective) + dtau_s, & ! 0.67-micron optical depth (stratiform) + dem_c, & ! 11-micron emissivity (convective) + dem_s, & ! 11-micron emissivity (stratiform) + fl_lsrainIN, & ! Precipitation flux + fl_lssnowIN, & ! Precipitation flux + fl_lsgrplIN, & ! Precipitation flux + fl_ccrainIN, & ! Precipitation flux + fl_ccsnowIN ! Precipitation flux + real(wp),intent(inout),dimension(nPoints,nLevels) :: & + dtau_s_snow, & ! 0.67-micron optical depth (snow) + dem_s_snow ! 11-micron emissivity (snow) + real(wp),intent(in),dimension(nPoints,nLevels,nHydro) :: & + reffIN ! + real(wp),intent(in),dimension(nPoints) :: & + sfcP ! Surface pressure + type(size_distribution),intent(inout) :: & + sd + + ! Outputs + type(cosp_optical_inputs),intent(inout) :: cospIN + type(cosp_column_inputs),intent(inout) :: cospstateIN + + ! Local variables + integer :: i,j,k + real(wp),dimension(nPoints,nLevels) :: column_frac_out,column_prec_out, & + fl_lsrain,fl_lssnow,fl_lsgrpl,fl_ccrain, & + fl_ccsnow + real(wp),dimension(nPoints,nLevels,nHydro) :: ReffTemp + type(rng_state),allocatable,dimension(:) :: rngs ! Seeds for random number generator + integer,dimension(:),allocatable :: seed + real(wp),dimension(:,:),allocatable :: ls_p_rate,cv_p_rate,frac_ls,frac_cv, & + prec_ls,prec_cv,g_vol + real(wp),dimension(:,:,:), allocatable :: frac_prec,& + MODIS_cloudWater,MODIS_cloudIce, & + MODIS_watersize,MODIS_iceSize, & + MODIS_snowSize,MODIS_cloudSnow, & + MODIS_opticalThicknessLiq, & + MODIS_opticalThicknessSnow, & + MODIS_opticalThicknessIce, & + fracPrecipIce, fracPrecipIce_statGrid + real(wp),dimension(:,:,:,:),allocatable :: mr_hydro,Reff,Np + + call t_startf("scops") + if (Ncolumns .gt. 1) then + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Generate subcolumns for clouds (SCOPS) and precipitation type (PREC_SCOPS) + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! RNG used for subcolumn generation + allocate(rngs(nPoints),seed(nPoints)) + seed = int(sfcP) + if (Npoints .gt. 1) seed=(sfcP-int(sfcP))*1000000 + call init_rng(rngs, seed) + + ! Call scops + call scops(NPoints,Nlevels,Ncolumns,rngs,tca,cca,overlap,cospIN%frac_out,0) + deallocate(seed,rngs) + + ! Sum up precipitation rates. If not using preciitation fluxes, mixing ratios are + ! stored in _rate variables. + allocate(ls_p_rate(nPoints,nLevels),cv_p_rate(nPoints,Nlevels)) + if(use_precipitation_fluxes) then + ls_p_rate(:,1:nLevels) = fl_lsrainIN + fl_lssnowIN + fl_lsgrplIN + cv_p_rate(:,1:nLevels) = fl_ccrainIN + fl_ccsnowIN + else + ls_p_rate(:,1:nLevels) = 0 ! mixing_ratio(rain) + mixing_ratio(snow) + mixing_ratio (groupel) + cv_p_rate(:,1:nLevels) = 0 ! mixing_ratio(rain) + mixing_ratio(snow) + endif + + ! Call PREC_SCOPS + allocate(frac_prec(nPoints,nColumns,nLevels)) + call prec_scops(nPoints,nLevels,nColumns,ls_p_rate,cv_p_rate,cospIN%frac_out,frac_prec) + deallocate(ls_p_rate,cv_p_rate) + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Compute precipitation fraction in each gridbox + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Allocate + allocate(frac_ls(nPoints,nLevels),prec_ls(nPoints,nLevels), & + frac_cv(nPoints,nLevels),prec_cv(nPoints,nLevels)) + + ! Initialize + frac_ls(1:nPoints,1:nLevels) = 0._wp + prec_ls(1:nPoints,1:nLevels) = 0._wp + frac_cv(1:nPoints,1:nLevels) = 0._wp + prec_cv(1:nPoints,1:nLevels) = 0._wp + do j=1,nPoints + do k=1,nLevels + do i=1,nColumns + if (cospIN%frac_out(j,i,k) .eq. 1) frac_ls(j,k) = frac_ls(j,k)+1._wp + if (cospIN%frac_out(j,i,k) .eq. 2) frac_cv(j,k) = frac_cv(j,k)+1._wp + if (frac_prec(j,i,k) .eq. 1) prec_ls(j,k) = prec_ls(j,k)+1._wp + if (frac_prec(j,i,k) .eq. 2) prec_cv(j,k) = prec_cv(j,k)+1._wp + if (frac_prec(j,i,k) .eq. 3) prec_cv(j,k) = prec_cv(j,k)+1._wp + if (frac_prec(j,i,k) .eq. 3) prec_ls(j,k) = prec_ls(j,k)+1._wp + enddo + frac_ls(j,k)=frac_ls(j,k)/nColumns + frac_cv(j,k)=frac_cv(j,k)/nColumns + prec_ls(j,k)=prec_ls(j,k)/nColumns + prec_cv(j,k)=prec_cv(j,k)/nColumns + + ! Adjust grid-box mean snow properties to local properties + ! Convert longwave optical depth to longwave emissivity + if (prec_ls(j,k) .ne. 0._r8 .and. dtau_s_snow(j,k) .gt. 0._r8) then + dtau_s_snow(j,k) = dtau_s_snow(j,k)/prec_ls(j,k) + end if + if (prec_ls(j,k) .ne. 0._r8 .and. dem_s_snow(j,k) .gt. 0._r8) then + dem_s_snow(j,k) = dem_s_snow(j,k)/prec_ls(j,k) + dem_s_snow(j,k) = 1._r8 - exp ( -1._r8*dem_s_snow(j,k)) + end if !!+JEK + enddo + enddo + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Compute mixing ratios, effective radii and precipitation fluxes for clouds + ! and precipitation + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + allocate(mr_hydro(nPoints,nColumns,nLevels,nHydro), & + Reff(nPoints,nColumns,nLevels,nHydro), & + Np(nPoints,nColumns,nLevels,nHydro)) + + ! Initialize + mr_hydro(:,:,:,:) = 0._wp + Reff(:,:,:,:) = 0._wp + Np(:,:,:,:) = 0._wp + + do k=1,nColumns + ! Subcolumn clouds + column_frac_out = cospIN%frac_out(:,k,:) + + ! LS clouds + where (column_frac_out == I_LSC) + mr_hydro(:,k,:,I_LSCLIQ) = mr_lsliq + mr_hydro(:,k,:,I_LSCICE) = mr_lsice + Reff(:,k,:,I_LSCLIQ) = ReffIN(:,:,I_LSCLIQ) + Reff(:,k,:,I_LSCICE) = ReffIN(:,:,I_LSCICE) + ! CONV clouds + elsewhere (column_frac_out == I_CVC) + mr_hydro(:,k,:,I_CVCLIQ) = mr_ccliq + mr_hydro(:,k,:,I_CVCICE) = mr_ccice + Reff(:,k,:,I_CVCLIQ) = ReffIN(:,:,I_CVCLIQ) + Reff(:,k,:,I_CVCICE) = ReffIN(:,:,I_CVCICE) + end where + + ! Subcolumn precipitation + column_prec_out = frac_prec(:,k,:) + + ! LS Precipitation + where ((column_prec_out == 1) .or. (column_prec_out == 3) ) + Reff(:,k,:,I_LSRAIN) = ReffIN(:,:,I_LSRAIN) + Reff(:,k,:,I_LSSNOW) = ReffIN(:,:,I_LSSNOW) + Reff(:,k,:,I_LSGRPL) = ReffIN(:,:,I_LSGRPL) + ! CONV precipitation + elsewhere ((column_prec_out == 2) .or. (column_prec_out == 3)) + Reff(:,k,:,I_CVRAIN) = ReffIN(:,:,I_CVRAIN) + Reff(:,k,:,I_CVSNOW) = ReffIN(:,:,I_CVSNOW) + end where + enddo + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Convert the mixing ratio and precipitation fluxes from gridbox mean to + ! the fraction-based values + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + do k=1,nLevels + do j=1,nPoints + ! Clouds + if (frac_ls(j,k) .ne. 0._r8) then + mr_hydro(j,:,k,I_LSCLIQ) = mr_hydro(j,:,k,I_LSCLIQ)/frac_ls(j,k) + mr_hydro(j,:,k,I_LSCICE) = mr_hydro(j,:,k,I_LSCICE)/frac_ls(j,k) + endif + if (frac_cv(j,k) .ne. 0._r8) then + mr_hydro(j,:,k,I_CVCLIQ) = mr_hydro(j,:,k,I_CVCLIQ)/frac_cv(j,k) + mr_hydro(j,:,k,I_CVCICE) = mr_hydro(j,:,k,I_CVCICE)/frac_cv(j,k) + endif + + ! Precipitation + if (use_precipitation_fluxes) then + if (prec_ls(j,k) .ne. 0._r8) then + fl_lsrain(j,k) = fl_lsrainIN(j,k)/prec_ls(j,k) + fl_lssnow(j,k) = fl_lssnowIN(j,k)/prec_ls(j,k) + fl_lsgrpl(j,k) = fl_lsgrplIN(j,k)/prec_ls(j,k) + endif + if (prec_cv(j,k) .ne. 0._r8) then + fl_ccrain(j,k) = fl_ccrainIN(j,k)/prec_cv(j,k) + fl_ccsnow(j,k) = fl_ccsnowIN(j,k)/prec_cv(j,k) + endif + else + if (prec_ls(j,k) .ne. 0._r8) then + mr_hydro(j,:,k,I_LSRAIN) = mr_hydro(j,:,k,I_LSRAIN)/prec_ls(j,k) + mr_hydro(j,:,k,I_LSSNOW) = mr_hydro(j,:,k,I_LSSNOW)/prec_ls(j,k) + mr_hydro(j,:,k,I_LSGRPL) = mr_hydro(j,:,k,I_LSGRPL)/prec_ls(j,k) + endif + if (prec_cv(j,k) .ne. 0._r8) then + mr_hydro(j,:,k,I_CVRAIN) = mr_hydro(j,:,k,I_CVRAIN)/prec_cv(j,k) + mr_hydro(j,:,k,I_CVSNOW) = mr_hydro(j,:,k,I_CVSNOW)/prec_cv(j,k) + endif + endif + enddo + enddo + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Convert precipitation fluxes to mixing ratios + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + if (use_precipitation_fluxes) then + ! LS rain + call cosp_precip_mxratio(nPoints, nLevels, nColumns, cospstateIN%pfull, & + cospstateIN%at, frac_prec, 1._wp, n_ax(I_LSRAIN), n_bx(I_LSRAIN), & + alpha_x(I_LSRAIN), c_x(I_LSRAIN), d_x(I_LSRAIN), g_x(I_LSRAIN), & + a_x(I_LSRAIN), b_x(I_LSRAIN), gamma_1(I_LSRAIN), gamma_2(I_LSRAIN), & + gamma_3(I_LSRAIN), gamma_4(I_LSRAIN), fl_lsrain, & + mr_hydro(:,:,:,I_LSRAIN), Reff(:,:,:,I_LSRAIN)) + ! LS snow + call cosp_precip_mxratio(nPoints, nLevels, nColumns, cospstateIN%pfull, & + cospstateIN%at, frac_prec, 1._wp, n_ax(I_LSSNOW), n_bx(I_LSSNOW), & + alpha_x(I_LSSNOW), c_x(I_LSSNOW), d_x(I_LSSNOW), g_x(I_LSSNOW), & + a_x(I_LSSNOW), b_x(I_LSSNOW), gamma_1(I_LSSNOW), gamma_2(I_LSSNOW), & + gamma_3(I_LSSNOW), gamma_4(I_LSSNOW), fl_lssnow, & + mr_hydro(:,:,:,I_LSSNOW), Reff(:,:,:,I_LSSNOW)) + ! CV rain + call cosp_precip_mxratio(nPoints, nLevels, nColumns, cospstateIN%pfull, & + cospstateIN%at, frac_prec, 2._wp, n_ax(I_CVRAIN), n_bx(I_CVRAIN), & + alpha_x(I_CVRAIN), c_x(I_CVRAIN), d_x(I_CVRAIN), g_x(I_CVRAIN), & + a_x(I_CVRAIN), b_x(I_CVRAIN), gamma_1(I_CVRAIN), gamma_2(I_CVRAIN), & + gamma_3(I_CVRAIN), gamma_4(I_CVRAIN), fl_ccrain, & + mr_hydro(:,:,:,I_CVRAIN), Reff(:,:,:,I_CVRAIN)) + ! CV snow + call cosp_precip_mxratio(nPoints, nLevels, nColumns, cospstateIN%pfull, & + cospstateIN%at, frac_prec, 2._wp, n_ax(I_CVSNOW), n_bx(I_CVSNOW), & + alpha_x(I_CVSNOW), c_x(I_CVSNOW), d_x(I_CVSNOW), g_x(I_CVSNOW), & + a_x(I_CVSNOW), b_x(I_CVSNOW), gamma_1(I_CVSNOW), gamma_2(I_CVSNOW), & + gamma_3(I_CVSNOW), gamma_4(I_CVSNOW), fl_ccsnow, & + mr_hydro(:,:,:,I_CVSNOW), Reff(:,:,:,I_CVSNOW)) + ! LS groupel. + call cosp_precip_mxratio(nPoints, nLevels, nColumns, cospstateIN%pfull, & + cospstateIN%at, frac_prec, 1._wp, n_ax(I_LSGRPL), n_bx(I_LSGRPL), & + alpha_x(I_LSGRPL), c_x(I_LSGRPL), d_x(I_LSGRPL), g_x(I_LSGRPL), & + a_x(I_LSGRPL), b_x(I_LSGRPL), gamma_1(I_LSGRPL), gamma_2(I_LSGRPL), & + gamma_3(I_LSGRPL), gamma_4(I_LSGRPL), fl_lsgrpl, & + mr_hydro(:,:,:,I_LSGRPL), Reff(:,:,:,I_LSGRPL)) + endif + + else + cospIN%frac_out(:,:,:) = 1 + allocate(mr_hydro(nPoints, 1,nLevels,nHydro),Reff(nPoints,1,nLevels,nHydro), & + Np(nPoints,1,nLevels,nHydro)) + mr_hydro(:,1,:,I_LSCLIQ) = mr_lsliq + mr_hydro(:,1,:,I_LSCICE) = mr_lsice + mr_hydro(:,1,:,I_CVCLIQ) = mr_ccliq + mr_hydro(:,1,:,I_CVCICE) = mr_ccice + Reff(:,1,:,:) = ReffIN + endif + call t_stopf("scops") + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! CLOUDSAT RADAR OPTICS + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + call t_startf("cloudsat_optics") + if (lradar_sim) then + ! Compute gaseous absorption (assume identical for each subcolun) + allocate(g_vol(nPoints,nLevels)) + g_vol(:,:)=0._wp + do i = 1, nPoints + do j = 1, nLevels + if (cospIN%rcfg_cloudsat%use_gas_abs == 1 .or. & + (cospIN%rcfg_cloudsat%use_gas_abs == 2 .and. j == 1)) then + g_vol(i,j) = gases(cospstateIN%pfull(i,j), cospstateIN%at(i,j), & + cospstateIN%qv(i,j), cospIN%rcfg_cloudsat%freq) + endif + cospIN%g_vol_cloudsat(i,:,j) = g_vol(i,j) + end do + end do + + ! Loop over all subcolumns + allocate(fracPrecipIce(nPoints,nColumns,nLevels)) + fracPrecipIce(:,:,:) = 0._wp + do k=1,nColumns + call quickbeam_optics(sd, cospIN%rcfg_cloudsat, nPoints, nLevels, R_UNDEF, & + mr_hydro(:,k,:,1:nHydro)*1000._wp, Reff(:,k,:,1:nHydro)*1.e6_wp, & + Np(:,k,:,1:nHydro), cospstateIN%pfull, cospstateIN%at, & + cospstateIN%qv, cospIN%z_vol_cloudsat(1:nPoints,k,:), & + cospIN%kr_vol_cloudsat(1:nPoints,k,:)) + + ! At each model level, what fraction of the precipitation is frozen? + where(mr_hydro(:,k,:,I_LSRAIN) .gt. 0 .or. mr_hydro(:,k,:,I_LSSNOW) .gt. 0 .or. & + mr_hydro(:,k,:,I_CVRAIN) .gt. 0 .or. mr_hydro(:,k,:,I_CVSNOW) .gt. 0 .or. & + mr_hydro(:,k,:,I_LSGRPL) .gt. 0) + fracPrecipIce(:,k,:) = (mr_hydro(:,k,:,I_LSSNOW) + mr_hydro(:,k,:,I_CVSNOW) + & + mr_hydro(:,k,:,I_LSGRPL)) / & + (mr_hydro(:,k,:,I_LSSNOW) + mr_hydro(:,k,:,I_CVSNOW) + mr_hydro(:,k,:,I_LSGRPL) + & + mr_hydro(:,k,:,I_LSRAIN) + mr_hydro(:,k,:,I_CVRAIN)) + elsewhere + fracPrecipIce(:,k,:) = 0._wp + endwhere + enddo + + ! Regrid frozen fraction to Cloudsat/Calipso statistical grid + allocate(fracPrecipIce_statGrid(nPoints,nColumns,Nlvgrid)) + fracPrecipIce_statGrid(:,:,:) = 0._wp + call cosp_change_vertical_grid(Npoints, Ncolumns, Nlevels, cospstateIN%hgt_matrix(:,Nlevels:1:-1), & + cospstateIN%hgt_matrix_half(:,Nlevels:1:-1), fracPrecipIce(:,:,Nlevels:1:-1), Nlvgrid, & + vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), fracPrecipIce_statGrid(:,:,Nlvgrid:1:-1)) + + ! For near-surface diagnostics, we only need the frozen fraction at one layer. + cospIN%fracPrecipIce(:,:) = fracPrecipIce_statGrid(:,:,cloudsat_preclvl) + + ! Regrid preipitation mixing-ratios to statistical grid. + !allocate(tempStatGrid(nPoints,ncol,Nlvgrid)) + !tempStatGrid(:,:,:,:) = 0._wp + !call cosp_change_vertical_grid(Npoints, ncol, pver, cospstateIN%hgt_matrix(:,pver:1:-1), & + ! cospstateIN%hgt_matrix_half(:,pver:1:-1), mr_hydro(:,:,:,LSGRPL), & + ! Nlvgrid,vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), tempStatGrid) + ! + endif + call t_stopf("cloudsat_optics") + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! CALIPSO Polarized optics + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + call t_startf("calipso_optics") + if (Llidar_sim) then + ReffTemp = ReffIN + call lidar_optics(nPoints,nColumns,nLevels,5,lidar_ice_type, & + mr_hydro(1:nPoints,1:nColumns,1:nLevels,I_LSCLIQ), & + mr_hydro(1:nPoints,1:nColumns,1:nLevels,I_LSCICE), & + mr_hydro(1:nPoints,1:nColumns,1:nLevels,I_CVCLIQ), & + mr_hydro(1:nPoints,1:nColumns,1:nLevels,I_CVCICE), & + mr_hydro(1:nPoints,1:nColumns,1:nLevels,I_LSSNOW), & + ReffTemp(1:nPoints,1:nLevels,I_LSCLIQ), & + ReffTemp(1:nPoints,1:nLevels,I_LSCICE), & + ReffTemp(1:nPoints,1:nLevels,I_CVCLIQ), & + ReffTemp(1:nPoints,1:nLevels,I_CVCICE), & + ReffTemp(1:nPoints,1:nLevels,I_LSSNOW), & + cospstateIN%pfull(1:nPoints,1:nLevels), & + cospstateIN%phalf(1:nPoints,1:nLevels+1), & + cospstateIN%at(1:nPoints,1:nLevels), & + cospIN%beta_mol_calipso(1:nPoints,1:nLevels), & + cospIN%betatot_calipso(1:nPoints,1:nColumns,1:nLevels), & + cospIN%tau_mol_calipso(1:nPoints,1:nLevels), & + cospIN%tautot_calipso(1:nPoints,1:nColumns,1:nLevels), & + cospIN%tautot_S_liq(1:nPoints,1:nColumns), & + cospIN%tautot_S_ice(1:nPoints,1:nColumns), & + cospIN%betatot_ice_calipso(1:nPoints,1:nColumns,1:nLevels), & + cospIN%betatot_liq_calipso(1:nPoints,1:nColumns,1:nLevels), & + cospIN%tautot_ice_calipso(1:nPoints,1:nColumns,1:nLevels), & + cospIN%tautot_liq_calipso(1:nPoints,1:nColumns,1:nLevels)) + endif + call t_stopf("calipso_optics") + + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! Compute optical fields for passive simulators (i.e. only sunlit points) + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 11 micron emissivity (needed by the ISCCP simulator) + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + call t_startf("11micron_emissivity") + if (Lisccp_sim) then + call cosp_simulator_optics(nPoints,nColumns,nLevels,cospIN%frac_out,dem_c,dem_s, & + cospIN%emiss_11) + ! Add in contributions from radiative snow + do j=1,nColumns + where(frac_prec(:,j,:) .eq. 1 .or. frac_prec(:,j,:) .eq. 3) + cospIN%emiss_11(:,j,:) = 1._wp - (1- cospIN%emiss_11(:,j,:))*(1-dem_s_snow) + endwhere + enddo + endif + call t_stopf("11micron_emissivity") + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 0.67 micron optical depth (needed by ISCCP, MISR and MODIS simulators) + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + call t_startf("067tau") + if (Lisccp_sim .or. Lmisr_sim .or. Lmodis_sim) then + call cosp_simulator_optics(nPoints,nColumns,nLevels,cospIN%frac_out,dtau_c,dtau_s,& + cospIN%tau_067) + + ! Add in contributions from snow + do j=1,nColumns + where((frac_prec(:,j,:) .eq. 1 .or. frac_prec(:,j,:) .eq. 3) .and. & + Reff(:,j,:,I_LSSNOW) .gt. 0._r8 .and. dtau_s_snow .gt. 0._r8) + cospIN%tau_067(:,j,:) = cospIN%tau_067(:,j,:)+dtau_s_snow + endwhere + enddo + endif + call t_stopf("067tau") + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! MODIS optics + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + call t_startf("modis_optics") + if (lmodis_sim) then + allocate(MODIS_cloudWater(nPoints,nColumns,nLevels), & + MODIS_cloudIce(nPoints,nColumns,nLevels), & + MODIS_cloudSnow(nPoints,nColumns,nLevels), & + MODIS_waterSize(nPoints,nColumns,nLevels), & + MODIS_iceSize(nPoints,nColumns,nLevels), & + MODIS_snowSize(nPoints,nColumns,nLevels), & + MODIS_opticalThicknessLiq(nPoints,nColumns,nLevels), & + MODIS_opticalThicknessIce(nPoints,nColumns,nLevels), & + MODIS_opticalThicknessSnow(nPoints,nColumns,nLevels)) + + ! Cloud water + call cosp_simulator_optics(nPoints,nColumns,nLevels,cospIN%frac_out, & + mr_hydro(:,:,:,I_CVCLIQ),mr_hydro(:,:,:,I_LSCLIQ),MODIS_cloudWater) + ! Cloud ice + call cosp_simulator_optics(nPoints,nColumns,nLevels,cospIN%frac_out, & + mr_hydro(:,:,:,I_CVCICE),mr_hydro(:,:,:,I_LSCICE),MODIS_cloudIce) + ! Cloud water droplet size + call cosp_simulator_optics(nPoints,nColumns,nLevels,cospIN%frac_out, & + Reff(:,:,:,I_CVCLIQ),Reff(:,:,:,I_LSCLIQ),MODIS_waterSize) + ! Cloud ice crystal size + call cosp_simulator_optics(nPoints,nColumns,nLevels,cospIN%frac_out, & + Reff(:,:,:,I_CVCICE),Reff(:,:,:,I_LSCICE),MODIS_iceSize) + + ! Cloud snow and size + MODIS_snowSize(:,:,:) = Reff(:,:,:,I_LSSNOW) + do j=1,nColumns + where((frac_prec(:,j,:) .eq. 1 .or. frac_prec(:,j,:) .eq. 3) .and. & + Reff(:,j,:,I_LSSNOW) .gt. 0._r8 .and. dtau_s_snow .gt. 0._r8) + MODIS_cloudSnow(:,j,:) = mr_hydro(:,j,:,I_LSSNOW) + MODIS_snowSize(:,j,:) = Reff(:,j,:,I_LSSNOW) + elsewhere + MODIS_snowSize(:,j,:) = 0._wp + MODIS_cloudSnow(:,j,:) = 0._wp + endwhere + enddo + + ! Partition optical thickness into liquid and ice parts + call modis_optics_partition(nPoints, nLevels, nColumns, MODIS_cloudWater, & + MODIS_cloudIce, MODIS_cloudSnow, MODIS_waterSize, MODIS_iceSize, & + MODIS_snowSize, cospIN%tau_067, MODIS_opticalThicknessLiq, & + MODIS_opticalThicknessIce, MODIS_opticalThicknessSnow) + + ! Compute assymetry parameter and single scattering albedo + call modis_optics(nPoints, nLevels, nColumns, MODIS_opticalThicknessLiq, & + MODIS_waterSize*1.0e6_wp, MODIS_opticalThicknessIce, & + MODIS_iceSize*1.0e6_wp, MODIS_opticalThicknessSnow, & + MODIS_snowSize*1.0e6_wp, cospIN%fracLiq, cospIN%asym, cospIN%ss_alb) + + endif ! MODIS simulator optics + call t_stopf("modis_optics") + + end subroutine subsample_and_optics + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE construct_cospIN + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine construct_cospIN(npoints,ncolumns,nlevels,ninst_rttov,y,emis_grey) + use cosp_kinds, only: wp + + ! Inputs + integer,intent(in) :: & + npoints, & ! Number of horizontal gridpoints + ncolumns, & ! Number of subcolumns + nlevels, & ! Number of vertical levels + ninst_rttov ! Number of RTTOV instruments + ! Outputs + type(cosp_optical_inputs),intent(out) :: y + ! Optional input + real(wp),intent(in),target, optional :: & + emis_grey + + ! Dimensions + y%Npoints = Npoints + y%Ncolumns = Ncolumns + y%Nlevels = Nlevels + y%Ninst_rttov = Ninst_rttov + y%Npart = 4 + y%Nrefl = PARASOL_NREFL + + if (present(emis_grey)) y%emis_grey => emis_grey + + allocate(y%tau_067( npoints, ncolumns, nlevels),& + y%emiss_11( npoints, ncolumns, nlevels),& + y%frac_out( npoints, ncolumns, nlevels),& + y%betatot_calipso( npoints, ncolumns, nlevels),& + y%betatot_ice_calipso(npoints, ncolumns, nlevels),& + y%fracLiq( npoints, ncolumns, nlevels),& + y%betatot_liq_calipso(npoints, ncolumns, nlevels),& + y%tautot_calipso( npoints, ncolumns, nlevels),& + y%tautot_ice_calipso( npoints, ncolumns, nlevels),& + y%tautot_liq_calipso( npoints, ncolumns, nlevels),& + y%z_vol_cloudsat( npoints, ncolumns, nlevels),& + y%kr_vol_cloudsat( npoints, ncolumns, nlevels),& + y%g_vol_cloudsat( npoints, ncolumns, nlevels),& + y%asym( npoints, ncolumns, nlevels),& + y%ss_alb( npoints, ncolumns, nlevels),& + y%beta_mol_calipso( npoints, nlevels),& + y%tau_mol_calipso( npoints, nlevels),& + y%tautot_S_ice( npoints, ncolumns ),& + y%tautot_S_liq( npoints, ncolumns) ,& + y%fracPrecipIce(npoints, ncolumns)) + allocate(y%cfg_rttov(ninst_rttov)) ! JKS do I need an if statement if "ninst_rttov" is zero? + end subroutine construct_cospIN + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE construct_cospstateIN + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine construct_cospstateIN(npoints,nlevels,y) + ! Inputs + integer,intent(in) :: & + npoints, & ! Number of horizontal gridpoints + nlevels ! Number of vertical levels + ! Outputs + type(cosp_column_inputs),intent(out) :: y + + allocate(y%sunlit(npoints),y%skt(npoints),y%land(npoints),y%at(npoints,nlevels), & + y%pfull(npoints,nlevels),y%phalf(npoints,nlevels+1),y%qv(npoints,nlevels), & + y%o3(npoints,nlevels),y%hgt_matrix(npoints,nlevels),y%u_sfc(npoints), & + y%co(npoints,nlevels),y%n2o(npoints,nlevels),y%ch4(npoints,nlevels), & + y%co2(npoints,nlevels), & + y%v_sfc(npoints),y%lat(npoints),y%lon(nPoints),y%rttov_sfcmask(nPoints), & + y%cloudIce(nPoints,nLevels),y%cloudLiq(nPoints,nLevels),y%surfelev(nPoints),& + y%DeffLiq(nPoints,nLevels),y%DeffIce(nPoints,nLevels), & + y%fl_snow(nPoints,nLevels),y%fl_rain(nPoints,nLevels), & + y%tca(nPoints,nLevels),y%hgt_matrix_half(npoints,nlevels), & + y%month(nPoints),y%time_frac(nPoints),y%sza(nPoints)) + + end subroutine construct_cospstateIN + ! ###################################################################################### + ! SUBROUTINE construct_cosp_outputs + ! + ! This subroutine allocates output fields based on input logical flag switches. + ! ###################################################################################### + subroutine construct_cosp_outputs(Npoints,Ncolumns,Nlevels,Nlvgrid,N_rttov_instruments,rttov_configs,x) + ! Inputs + integer,intent(in) :: & + Npoints, & ! Number of sampled points + Ncolumns, & ! Number of subgrid columns + Nlevels, & ! Number of model levels + Nlvgrid, & ! Number of levels in L3 stats computation + N_rttov_instruments ! Number of RTTOV instruments + + type(rttov_cfg), dimension(N_rttov_instruments),intent(in) :: & + rttov_configs + + ! Outputs + type(cosp_outputs),intent(out) :: & + x ! COSP output structure + + integer :: & + i + + ! ISCCP simulator outputs + if (lisccp_sim) then + allocate(x%isccp_boxtau(Npoints,Ncolumns)) + allocate(x%isccp_boxptop(Npoints,Ncolumns)) + allocate(x%isccp_fq(Npoints,numISCCPTauBins,numISCCPPresBins)) + allocate(x%isccp_totalcldarea(Npoints)) + allocate(x%isccp_meanptop(Npoints)) + allocate(x%isccp_meantaucld(Npoints)) + allocate(x%isccp_meantb(Npoints)) + allocate(x%isccp_meantbclr(Npoints)) + allocate(x%isccp_meanalbedocld(Npoints)) + endif + + ! MISR simulator + if (lmisr_sim) then + allocate(x%misr_fq(Npoints,numMISRTauBins,numMISRHgtBins)) + ! *NOTE* These 3 fields are not output, but were part of the v1.4.0 cosp_misr, so + ! they are still computed. Should probably have a logical to control these + ! outputs. + allocate(x%misr_dist_model_layertops(Npoints,numMISRHgtBins)) + allocate(x%misr_meanztop(Npoints)) + allocate(x%misr_cldarea(Npoints)) + endif + + ! MODIS simulator + if (lmodis_sim) then + allocate(x%modis_Cloud_Fraction_Total_Mean(Npoints)) + allocate(x%modis_Cloud_Fraction_Water_Mean(Npoints)) + allocate(x%modis_Cloud_Fraction_Ice_Mean(Npoints)) + allocate(x%modis_Cloud_Fraction_High_Mean(Npoints)) + allocate(x%modis_Cloud_Fraction_Mid_Mean(Npoints)) + allocate(x%modis_Cloud_Fraction_Low_Mean(Npoints)) + allocate(x%modis_Optical_Thickness_Total_Mean(Npoints)) + allocate(x%modis_Optical_Thickness_Water_Mean(Npoints)) + allocate(x%modis_Optical_Thickness_Ice_Mean(Npoints)) + allocate(x%modis_Optical_Thickness_Total_LogMean(Npoints)) + allocate(x%modis_Optical_Thickness_Water_LogMean(Npoints)) + allocate(x%modis_Optical_Thickness_Ice_LogMean(Npoints)) + allocate(x%modis_Cloud_Particle_Size_Water_Mean(Npoints)) + allocate(x%modis_Cloud_Particle_Size_Ice_Mean(Npoints)) + allocate(x%modis_Cloud_Top_Pressure_Total_Mean(Npoints)) + allocate(x%modis_Liquid_Water_Path_Mean(Npoints)) + allocate(x%modis_Ice_Water_Path_Mean(Npoints)) + allocate(x%modis_Optical_Thickness_vs_Cloud_Top_Pressure(nPoints,numModisTauBins,numMODISPresBins)) + allocate(x%modis_Optical_thickness_vs_ReffLIQ(nPoints,numMODISTauBins,numMODISReffLiqBins)) + allocate(x%modis_Optical_Thickness_vs_ReffICE(nPoints,numMODISTauBins,numMODISReffIceBins)) + endif + + ! CALIPSO simulator + if (llidar_sim) then + allocate(x%calipso_beta_mol(Npoints,Nlevels)) + allocate(x%calipso_beta_tot(Npoints,Ncolumns,Nlevels)) + allocate(x%calipso_srbval(SR_BINS+1)) + allocate(x%calipso_cfad_sr(Npoints,SR_BINS,Nlvgrid)) + allocate(x%calipso_betaperp_tot(Npoints,Ncolumns,Nlevels)) + allocate(x%calipso_lidarcld(Npoints,Nlvgrid)) + allocate(x%calipso_cldlayer(Npoints,LIDAR_NCAT)) + allocate(x%calipso_lidarcldphase(Npoints,Nlvgrid,6)) + allocate(x%calipso_lidarcldtmp(Npoints,LIDAR_NTEMP,5)) + allocate(x%calipso_cldlayerphase(Npoints,LIDAR_NCAT,6)) + ! These 2 outputs are part of the calipso output type, but are not controlled by an + ! logical switch in the output namelist, so if all other fields are on, then allocate + allocate(x%calipso_tau_tot(Npoints,Ncolumns,Nlevels)) + allocate(x%calipso_temp_tot(Npoints,Nlevels)) + ! Calipso opaque cloud diagnostics +! allocate(x%calipso_cldtype(Npoints,LIDAR_NTYPE)) +! allocate(x%calipso_cldtypetemp(Npoints,LIDAR_NTYPE)) +! allocate(x%calipso_cldtypemeanz(Npoints,2)) +! allocate(x%calipso_cldtypemeanzse(Npoints,3)) +! allocate(x%calipso_cldthinemis(Npoints)) +! allocate(x%calipso_lidarcldtype(Npoints,Nlvgrid,LIDAR_NTYPE+1)) + endif + + ! PARASOL + if (lparasol_sim) then + allocate(x%parasolPix_refl(Npoints,Ncolumns,PARASOL_NREFL)) + allocate(x%parasolGrid_refl(Npoints,PARASOL_NREFL)) + endif + + ! Cloudsat simulator + if (lradar_sim) then + allocate(x%cloudsat_Ze_tot(Npoints,Ncolumns,Nlevels)) + allocate(x%cloudsat_cfad_ze(Npoints,CLOUDSAT_DBZE_BINS,Nlvgrid)) + allocate(x%lidar_only_freq_cloud(Npoints,Nlvgrid)) + allocate(x%radar_lidar_tcc(Npoints)) + allocate(x%cloudsat_precip_cover(Npoints,nCloudsatPrecipClass)) + allocate(x%cloudsat_pia(Npoints)) + endif + + ! RTTOV - Allocate output for multiple instruments + ! Do I not need to allocate the number of instruments? Because each rttov output DDT will be a pointer? + + if (masterproc) then + if (docosp) then + write(iulog,*)'Reached RTTOV section in construct_cosp_outputs' + write(iulog,*)'lrttov_sim: ', lrttov_sim + end if + end if + + if ((N_rttov_instruments .gt. 0) .and. (lrttov_sim)) then + x % N_rttov_instruments = N_rttov_instruments + allocate(x % rttov_outputs(N_rttov_instruments)) ! Need to allocate a pointer? + print*,'Immediately after rttov_outputs allocation.' + print*,'associated(x % rttov_outputs(1) % refl_total): ',associated(x % rttov_outputs(1) % refl_total) + print*,'associated(x % rttov_outputs(1) % refl_clear): ',associated(x % rttov_outputs(1) % refl_clear) + do i=1,N_rttov_instruments + print*,'i: ',i + print*,'rttov_configs(i) % nchan_out: ',rttov_configs(i) % nchan_out + print*,'rttov_configs(i) % Lrttov_bt: ',rttov_configs(i) % Lrttov_bt + print*,'rttov_configs(i) % Lrttov_rad: ',rttov_configs(i) % Lrttov_rad + print*,'rttov_configs(i) % Lrttov_refl: ',rttov_configs(i) % Lrttov_refl + print*,'rttov_configs(i) % Lrttov_cld: ',rttov_configs(i) % Lrttov_cld + print*,'rttov_configs(i) % Lrttov_aer: ',rttov_configs(i) % Lrttov_aer + print*,'rttov_configs(i) % Lrttov_pc: ',rttov_configs(i) % Lrttov_pc + + print*,'1.' + x % rttov_outputs(i) % nchan_out = rttov_configs(i) % nchan_out + if (rttov_configs(i) % Lrttov_pc) then ! Treat PC-RTTOV fields as clear-sky only for now + print*,'2a.' + allocate(x % rttov_outputs(i) % channel_indices(rttov_configs(i) % nchan_out)) + if (rttov_configs(i) % Lrttov_bt) then ! Brightness temp + allocate(x % rttov_outputs(i) % bt_total_pc(Npoints,rttov_configs(i) % nchan_out)) + ! if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_bt_clear(Npoints,Nchan)) + end if + if (rttov_configs(i) % Lrttov_rad) then ! Radiance + allocate(x % rttov_outputs(i) % rad_total_pc(Npoints,rttov_configs(i) % nchan_out)) + ! if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_rad_clear(Npoints,Nchan)) + ! if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_rad_cloudy(Npoints,Nchan)) + end if + else + print*,'3a.' + allocate(x % rttov_outputs(i) % channel_indices(rttov_configs(i) % nchan_out)) + if (rttov_configs(i) % Lrttov_bt) then ! Brightness temp + allocate(x % rttov_outputs(i) % bt_total(Npoints,rttov_configs(i) % nchan_out)) + if ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer)) then + allocate(x % rttov_outputs(i) % bt_clear(Npoints,rttov_configs(i) % nchan_out)) + end if + end if + if (rttov_configs(i) % Lrttov_rad) then ! Radiance + allocate(x % rttov_outputs(i) % rad_total(Npoints,rttov_configs(i) % nchan_out)) + if ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer)) then + allocate(x % rttov_outputs(i) % rad_clear(Npoints,rttov_configs(i) % nchan_out)) + end if + if ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer)) then + allocate(x % rttov_outputs(i) % rad_cloudy(Npoints,rttov_configs(i) % nchan_out)) + end if + end if + if (rttov_configs(i) % Lrttov_refl) then ! Reflectance + allocate(x % rttov_outputs(i) % refl_total(Npoints,rttov_configs(i) % nchan_out)) + end if + if (rttov_configs(i) % Lrttov_refl .and. ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer))) then + print*,'in refl_clear if-do.' + print*,'rttov_configs(i) % Lrttov_refl: ',rttov_configs(i) % Lrttov_refl + print*,'rttov_configs(i) % Lrttov_cld: ',rttov_configs(i) % Lrttov_cld + print*,'rttov_configs(i) % Lrttov_aer: ',rttov_configs(i) % Lrttov_aer + allocate(x % rttov_outputs(i) % refl_clear(Npoints,rttov_configs(i) % nchan_out)) + end if !^ Logic should be equivalent?? + end if + end do + else + x % N_rttov_instruments = 0 + end if + + print*,'associated(x % rttov_outputs(i) % refl_total): ',associated(x % rttov_outputs(1) % refl_total) + print*,'associated(x % rttov_outputs(i) % refl_clear): ',associated(x % rttov_outputs(1) % refl_clear) + if (masterproc) then + if (docosp) then + write(iulog,*)'Finished RTTOV section in construct_cosp_outputs' + write(iulog,*)'lrttov_sim: ', lrttov_sim + write(iulog,*)'associated(x % rttov_outputs(i) % bt_total): ',associated(x % rttov_outputs(1) % bt_total) + write(iulog,*)'associated(x % rttov_outputs(i) % refl_total): ',associated(x % rttov_outputs(1) % refl_total) + write(iulog,*)'associated(x % rttov_outputs(i) % refl_clear): ',associated(x % rttov_outputs(1) % refl_clear) + end if + end if + + end subroutine construct_cosp_outputs + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE destroy_cospIN + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine destroy_cospIN(y) + type(cosp_optical_inputs),intent(inout) :: y + + if (allocated(y%tau_067)) deallocate(y%tau_067) + if (allocated(y%emiss_11)) deallocate(y%emiss_11) + if (allocated(y%frac_out)) deallocate(y%frac_out) + if (allocated(y%beta_mol_calipso)) deallocate(y%beta_mol_calipso) + if (allocated(y%tau_mol_calipso)) deallocate(y%tau_mol_calipso) + if (allocated(y%betatot_calipso)) deallocate(y%betatot_calipso) + if (allocated(y%betatot_ice_calipso)) deallocate(y%betatot_ice_calipso) + if (allocated(y%betatot_liq_calipso)) deallocate(y%betatot_liq_calipso) + if (allocated(y%tautot_calipso)) deallocate(y%tautot_calipso) + if (allocated(y%tautot_ice_calipso)) deallocate(y%tautot_ice_calipso) + if (allocated(y%tautot_liq_calipso)) deallocate(y%tautot_liq_calipso) + if (allocated(y%tautot_S_liq)) deallocate(y%tautot_S_liq) + if (allocated(y%tautot_S_ice)) deallocate(y%tautot_S_ice) + if (allocated(y%z_vol_cloudsat)) deallocate(y%z_vol_cloudsat) + if (allocated(y%kr_vol_cloudsat)) deallocate(y%kr_vol_cloudsat) + if (allocated(y%g_vol_cloudsat)) deallocate(y%g_vol_cloudsat) + if (allocated(y%asym)) deallocate(y%asym) + if (allocated(y%ss_alb)) deallocate(y%ss_alb) + if (allocated(y%fracLiq)) deallocate(y%fracLiq) + if (allocated(y%fracPrecipIce)) deallocate(y%fracPrecipIce) + end subroutine destroy_cospIN + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE destroy_cospstateIN + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine destroy_cospstateIN(y) + type(cosp_column_inputs),intent(inout) :: y + + if (allocated(y%surfelev)) deallocate(y%surfelev) + if (allocated(y%sunlit)) deallocate(y%sunlit) + if (allocated(y%skt)) deallocate(y%skt) + if (allocated(y%land)) deallocate(y%land) + if (allocated(y%rttov_sfcmask)) deallocate(y%rttov_sfcmask) + if (allocated(y%at)) deallocate(y%at) + if (allocated(y%pfull)) deallocate(y%pfull) + if (allocated(y%phalf)) deallocate(y%phalf) + if (allocated(y%qv)) deallocate(y%qv) + if (allocated(y%month)) deallocate(y%month) ! New RTTOV variables below + if (allocated(y%time_frac)) deallocate(y%time_frac) + if (allocated(y%sza)) deallocate(y%sza) + if (allocated(y%co2)) deallocate(y%co2) + if (allocated(y%ch4)) deallocate(y%ch4) + if (allocated(y%n2o)) deallocate(y%n2o) + if (allocated(y%co)) deallocate(y%co) ! New RTTOV vars^ + if (allocated(y%o3)) deallocate(y%o3) + if (allocated(y%hgt_matrix)) deallocate(y%hgt_matrix) + if (allocated(y%u_sfc)) deallocate(y%u_sfc) + if (allocated(y%v_sfc)) deallocate(y%v_sfc) + if (allocated(y%lat)) deallocate(y%lat) + if (allocated(y%lon)) deallocate(y%lon) + if (allocated(y%emis_in)) deallocate(y%emis_in) + if (allocated(y%refl_in)) deallocate(y%refl_in) + if (allocated(y%cloudIce)) deallocate(y%cloudIce) + if (allocated(y%cloudLiq)) deallocate(y%cloudLiq) + if (allocated(y%DeffLiq)) deallocate(y%DeffLiq) + if (allocated(y%DeffIce)) deallocate(y%DeffIce) + if (allocated(y%fl_rain)) deallocate(y%fl_rain) + if (allocated(y%fl_snow)) deallocate(y%fl_snow) + if (allocated(y%tca)) deallocate(y%tca) + if (allocated(y%hgt_matrix_half)) deallocate(y%hgt_matrix_half) + + end subroutine destroy_cospstateIN + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE destroy_cosp_outputs + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine destroy_cosp_outputs(y) + type(cosp_outputs),intent(inout) :: y + integer :: i ! Local iterator for RTTOV instruments + + ! Deallocate and nullify + if (associated(y%calipso_beta_mol)) then + deallocate(y%calipso_beta_mol) + nullify(y%calipso_beta_mol) + endif + if (associated(y%calipso_temp_tot)) then + deallocate(y%calipso_temp_tot) + nullify(y%calipso_temp_tot) + endif + if (associated(y%calipso_betaperp_tot)) then + deallocate(y%calipso_betaperp_tot) + nullify(y%calipso_betaperp_tot) + endif + if (associated(y%calipso_beta_tot)) then + deallocate(y%calipso_beta_tot) + nullify(y%calipso_beta_tot) + endif + if (associated(y%calipso_tau_tot)) then + deallocate(y%calipso_tau_tot) + nullify(y%calipso_tau_tot) + endif + if (associated(y%calipso_lidarcldphase)) then + deallocate(y%calipso_lidarcldphase) + nullify(y%calipso_lidarcldphase) + endif + if (associated(y%calipso_cldlayerphase)) then + deallocate(y%calipso_cldlayerphase) + nullify(y%calipso_cldlayerphase) + endif + if (associated(y%calipso_lidarcldtmp)) then + deallocate(y%calipso_lidarcldtmp) + nullify(y%calipso_lidarcldtmp) + endif + if (associated(y%calipso_cldlayer)) then + deallocate(y%calipso_cldlayer) + nullify(y%calipso_cldlayer) + endif + if (associated(y%calipso_lidarcld)) then + deallocate(y%calipso_lidarcld) + nullify(y%calipso_lidarcld) + endif + if (associated(y%calipso_srbval)) then + deallocate(y%calipso_srbval) + nullify(y%calipso_srbval) + endif + if (associated(y%calipso_cfad_sr)) then + deallocate(y%calipso_cfad_sr) + nullify(y%calipso_cfad_sr) + endif + if (associated(y%parasolPix_refl)) then + deallocate(y%parasolPix_refl) + nullify(y%parasolPix_refl) + endif + if (associated(y%parasolGrid_refl)) then + deallocate(y%parasolGrid_refl) + nullify(y%parasolGrid_refl) + endif + if (associated(y%cloudsat_Ze_tot)) then + deallocate(y%cloudsat_Ze_tot) + nullify(y%cloudsat_Ze_tot) + endif + if (associated(y%cloudsat_precip_cover)) then + deallocate(y%cloudsat_precip_cover) + nullify(y%cloudsat_precip_cover) + endif + if (associated(y%cloudsat_pia)) then + deallocate(y%cloudsat_pia) + nullify(y%cloudsat_pia) + endif + if (associated(y%cloudsat_cfad_ze)) then + deallocate(y%cloudsat_cfad_ze) + nullify(y%cloudsat_cfad_ze) + endif + if (associated(y%radar_lidar_tcc)) then + deallocate(y%radar_lidar_tcc) + nullify(y%radar_lidar_tcc) + endif + if (associated(y%lidar_only_freq_cloud)) then + deallocate(y%lidar_only_freq_cloud) + nullify(y%lidar_only_freq_cloud) + endif + if (associated(y%isccp_totalcldarea)) then + deallocate(y%isccp_totalcldarea) + nullify(y%isccp_totalcldarea) + endif + if (associated(y%isccp_meantb)) then + deallocate(y%isccp_meantb) + nullify(y%isccp_meantb) + endif + if (associated(y%isccp_meantbclr)) then + deallocate(y%isccp_meantbclr) + nullify(y%isccp_meantbclr) + endif + if (associated(y%isccp_meanptop)) then + deallocate(y%isccp_meanptop) + nullify(y%isccp_meanptop) + endif + if (associated(y%isccp_meantaucld)) then + deallocate(y%isccp_meantaucld) + nullify(y%isccp_meantaucld) + endif + if (associated(y%isccp_meanalbedocld)) then + deallocate(y%isccp_meanalbedocld) + nullify(y%isccp_meanalbedocld) + endif + if (associated(y%isccp_boxtau)) then + deallocate(y%isccp_boxtau) + nullify(y%isccp_boxtau) + endif + if (associated(y%isccp_boxptop)) then + deallocate(y%isccp_boxptop) + nullify(y%isccp_boxptop) + endif + if (associated(y%isccp_fq)) then + deallocate(y%isccp_fq) + nullify(y%isccp_fq) + endif + if (associated(y%misr_fq)) then + deallocate(y%misr_fq) + nullify(y%misr_fq) + endif + if (associated(y%misr_dist_model_layertops)) then + deallocate(y%misr_dist_model_layertops) + nullify(y%misr_dist_model_layertops) + endif + if (associated(y%misr_meanztop)) then + deallocate(y%misr_meanztop) + nullify(y%misr_meanztop) + endif + if (associated(y%misr_cldarea)) then + deallocate(y%misr_cldarea) + nullify(y%misr_cldarea) + endif + if (associated(y%modis_Cloud_Fraction_Total_Mean)) then + deallocate(y%modis_Cloud_Fraction_Total_Mean) + nullify(y%modis_Cloud_Fraction_Total_Mean) + endif + if (associated(y%modis_Cloud_Fraction_Ice_Mean)) then + deallocate(y%modis_Cloud_Fraction_Ice_Mean) + nullify(y%modis_Cloud_Fraction_Ice_Mean) + endif + if (associated(y%modis_Cloud_Fraction_Water_Mean)) then + deallocate(y%modis_Cloud_Fraction_Water_Mean) + nullify(y%modis_Cloud_Fraction_Water_Mean) + endif + if (associated(y%modis_Cloud_Fraction_High_Mean)) then + deallocate(y%modis_Cloud_Fraction_High_Mean) + nullify(y%modis_Cloud_Fraction_High_Mean) + endif + if (associated(y%modis_Cloud_Fraction_Mid_Mean)) then + deallocate(y%modis_Cloud_Fraction_Mid_Mean) + nullify(y%modis_Cloud_Fraction_Mid_Mean) + endif + if (associated(y%modis_Cloud_Fraction_Low_Mean)) then + deallocate(y%modis_Cloud_Fraction_Low_Mean) + nullify(y%modis_Cloud_Fraction_Low_Mean) + endif + if (associated(y%modis_Optical_Thickness_Total_Mean)) then + deallocate(y%modis_Optical_Thickness_Total_Mean) + nullify(y%modis_Optical_Thickness_Total_Mean) + endif + if (associated(y%modis_Optical_Thickness_Water_Mean)) then + deallocate(y%modis_Optical_Thickness_Water_Mean) + nullify(y%modis_Optical_Thickness_Water_Mean) + endif + if (associated(y%modis_Optical_Thickness_Ice_Mean)) then + deallocate(y%modis_Optical_Thickness_Ice_Mean) + nullify(y%modis_Optical_Thickness_Ice_Mean) + endif + if (associated(y%modis_Optical_Thickness_Total_LogMean)) then + deallocate(y%modis_Optical_Thickness_Total_LogMean) + nullify(y%modis_Optical_Thickness_Total_LogMean) + endif + if (associated(y%modis_Optical_Thickness_Water_LogMean)) then + deallocate(y%modis_Optical_Thickness_Water_LogMean) + nullify(y%modis_Optical_Thickness_Water_LogMean) + endif + if (associated(y%modis_Optical_Thickness_Ice_LogMean)) then + deallocate(y%modis_Optical_Thickness_Ice_LogMean) + nullify(y%modis_Optical_Thickness_Ice_LogMean) + endif + if (associated(y%modis_Cloud_Particle_Size_Water_Mean)) then + deallocate(y%modis_Cloud_Particle_Size_Water_Mean) + nullify(y%modis_Cloud_Particle_Size_Water_Mean) + endif + if (associated(y%modis_Cloud_Particle_Size_Ice_Mean)) then + deallocate(y%modis_Cloud_Particle_Size_Ice_Mean) + nullify(y%modis_Cloud_Particle_Size_Ice_Mean) + endif + if (associated(y%modis_Cloud_Top_Pressure_Total_Mean)) then + deallocate(y%modis_Cloud_Top_Pressure_Total_Mean) + nullify(y%modis_Cloud_Top_Pressure_Total_Mean) + endif + if (associated(y%modis_Liquid_Water_Path_Mean)) then + deallocate(y%modis_Liquid_Water_Path_Mean) + nullify(y%modis_Liquid_Water_Path_Mean) + endif + if (associated(y%modis_Ice_Water_Path_Mean)) then + deallocate(y%modis_Ice_Water_Path_Mean) + nullify(y%modis_Ice_Water_Path_Mean) + endif + if (associated(y%modis_Optical_Thickness_vs_Cloud_Top_Pressure)) then + deallocate(y%modis_Optical_Thickness_vs_Cloud_Top_Pressure) + nullify(y%modis_Optical_Thickness_vs_Cloud_Top_Pressure) + endif + if (associated(y%modis_Optical_thickness_vs_ReffLIQ)) then + deallocate(y%modis_Optical_thickness_vs_ReffLIQ) + nullify(y%modis_Optical_thickness_vs_ReffLIQ) + endif + if (associated(y%modis_Optical_thickness_vs_ReffICE)) then + deallocate(y%modis_Optical_thickness_vs_ReffICE) + nullify(y%modis_Optical_thickness_vs_ReffICE) + endif + if (associated(y%calipso_cldtype)) then + deallocate(y%calipso_cldtype) + nullify(y%calipso_cldtype) + endif + if (associated(y%calipso_cldtypetemp)) then + deallocate(y%calipso_cldtypetemp) + nullify(y%calipso_cldtypetemp) + endif + if (associated(y%calipso_cldtypemeanz)) then + deallocate(y%calipso_cldtypemeanz) + nullify(y%calipso_cldtypemeanz) + endif + if (associated(y%calipso_cldtypemeanzse)) then + deallocate(y%calipso_cldtypemeanzse) + nullify(y%calipso_cldtypemeanzse) + endif + if (associated(y%calipso_cldthinemis)) then + deallocate(y%calipso_cldthinemis) + nullify(y%calipso_cldthinemis) + endif + if (associated(y%calipso_lidarcldtype)) then + deallocate(y%calipso_lidarcldtype) + nullify(y%calipso_lidarcldtype) + endif + + ! RTTOV multi-instrument - JKS +! if (associated(y%rttov_outputs)) then + if (allocated(y%rttov_outputs)) then + do i=1,y % N_rttov_instruments ! Iterate over each instrument + if (associated(y%rttov_outputs(i)%channel_indices)) then + deallocate(y%rttov_outputs(i)%channel_indices) + nullify(y%rttov_outputs(i)%channel_indices) + endif + if (associated(y%rttov_outputs(i)%bt_total)) then + deallocate(y%rttov_outputs(i)%bt_total) + nullify(y%rttov_outputs(i)%bt_total) + endif + if (associated(y%rttov_outputs(i)%bt_clear)) then + deallocate(y%rttov_outputs(i)%bt_clear) + nullify(y%rttov_outputs(i)%bt_clear) + endif + if (associated(y%rttov_outputs(i)%rad_total)) then + deallocate(y%rttov_outputs(i)%rad_total) + nullify(y%rttov_outputs(i)%rad_total) + endif + if (associated(y%rttov_outputs(i)%rad_clear)) then + deallocate(y%rttov_outputs(i)%rad_clear) + nullify(y%rttov_outputs(i)%rad_clear) + endif + if (associated(y%rttov_outputs(i)%rad_cloudy)) then + deallocate(y%rttov_outputs(i)%rad_cloudy) + nullify(y%rttov_outputs(i)%rad_cloudy) + endif + if (associated(y%rttov_outputs(i)%refl_total)) then + deallocate(y%rttov_outputs(i)%refl_total) + nullify(y%rttov_outputs(i)%refl_total) + endif + if (associated(y%rttov_outputs(i)%refl_clear)) then + deallocate(y%rttov_outputs(i)%refl_clear) + nullify(y%rttov_outputs(i)%refl_clear) + endif + if (associated(y%rttov_outputs(i)%bt_total_pc)) then + deallocate(y%rttov_outputs(i)%bt_total_pc) + nullify(y%rttov_outputs(i)%bt_total_pc) + endif + if (associated(y%rttov_outputs(i)%rad_total_pc)) then + deallocate(y%rttov_outputs(i)%rad_total_pc) + nullify(y%rttov_outputs(i)%rad_total_pc) + endif + end do + deallocate(y%rttov_outputs) +! nullify(y%rttov_outputs) + end if + + end subroutine destroy_cosp_outputs + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE rttov_cleanup + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine rttov_cleanup(y) + use MOD_COSP_RTTOV_INTERFACE, only: DESTROY_RTTOV_CONFIG + + type(cosp_optical_inputs),intent(inout) :: y + integer :: i + + if (size(y%cfg_rttov) .gt. 0) then + do i=1,y%Ninst_rttov + call destroy_rttov_config(y%cfg_rttov(i)) + end do + end if + nullify(y%cfg_rttov) + + end subroutine rttov_cleanup + +#endif + +!####################################################################### +end module cospsimulator_intr diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index df50854428..f0d8e22d2e 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -479,11 +479,9 @@ program cosp2_test !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Construct COSP input types !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - print*,'1.' if (iChunk .eq. 1) then ! call construct_cospIN(Nptsperit,nColumns,nLevels,rttov_Ninstruments,cospIN,emis_grey=0.2_wp) call construct_cospIN(Nptsperit,nColumns,nLevels,rttov_Ninstruments,cospIN) - print*,'1.a' call construct_cospstateIN(Nptsperit,nLevels,cospstateIN) endif if (iChunk .eq. nChunks) then @@ -501,7 +499,6 @@ program cosp2_test ! surface-2-TOA, whereas COSP expects all fields to be ordered from TOA-2-SFC. So the ! vertical fields are flipped prior to storing to COSP input type. !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - print*,'2.' cospIN%emsfc_lw = emsfc_lw cospIN%rcfg_cloudsat = rcfg_cloudsat @@ -638,7 +635,6 @@ program cosp2_test !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Call COSP !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - print*,'3.' cosp_status = COSP_SIMULATOR(cospIN, cospstateIN, cospOUT,start_idx,end_idx,rttov_verbose) do ij=1,size(cosp_status,1) if (cosp_status(ij) .ne. '') print*,trim(cosp_status(ij)) @@ -1088,7 +1084,7 @@ subroutine construct_cospIN(npoints,ncolumns,nlevels,ninst_rttov,y,emis_grey) ninst_rttov ! Number of RTTOV instruments ! Outputs type(cosp_optical_inputs),intent(out) :: y - + ! Optional input real(kind=wp),intent(in),target, optional :: & emis_grey diff --git a/src/cosp.F90 b/src/cosp.F90 index 4483403a80..b11bc6fe31 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -4306,6 +4306,19 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lrttov_column = .false. nError=nError+1 errorMessage(nError) = 'ERROR(rttov_simulator): The number of points in the input fields are inconsistent' + print*,'size(cospgridIN%pfull,1): ',size(cospgridIN%pfull,1) + print*,'size(cospgridIN%at,1): ',size(cospgridIN%at,1) + print*,'size(cospgridIN%qv,1): ',size(cospgridIN%qv,1) + print*,'size(cospgridIN%hgt_matrix_half,1): ',size(cospgridIN%hgt_matrix_half,1) + print*,'size(cospgridIN%u_sfc): ',size(cospgridIN%u_sfc) + print*,'size(cospgridIN%v_sfc): ',size(cospgridIN%v_sfc) + print*,'size(cospgridIN%skt): ',size(cospgridIN%skt) + print*,'size(cospgridIN%phalf,1): ',size(cospgridIN%phalf,1) + print*,'size(cospgridIN%cloudIce,1): ',size(cospgridIN%cloudIce,1) + print*,'size(cospgridIN%cloudLiq,1): ',size(cospgridIN%cloudLiq,1) + print*,'size(cospgridIN%rttov_sfcmask): ',size(cospgridIN%rttov_sfcmask) + print*,'size(cospgridIN%lon): ',size(cospgridIN%lon) + print*,'size(cospgridIN%lat): ',size(cospgridIN%lat) endif if (size(cospgridIN%pfull,2) .ne. cospIN%Nlevels .OR. & size(cospgridIN%at,2) .ne. cospIN%Nlevels .OR. & diff --git a/src/simulator/rttov/cosp_rttovSTUB.F90 b/src/simulator/rttov/cosp_rttovSTUB.F90 index ce5559c759..2ff2ac306b 100644 --- a/src/simulator/rttov/cosp_rttovSTUB.F90 +++ b/src/simulator/rttov/cosp_rttovSTUB.F90 @@ -57,6 +57,8 @@ MODULE MOD_COSP_RTTOV nPoints, & ! Number of profiles to simulate nLevels, & ! Number of levels nSubCols ! Number of subcolumns + real(kind=wp),pointer :: & + emis_grey => null() integer,dimension(:),pointer :: & month ! real(wp),dimension(:),pointer :: & From b740de0c2af9c887220b64ac44c1a0da1eeeeac1 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 27 Sep 2023 09:44:11 -0600 Subject: [PATCH 091/159] New test instrument namelist demonstrating channel subsetting. --- .../run/instrument_nls/cosp2_rttov_inst4.txt | 79 +++++++++++++++++++ driver/run/rttov_channel_input_MODIS16.csv | 16 ++++ 2 files changed, 95 insertions(+) create mode 100644 driver/run/instrument_nls/cosp2_rttov_inst4.txt create mode 100644 driver/run/rttov_channel_input_MODIS16.csv diff --git a/driver/run/instrument_nls/cosp2_rttov_inst4.txt b/driver/run/instrument_nls/cosp2_rttov_inst4.txt new file mode 100644 index 0000000000..80316408bb --- /dev/null +++ b/driver/run/instrument_nls/cosp2_rttov_inst4.txt @@ -0,0 +1,79 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +! Simulate MODIS, but just channels 20-36, removing 26 + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.true., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=16, ! 2300 + !-------------- RTTOV Filepaths + Lchannel_filepath=.true., + channel_filepath='rttov_channel_input_MODIS16.csv', + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='rttov13pred54L/rtcoef_eos_2_modis-shifted_7gas.dat', + aer_coef_filepath='cldaer_visir/scaercoef_eos_2_modis-shifted_cams.dat', + cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_modis-shifted.dat', +! OD_coef_filepath='rttov9pred101L/rtcoef_eos_2_airs_pcrttov_compat.H5', +! aer_coef_filepath='cldaer_visir/scaercoef_eos_2_airs_cams.H5', +! cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_airs.H5', + PC_coef_filepath='pc/pccoef_eos_2_airs_landsea.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.false., + CO_data=.false., + CO2_data=.true., + CH4_data=.false., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=16, + rttov_ZenAng=0.0, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at +/ diff --git a/driver/run/rttov_channel_input_MODIS16.csv b/driver/run/rttov_channel_input_MODIS16.csv new file mode 100644 index 0000000000..d6cf2cb824 --- /dev/null +++ b/driver/run/rttov_channel_input_MODIS16.csv @@ -0,0 +1,16 @@ +20,1,0 +21,1,0 +22,1,0 +23,1,0 +24,1,0 +25,1,0 +27,1,0 +28,1,0 +29,1,0 +30,1,0 +31,1,0 +32,1,0 +33,1,0 +34,1,0 +35,1,0 +36,1,0 \ No newline at end of file From 567b6e3ea14963d11e0b125490918dffe7943eff Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 27 Sep 2023 09:44:55 -0600 Subject: [PATCH 092/159] Updates to testing namelist files --- driver/run/cosp2_input_rttov_nl.txt | 6 ++++-- driver/run/cosp2_input_rttov_nl.um_global.txt | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/driver/run/cosp2_input_rttov_nl.txt b/driver/run/cosp2_input_rttov_nl.txt index 800c2ec8e4..b32d34274c 100644 --- a/driver/run/cosp2_input_rttov_nl.txt +++ b/driver/run/cosp2_input_rttov_nl.txt @@ -82,8 +82,10 @@ !---------------------------------------------------------------------------------- !-------------- RTTOV inputs !---------------------------------------------------------------------------------- - rttov_Ninstruments=3, - rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt', + rttov_Ninstruments=4, + rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt','instrument_nls/cosp2_rttov_inst4.txt', +! rttov_Ninstruments=3, +! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt', ! rttov_Ninstruments=1, ! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt', rttov_verbose=.true. diff --git a/driver/run/cosp2_input_rttov_nl.um_global.txt b/driver/run/cosp2_input_rttov_nl.um_global.txt index 3d7c7d2ad3..8d48eb7a87 100644 --- a/driver/run/cosp2_input_rttov_nl.um_global.txt +++ b/driver/run/cosp2_input_rttov_nl.um_global.txt @@ -26,7 +26,7 @@ ! Namelist that sets up the main COSP options &COSP_INPUT NPOINTS=1728, ! 1728,6912 - NPOINTS_IT=500,! 1000 Max number of gridpoints to be processed in one iteration + NPOINTS_IT=250,! 1000 Max number of gridpoints to be processed in one iteration NCOLUMNS=20, ! Number of subcolumns NLEVELS=54, ! Number of model levels USE_VGRID=.true., ! Use fixed vertical grid for outputs? (if .true. then you need to define number of levels with Nlr) From 29d3e1b1243869fcab2141466c9285c6633d7948 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 27 Sep 2023 16:57:16 -0600 Subject: [PATCH 093/159] First attempt at solar (VIS/NIR) implementation. Not getting expected output and need to remove time_frac and month fields. --- .../run/instrument_nls/cosp2_rttov_inst1.txt | 1 + driver/src/cosp2_io.f90 | 26 +++- driver/src/cosp2_test.F90 | 56 ++++++-- src/cosp.F90 | 130 +++++++++++++++++- src/simulator/cosp_rttov_interface_v13.F90 | 13 +- src/simulator/rttov/cosp_rttovSTUB.F90 | 5 +- src/simulator/rttov/cosp_rttov_v13.F90 | 53 +++++-- 7 files changed, 253 insertions(+), 31 deletions(-) diff --git a/driver/run/instrument_nls/cosp2_rttov_inst1.txt b/driver/run/instrument_nls/cosp2_rttov_inst1.txt index 4be037e2d0..84dcd736f9 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst1.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst1.txt @@ -34,6 +34,7 @@ Lrttov_cldparam=.false., ! Use user input cloud optical parameters Lrttov_aerparam=.false., ! Use user input aerosol optical parameters Lrttov_pc=.false., ! Run with PC-RTTOV + Lrttov_solar=.true., ! Do solar calculations !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" nchannels_rec=0, ! 2300 !-------------- RTTOV Filepaths diff --git a/driver/src/cosp2_io.f90 b/driver/src/cosp2_io.f90 index 4829a08c64..bb8d2ef9db 100644 --- a/driver/src/cosp2_io.f90 +++ b/driver/src/cosp2_io.f90 @@ -2137,7 +2137,8 @@ SUBROUTINE NC_READ_INPUT_FILE(fname,Npnts,Nl,Nhydro,lon,lat,p,ph,z,zh,T,qv,rh,tc mr_lsliq,mr_lsice,mr_ccliq,mr_ccice,fl_lsrain,fl_lssnow, & fl_lsgrpl,fl_ccrain,fl_ccsnow,Reff,dtau_s,dtau_c,dem_s, & dem_c,skt,landmask,mr_ozone,u_wind,v_wind,sunlit, & - emsfc_lw,mode,Nlon,Nlat,surfelev,month,hour,minute) + emsfc_lw,mode,Nlon,Nlat,surfelev,year,month,day, & + hour,minute,seconds) ! Arguments character(len=512),intent(in) :: fname ! File name @@ -2147,7 +2148,8 @@ SUBROUTINE NC_READ_INPUT_FILE(fname,Npnts,Nl,Nhydro,lon,lat,p,ph,z,zh,T,qv,rh,tc mr_lsliq,mr_lsice,mr_ccliq,mr_ccice,fl_lsrain,fl_lssnow,fl_lsgrpl, & fl_ccrain,fl_ccsnow,dtau_s,dtau_c,dem_s,dem_c,mr_ozone real(wp),dimension(Npnts,Nl,Nhydro),intent(out) :: Reff - real(wp),dimension(Npnts),intent(out) :: skt,landmask,u_wind,v_wind,sunlit,surfelev,minute,month,hour + real(wp),dimension(Npnts),intent(out) :: skt,landmask,u_wind,v_wind,sunlit,surfelev, & + year,month,day,hour,minute,seconds real(wp),intent(out) :: emsfc_lw integer,intent(out) :: mode,Nlon,Nlat @@ -2494,12 +2496,24 @@ SUBROUTINE NC_READ_INPUT_FILE(fname,Npnts,Nl,Nhydro,lon,lat,p,ph,z,zh,T,qv,rh,tc else call map_ll_to_point(Na,Nb,Npoints,x2=x2,y1=sunlit) endif + case ('year') + if (Lpoint) then + year(1:Npoints) = x1(1:Npoints) + else + call map_ll_to_point(Na,Nb,Npoints,x2=x2,y1=year) + endif case ('month') if (Lpoint) then month(1:Npoints) = x1(1:Npoints) else call map_ll_to_point(Na,Nb,Npoints,x2=x2,y1=month) endif + case ('day') + if (Lpoint) then + day(1:Npoints) = x1(1:Npoints) + else + call map_ll_to_point(Na,Nb,Npoints,x2=x2,y1=day) + endif case ('hour') if (Lpoint) then hour(1:Npoints) = x1(1:Npoints) @@ -2511,7 +2525,13 @@ SUBROUTINE NC_READ_INPUT_FILE(fname,Npnts,Nl,Nhydro,lon,lat,p,ph,z,zh,T,qv,rh,tc minute(1:Npoints) = x1(1:Npoints) else call map_ll_to_point(Na,Nb,Npoints,x2=x2,y1=minute) - endif + endif + case ('second') + if (Lpoint) then + seconds(1:Npoints) = x1(1:Npoints) + else + call map_ll_to_point(Na,Nb,Npoints,x2=x2,y1=seconds) + endif end select ! Free memory if (vrank == 1) deallocate(x1) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index f0d8e22d2e..c536d60aea 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -89,10 +89,13 @@ program cosp2_test u_wind, & ! U-component of wind (m/s) v_wind, & ! V-component of wind (m/s) sunlit ! Sunlit flag - real(wp),dimension(:),allocatable :: & + real(wp),dimension(:),allocatable :: & ! JKS change to target? + year, & ! Year (CE) month, & ! Month [1,12] + day, & ! Day [1,31] hour, & ! Hour [0,24] - minute ! Minute [0,60] + minute, & ! Minute [0,60] + seconds ! Second [0,60] real(wp),dimension(:,:),allocatable,target :: & p, & ! Model pressure levels (pa) ph, & ! Moddel pressure @ half levels (pa) @@ -323,20 +326,24 @@ program cosp2_test dtau_s(Npoints,Nlevels),dtau_c(Npoints,Nlevels),dem_s(Npoints,Nlevels), & dem_c(Npoints,Nlevels),skt(Npoints),landmask(Npoints), & mr_ozone(Npoints,Nlevels),u_wind(Npoints),v_wind(Npoints),sunlit(Npoints), & - frac_out(Npoints,Ncolumns,Nlevels),surfelev(Npoints),month(Npoints), & - hour(Npoints),minute(Npoints)) + frac_out(Npoints,Ncolumns,Nlevels),surfelev(Npoints),year(Npoints), & + month(Npoints),day(Npoints),hour(Npoints),minute(Npoints),seconds(Npoints)) ! Set some fields to masked values if the COSP offline driver outputs are inconsistent - month(:) = R_UNDEF - hour(:) = R_UNDEF - minute(:) = R_UNDEF + year(:) = R_UNDEF + month(:) = R_UNDEF + day(:) = R_UNDEF + hour(:) = R_UNDEF + minute(:) = R_UNDEF + seconds(:) = R_UNDEF fileIN = trim(dinput)//trim(finput) call nc_read_input_file(fileIN,Npoints,Nlevels,N_HYDRO,lon,lat,p,ph,zlev,zlev_half, & T,sh,rh,tca,cca,mr_lsliq,mr_lsice,mr_ccliq,mr_ccice,fl_lsrain, & fl_lssnow,fl_lsgrpl,fl_ccrain,fl_ccsnow,Reff,dtau_s,dtau_c, & dem_s,dem_c,skt,landmask,mr_ozone,u_wind,v_wind,sunlit, & - emsfc_lw,geomode,Nlon,Nlat,surfelev,month,hour,minute) + emsfc_lw,geomode,Nlon,Nlat,surfelev,year,month,day,hour, & + minute,seconds) call cpu_time(driver_time(2)) !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -534,12 +541,24 @@ program cosp2_test cospstateIN%co(:,:) = 2.098e-07 cospstateIN%so2(:,:) = 2.0e-11 + if (any(year(start_idx:end_idx) .lt. 0._wp)) then + print*,'Some of values of the input year field are masked. Replacing with 1 so RTTOV will run.' + where (year(start_idx:end_idx) .lt. 0._wp) + year(start_idx:end_idx) = 1 + end where + end if if (any(month(start_idx:end_idx) .lt. 0._wp)) then print*,'Some of values of the input month field are masked. Replacing with 1 so RTTOV will run.' where (month(start_idx:end_idx) .lt. 0._wp) month(start_idx:end_idx) = 1 end where end if + if (any(day(start_idx:end_idx) .lt. 0._wp)) then + print*,'Some of values of the input day field are masked. Replacing with 1 so RTTOV will run.' + where (day(start_idx:end_idx) .lt. 0._wp) + day(start_idx:end_idx) = 1 + end where + end if if (any(hour(start_idx:end_idx) .lt. 0._wp)) then print*,'Some of values of the input hour field are masked. Replacing with 1 so RTTOV will run.' where (hour(start_idx:end_idx) .lt. 0._wp) @@ -552,10 +571,26 @@ program cosp2_test minute(start_idx:end_idx) = 1._wp end where end if + if (any(seconds(start_idx:end_idx) .lt. 0._wp)) then + print*,'Some of values of the input minute field are masked. Replacing with 1 so RTTOV will run.' + where (seconds(start_idx:end_idx) .lt. 0._wp) + seconds(start_idx:end_idx) = 1._wp + end where + end if - ! Time information + ! Time information (should depreciate soon) cospstateIN%month = month(start_idx:end_idx) cospstateIN%time_frac = (60*hour(start_idx:end_idx) + minute(start_idx:end_idx)) / (24*60) ! Time (UTC) expressed as a fraction on [0,1] + + ! Read in date and time objects for RTTOV + cospstateIN%rttov_date(:,1) = year(start_idx:end_idx) + cospstateIN%rttov_date(:,2) = month(start_idx:end_idx) + cospstateIN%rttov_date(:,3) = day(start_idx:end_idx) + + cospstateIN%rttov_time(:,1) = hour(start_idx:end_idx) + cospstateIN%rttov_time(:,2) = minute(start_idx:end_idx) + cospstateIN%rttov_time(:,3) = seconds(start_idx:end_idx) + cospstateIN%sza = 0._wp ! => null() didn't work. ! JKS nothing passed in the UKMO input. ! From the data input file @@ -1174,6 +1209,7 @@ subroutine construct_cospstateIN(npoints,nlevels,y) y%DeffLiq(nPoints,nLevels),y%DeffIce(nPoints,nLevels), & y%fl_snow(nPoints,nLevels),y%fl_rain(nPoints,nLevels), & y%tca(nPoints,nLevels),y%hgt_matrix_half(nPoints,nlevels), & + y%rttov_date(nPoints,3),y%rttov_time(nPoints,3), & y%month(nPoints),y%time_frac(nPoints),y%sza(nPoints)) ! JKS - I should make this optional to save space. @@ -1603,6 +1639,8 @@ subroutine destroy_cospstateIN(y) if (allocated(y%hgt_matrix)) deallocate(y%hgt_matrix) if (allocated(y%hgt_matrix_half)) deallocate(y%hgt_matrix_half) if (allocated(y%surfelev)) deallocate(y%surfelev) + if (allocated(y%rttov_date)) deallocate(y%rttov_date) + if (allocated(y%rttov_time)) deallocate(y%rttov_time) if (allocated(y%month)) deallocate(y%month) if (allocated(y%time_frac)) deallocate(y%time_frac) if (allocated(y%sza)) deallocate(y%sza) diff --git a/src/cosp.F90 b/src/cosp.F90 index b11bc6fe31..e3407f9c70 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -128,6 +128,8 @@ MODULE MOD_COSP cloudLiq, & ! Cloud liquid water mixing ratio (kg/kg) DeffLiq, & ! Cloud liquid effective diameter (um) DeffIce, & ! Cloud ice effective diameter (um) + rttov_date, & ! Date of the profile as year (e.g. 2013), month (1-12), and day (1-31) + rttov_time, & ! Time of profile as hour, minute, second. emis_in, & ! Surface emissivity (point,channel) (1) refl_in, & ! Surface reflectance (point,channel) (1) fl_rain, & ! Precipitation (rain) flux (kg/m2/s) @@ -789,6 +791,8 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Below only needed for all-sky RTTOV calculation rttovIN%month => cospgridIN%month rttovIN%time_frac => cospgridIN%time_frac + rttovIN%rttov_date => cospgridIN%rttov_date + rttovIN%rttov_time => cospgridIN%rttov_time rttovIN%sza => cospgridIN%sza ! JKS make optional? Defeats the purpose of the "associated" check in cosp_rttov_v13. rttovIN%tca => cospgridIN%tca rttovIN%cldLiq => cospgridIN%cloudLiq @@ -2723,6 +2727,16 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%fl_snow has not been allocated' alloc_status = .false. endif + if (.not. allocated(cospgridIN%rttov_date)) then + nError=nError+1 + errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%rttov_date has not been allocated' + alloc_status = .false. + endif + if (.not. allocated(cospgridIN%rttov_time)) then + nError=nError+1 + errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%rttov_time has not been allocated' + alloc_status = .false. + endif if (.not. alloc_status) then Lrttov_column = .false. if (allocated(cospOUT%rttov_outputs)) then @@ -3491,6 +3505,25 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospIN%time_frac contains values out of range' Lrttov_column = .false. + if (allocated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if + endif + if (any(cospgridIN%rttov_time(:,1) .lt. 0 .OR. cospgridIN%rttov_time(:,1) .gt. 24)) then ! rttov_time(1), hour on [0,24] + nError=nError+1 + errorMessage(nError) = 'ERROR: COSP input variable: cospIN%rttov_time(1) contains values out of range' + Lrttov_column = .false. if (allocated(cospOUT%rttov_outputs)) then do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 @@ -3505,7 +3538,102 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF end do end if - endif + endif + if (any(cospgridIN%rttov_time(:,2) .lt. 0 .OR. cospgridIN%rttov_time(:,2) .gt. 60)) then ! rttov_time(2), minute on [0,60] + nError=nError+1 + errorMessage(nError) = 'ERROR: COSP input variable: cospIN%rttov_time(2) contains values out of range' + Lrttov_column = .false. + if (allocated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if + endif + if (any(cospgridIN%rttov_time(:,3) .lt. 0 .OR. cospgridIN%rttov_time(:,3) .gt. 60)) then ! rttov_time(3), second on [0,60] + nError=nError+1 + errorMessage(nError) = 'ERROR: COSP input variable: cospIN%rttov_time(3) contains values out of range' + Lrttov_column = .false. + if (allocated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if + endif + if (any(cospgridIN%rttov_date(:,1) .lt. 0)) then ! rttov_date(1), year on [0,60] + nError=nError+1 + errorMessage(nError) = 'ERROR: COSP input variable: cospIN%rttov_date(1) contains values out of range' + Lrttov_column = .false. + if (allocated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if + endif + if (any(cospgridIN%rttov_date(:,2) .lt. 0 .OR. cospgridIN%rttov_date(:,2) .gt. 12)) then ! rttov_date(2), month on [0,12] + nError=nError+1 + errorMessage(nError) = 'ERROR: COSP input variable: cospIN%rttov_date(2) contains values out of range' + Lrttov_column = .false. + if (allocated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if + endif + if (any(cospgridIN%rttov_date(:,3) .lt. 0 .OR. cospgridIN%rttov_date(:,3) .gt. 366)) then ! rttov_date(3), day on [0,366] + nError=nError+1 + errorMessage(nError) = 'ERROR: COSP input variable: cospIN%rttov_date(3) contains values out of range' + Lrttov_column = .false. + if (allocated(cospOUT%rttov_outputs)) then + do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 + if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF + if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF + end do + end if + endif endif ! COSP_INPUTS diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 3b7ddb3187..2791ebcf07 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -75,6 +75,7 @@ MODULE MOD_COSP_RTTOV_INTERFACE Lrttov_cld, & Lrttov_aer, & Lrttov_pc, & + Lrttov_solar, & user_tracegas_input character(len=256) :: & rttov_srcDir, & @@ -213,6 +214,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & logical :: Lrttov_cldparam logical :: Lrttov_aerparam logical :: Lrttov_pc + logical :: Lrttov_solar logical :: Lchannel_filepath logical :: user_tracegas_input logical :: SO2_data @@ -260,6 +262,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & Lrttov_cldparam = .false. Lrttov_aerparam = .false. Lrttov_pc = .false. + Lrttov_solar = .false. Lchannel_filepath = .false. SO2_data = .false. N2O_data = .false. @@ -273,7 +276,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & ! Read RTTOV namelist fields namelist/RTTOV_INPUT/Lrttov_bt,Lrttov_rad,Lrttov_refl,Lrttov_cld, & ! Logicals for RTTOV configuration Lrttov_aer,Lrttov_cldparam,Lrttov_aerparam, & ! - Lrttov_pc,nchannels_rec,Lchannel_filepath, & + Lrttov_pc,Lrttov_solar,nchannels_rec,Lchannel_filepath, & channel_filepath,rttov_srcDir,rttov_coefDir, & OD_coef_filepath,aer_coef_filepath,cld_coef_filepath, & PC_coef_filepath, & @@ -393,7 +396,8 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & rttov_config % opts % rt_mw % supply_foam_fraction = .false. ! UV/visible/IR-only radiative transfer options - rttov_config % opts % rt_ir % addsolar = .false. + rttov_config % opts % rt_ir % addsolar = Lrttov_solar + rttov_config % Lrttov_solar = Lrttov_solar rttov_config % opts % rt_ir % rayleigh_max_wavelength = 2._wp ! 2um rttov_config % opts % rt_ir % rayleigh_min_pressure = 0._wp ! 0 hPa rttov_config % opts % rt_ir % rayleigh_single_scatt = .true. @@ -416,7 +420,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & rttov_config % opts % rt_ir % cloud_overlap = 1 ! Maximum-random overlap rttov_config % opts % rt_ir % cc_low_cloud_top = 750_wp ! 750 hPa. Only applies when cloud_overlap=2. rttov_config % opts % rt_ir % ir_scatt_model = 2 - rttov_config % opts % rt_ir % vis_scatt_model = 1 + rttov_config % opts % rt_ir % vis_scatt_model = 1 ! Scattering model to use for solar source term: 1 => DOM; 2 => single-scattering; 3 => MFASIS-LUT; 4 => MFASIS-NN (default = 1); only applies when addclouds or addaerosl is true and addsolar is true. JKS note, DOM is the most expensive, MFASIS-NN might be a better option rttov_config % opts % rt_ir % dom_nstreams = 8 rttov_config % opts % rt_ir % dom_accuracy = 0._wp ! only applies when addclouds or addaerosl is true and DOM is selected as a scattering solver. rttov_config % opts % rt_ir % dom_opdep_threshold = 0._wp @@ -554,6 +558,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & print*,'rttov_config % Lrttov_cld: ',rttov_config % Lrttov_cld print*,'rttov_config % Lrttov_aer: ',rttov_config % Lrttov_aer print*,'rttov_config % Lrttov_pc: ',rttov_config % Lrttov_pc + print*,'rttov_config % Lrttov_solar: ',rttov_config % Lrttov_solar print*,'rttov_config % rttov_Nlocaltime: ',rttov_config % rttov_Nlocaltime print*,'rttov_config % rttov_localtime: ',rttov_config % rttov_localtime print*,'rttov_config % rttov_localtime_width: ',rttov_config % rttov_localtime_width @@ -705,6 +710,7 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, call cosp_rttov_construct_profiles(rttovIN, & rttovConfig % Lrttov_cld, & rttovConfig % Lrttov_aer, & + rttovConfig % Lrttov_solar, & rttovConfig % user_tracegas_input, & rttovConfig % opts % rt_all % CO2_data, & rttovConfig % opts % rt_all % CH4_data, & @@ -833,6 +839,7 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, call cosp_rttov_construct_profiles(rttovIN, & rttovConfig % Lrttov_cld, & rttovConfig % Lrttov_aer, & + rttovConfig % Lrttov_solar, & rttovConfig % user_tracegas_input, & rttovConfig % opts % rt_all % CO2_data, & rttovConfig % opts % rt_all % CH4_data, & diff --git a/src/simulator/rttov/cosp_rttovSTUB.F90 b/src/simulator/rttov/cosp_rttovSTUB.F90 index 2ff2ac306b..3b1ecdbdbf 100644 --- a/src/simulator/rttov/cosp_rttovSTUB.F90 +++ b/src/simulator/rttov/cosp_rttovSTUB.F90 @@ -87,9 +87,10 @@ MODULE MOD_COSP_RTTOV ch4, & ! Methane n2o, & ! n2o co, & ! Carbon monoxide - so2 ! Sulfur dioxide + so2, & ! Sulfur dioxide + rttov_date, & ! Date of the profile as year (e.g. 2013), month (1-12), and day (1-31) + rttov_time, & ! Time of profile as hour, minute, second. ! These fields below are needed ONLY for the RTTOV all-sky brightness temperature - real(wp),dimension(:,:),pointer :: & tca, & ! Cloud fraction cldIce, & ! Cloud ice cldLiq, & ! Cloud liquid diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 6472b80dbc..1de2eb02e9 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -34,8 +34,6 @@ ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% module mod_cosp_rttov - use rttov_const, only : errorstatus_success, errorstatus_fatal, & - platform_name,inst_name ! Use RTTOV v13 types here, more may be needed use rttov_types, only : rttov_options,rttov_coefs,rttov_profile, & rttov_transmission,rttov_radiance,rttov_chanprof, & @@ -88,7 +86,7 @@ module mod_cosp_rttov #include "rttov_bpr_calc.interface" #include "rttov_bpr_dealloc.interface" #include "rttov_legcoef_calc.interface" - +#include "rttov_calc_solar_angles.interface" ! Module parameters integer, parameter :: maxlim = 10000 @@ -103,8 +101,6 @@ module mod_cosp_rttov ! module-wides variables for input !==================== - integer(kind=jpim) :: dosolar - TYPE(rttov_chanprof), POINTER :: chanprof(:) => NULL() ! Input channel/profile list LOGICAL(KIND=jplm), POINTER :: calcemis(:) => NULL() ! Flag to indicate calculation of emissivity within RTTOV TYPE(rttov_emissivity), POINTER :: emissivity(:) => NULL() ! Input/output surface emissivity @@ -163,9 +159,10 @@ module mod_cosp_rttov ch4, & ! Methane n2o, & ! n2o co, & ! Carbon monoxide - so2 ! Sulfur dioxide + so2, & ! Sulfur dioxide + rttov_date, & ! Date of the profile as year (e.g. 2013), month (1-12), and day (1-31) + rttov_time, & ! Time of profile as hour, minute, second. ! These fields below are needed ONLY for the RTTOV all-sky brightness temperature - real(wp),dimension(:,:),pointer :: & tca, & ! Cloud fraction cldIce, & ! Cloud ice cldLiq, & ! Cloud liquid @@ -521,6 +518,7 @@ end subroutine cosp_pc_rttov_allocate subroutine cosp_rttov_construct_profiles(rttovIN, & Lrttov_cld, & Lrttov_aer, & + Lrttov_solar, & Luser_tracegas, & Ldo_co2, & Ldo_ch4, & @@ -543,6 +541,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & logical,intent(in) :: & Lrttov_cld, & Lrttov_aer, & + Lrttov_solar, & Luser_tracegas, & ! Use user-supplied trace gas columns from instrument namelists. Ldo_co2, & Ldo_ch4, & @@ -757,14 +756,42 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & if (Lrttov_aer) then ! Set aerosol mass mixing ratio units - profiles%mmr_cldaer = .true. ! kg/kg for cloud and aerosol (default) - + profiles%mmr_cldaer = .true. ! kg/kg for cloud and aerosol (default) ! Read in aerosol profiles -! do i = 1, rttovIN%nPoints -! profiles(i)%aerosols(naertyp,nlayers) = ! Aerosols in different modes (see User Guide pg 80) -! +! j = 0 ! Initialize input +! do i = 1,rttovIN%nPoints +! if (inst_swath_mask(i)) then ! only added masked columns to profiles +! j = j + 1 ! Increment profile counter +! profiles(j)%aerosols(naertyp,nlayers) = rttovIN%aerosols ! Aerosols in different modes (see User Guide pg 80) +! end if ! end do - endif + end if + + if (Lrttov_solar) then + + print*,'rttovIN%sza(:): ',rttovIN%sza(:) + + ! Populate longitude, latitude, time, and date profile fields + ! Read in aerosol profiles + j = 0 ! Initialize input + do i = 1,rttovIN%nPoints + if (inst_swath_mask(i)) then ! only added masked columns to profiles + j = j + 1 ! Increment profile counter + profiles(j)%date(:) = rttovIN%rttov_date(i,:) + profiles(j)%time(:) = rttovIN%rttov_time(i,:) + end if + end do + + ! Call functions to calculate the appropriate solar zenith and azimuthal angles. + call RTTOV_CALC_SOLAR_ANGLES(errorstatus, profiles) + call rttov_error('Error when calling RTTOV_CALC_SOLAR_ANGLES', lalloc = .false.) + + !call RTTOV_CALC_GEO_SAT_ANGLES + + print*,'profiles(:))%sunzenangle: ',profiles(:)%sunzenangle + print*,'profiles(:))%sunazangle: ',profiles(:)%sunazangle + + end if ! JKS - nothing to check here, this will never trigger. call rttov_error('error in aerosol profile initialization' , lalloc = .true.) From 8a79c94e8d04b623e2cbba4de6fb9e74ecabdf25 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 17 Oct 2023 13:30:43 -0600 Subject: [PATCH 094/159] Minor updates --- .../run/instrument_nls/cosp2_rttov_inst1.txt | 2 +- src/simulator/cosp_rttov_interface_v13.F90 | 25 +++++++++++++++++-- src/simulator/rttov/cosp_rttov_v13.F90 | 16 ++++++------ 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/driver/run/instrument_nls/cosp2_rttov_inst1.txt b/driver/run/instrument_nls/cosp2_rttov_inst1.txt index 84dcd736f9..0c74f31d5f 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst1.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst1.txt @@ -28,7 +28,7 @@ !-------------- Logical for constructing outputs and determining settings Lrttov_bt=.true., ! Calculate RTTOV brightness temps Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_refl=.true., ! Calculate RTTOV reflectivities Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values Lrttov_aer=.true., ! Calculate RTTOV all-sky + cloudy-sky values Lrttov_cldparam=.false., ! Use user input cloud optical parameters diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 2791ebcf07..65302934df 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -470,6 +470,27 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & endif ! JKS To-do: include opts_scatt settings (user guide pg 161) + if (rttov_config % Lrttov_mwscatt) then + opts_scatt%config%do_checkinput = .true. + opts_scatt%config%apply_reg_limits = .false. + opts_scatt%config%verbose = .true. + opts_scatt%ozone_data = .false. ! Default + opts_scatt%use_t2m_opdep = .true. + opts_scatt%use_q2m = .true. + opts_scatt%use_tskin_eff = .false. + opts_scatt%addrefrac = .true. + opts_scatt%rad_down_lin_tau = .false. ! Recommended + opts_scatt%interp_mode = 1 ! Default + opts_scatt%lgradp = .false. + opts_scatt%fastem_version = 6 ! Default + opts_scatt %supply_foam_fraction = .false. + opts_scatt%lusercfrac = .false. ! User supplied cloud fraction in rttov_profile_cloud. Maybe set to true? pg 164 + opts_scatt%cc_threshold = 0.001_wp ! Default +! opts_scatt%pol_mode = +! opts_scatt%ice_polarisation = + opts_scatt%hydro_cfrac_tlad = .true. ! Default + opts_scatt%zero_hydro_tlad = .false. ! Default + end if ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 2. Read coefficients (from RTTOV example files) @@ -495,8 +516,8 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & if (nchannels_rec > rttov_config % coefs % coef % fmv_chn) then nchannels_rec = rttov_config % coefs % coef % fmv_chn print*,'nchannels_rec cap hit' - endif - endif + end if + end if ! We aren't checking an allocation steps so this seems more appropriate. call rttov_error('fatal error reading coefficients' , lalloc = .false.) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 1de2eb02e9..9cc40aad7c 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -652,11 +652,11 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & profiles(j)%longitude = rttovIN%longitude(i) profiles(j)%elevation = rttovIN%h_surf(i) * 1e-3 ! Convert m to km - ! Solar angles. + ! Solar angles. This is overwritten in the solar code now. if (associated(rttovIN%sza)) then profiles(j)%sunzenangle = rttovIN%sza(i) ! SZA in degrees else - print*,'No solar zenith angle passed. Setting to zero.' + if (verbose) print*,'No solar zenith angle passed. Setting to zero.' profiles(j)%sunzenangle = 0. end if profiles(j)%sunazangle = 0. ! hard-coded in like rttov9 @@ -769,8 +769,6 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & if (Lrttov_solar) then - print*,'rttovIN%sza(:): ',rttovIN%sza(:) - ! Populate longitude, latitude, time, and date profile fields ! Read in aerosol profiles j = 0 ! Initialize input @@ -787,10 +785,12 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & call rttov_error('Error when calling RTTOV_CALC_SOLAR_ANGLES', lalloc = .false.) !call RTTOV_CALC_GEO_SAT_ANGLES - - print*,'profiles(:))%sunzenangle: ',profiles(:)%sunzenangle - print*,'profiles(:))%sunazangle: ',profiles(:)%sunazangle - + if (verbose) then + print*,'profiles(:))%sunzenangle: ',profiles(:)%sunzenangle + print*,'profiles(:))%sunazangle: ',profiles(:)%sunazangle + print*,'profiles(:))%zenangle: ',profiles(:)%zenangle + print*,'profiles(:))%azangle: ',profiles(:)%azangle + end if end if ! JKS - nothing to check here, this will never trigger. From caf9d6c96d3b52d3f72055d22039ddbafd0bbf4a Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 17 Oct 2023 14:47:05 -0600 Subject: [PATCH 095/159] Include necessary objects and links for RTTOV-scatt --- src/simulator/cosp_rttov_interface_v13.F90 | 51 +++++++++++++--------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 65302934df..b595177c8d 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -44,7 +44,9 @@ MODULE MOD_COSP_RTTOV_INTERFACE ! rttov_types contains definitions of all RTTOV data types USE rttov_types, ONLY : & rttov_options, & - rttov_coefs + rttov_options_scatt, & + rttov_coefs, & + rttov_scatt_coef ! jpim, jprb and jplm are the RTTOV integer, real and logical KINDs USE parkind1, ONLY : jpim, jprb, jplm @@ -53,6 +55,12 @@ MODULE MOD_COSP_RTTOV_INTERFACE IMPLICIT NONE +#include "rttov_scatt.interface" +#include "rttov_parallel_scatt.interface" +#include "rttov_read_scattcoeffs.interface" +#include "rttov_dealloc_scattcoeffs.interface" +#include "rttov_scatt_setupindex.interface" + #include "rttov_read_coefs.interface" #include "rttov_user_options_checkinput.interface" #include "rttov_print_opts.interface" @@ -76,6 +84,7 @@ MODULE MOD_COSP_RTTOV_INTERFACE Lrttov_aer, & Lrttov_pc, & Lrttov_solar, & + Lrttov_mwscatt, & user_tracegas_input character(len=256) :: & rttov_srcDir, & @@ -108,6 +117,8 @@ MODULE MOD_COSP_RTTOV_INTERFACE rttov_localtime_width(:) type(rttov_options) :: & opts ! RTTOV options structure + type(rttov_options_scatt) :: & + opts_scatt type(rttov_coefs) :: & coefs ! RTTOV coefficients structure logical(KIND=jplm), allocatable :: & @@ -471,25 +482,25 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & ! JKS To-do: include opts_scatt settings (user guide pg 161) if (rttov_config % Lrttov_mwscatt) then - opts_scatt%config%do_checkinput = .true. - opts_scatt%config%apply_reg_limits = .false. - opts_scatt%config%verbose = .true. - opts_scatt%ozone_data = .false. ! Default - opts_scatt%use_t2m_opdep = .true. - opts_scatt%use_q2m = .true. - opts_scatt%use_tskin_eff = .false. - opts_scatt%addrefrac = .true. - opts_scatt%rad_down_lin_tau = .false. ! Recommended - opts_scatt%interp_mode = 1 ! Default - opts_scatt%lgradp = .false. - opts_scatt%fastem_version = 6 ! Default - opts_scatt %supply_foam_fraction = .false. - opts_scatt%lusercfrac = .false. ! User supplied cloud fraction in rttov_profile_cloud. Maybe set to true? pg 164 - opts_scatt%cc_threshold = 0.001_wp ! Default -! opts_scatt%pol_mode = -! opts_scatt%ice_polarisation = - opts_scatt%hydro_cfrac_tlad = .true. ! Default - opts_scatt%zero_hydro_tlad = .false. ! Default + rttov_config % opts_scatt % config % do_checkinput = .true. + rttov_config % opts_scatt % config % apply_reg_limits = .false. + rttov_config % opts_scatt % config % verbose = .true. + rttov_config % opts_scatt % ozone_data = .false. ! Default + rttov_config % opts_scatt % use_t2m_opdep = .true. + rttov_config % opts_scatt % use_q2m = .true. + rttov_config % opts_scatt % use_tskin_eff = .false. + rttov_config % opts_scatt % addrefrac = .true. + rttov_config % opts_scatt % rad_down_lin_tau = .false. ! Recommended + rttov_config % opts_scatt % interp_mode = 1 ! Default + rttov_config % opts_scatt % lgradp = .false. + rttov_config % opts_scatt % fastem_version = 6 ! Default + rttov_config % opts_scatt % supply_foam_fraction = .false. + rttov_config % opts_scatt % lusercfrac = .false. ! User supplied cloud fraction in rttov_profile_cloud. Maybe set to true? pg 164 + rttov_config % opts_scatt % cc_threshold = 0.001_wp ! Default +! rttov_config % opts_scatt % pol_mode = +! rttov_config % opts_scatt % ice_polarisation = + rttov_config % opts_scatt % hydro_cfrac_tlad = .true. ! Default + rttov_config % opts_scatt % zero_hydro_tlad = .false. ! Default end if ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From dfe7a68c5e9d038e70162e0cec5cb4f437dab467 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 7 Nov 2023 15:53:53 -0700 Subject: [PATCH 096/159] Cleaned up print statements and old "month" and "time_frac" variables. --- build/Makefile | 5 +- .../run/instrument_nls/cosp2_rttov_inst1.txt | 2 +- driver/src/cosp2_test.F90 | 9 +-- src/cosp.F90 | 72 ------------------- src/simulator/cosp_rttov_interface_v13.F90 | 20 +++--- 5 files changed, 17 insertions(+), 91 deletions(-) diff --git a/build/Makefile b/build/Makefile index 0cb618401d..39dbf22251 100644 --- a/build/Makefile +++ b/build/Makefile @@ -31,9 +31,9 @@ LDFLAGS += $(NC_LIB) -lnetcdff LDFLAGS += -L. -lcosp -lsubcol -# Need additional load flags from Makefile.rttov when linking to RTTOV +# Need additional load flags from Makefile.rttov when linking to RTTOV. May remove with improved linking. ifdef RTTOV -LDFLAGS += $(LIBS) $(LLIBS) $(LDFLAGS_NETCDF) $(LDFLAGS_HDF5) $(LDFLAGS_ARCH) $(LDFLAGS_LAPACK) +LDFLAGS += $(LLIBS) $(LDFLAGS_NETCDF) $(LDFLAGS_HDF5) $(LDFLAGS_ARCH) $(LDFLAGS_LAPACK) endif # Rules @@ -72,6 +72,7 @@ endif LIBRARY = libcosp.a +# Jonah tried to link in RTTOV to libcosp.a rather than cosp2_test. It didn't work. $(LIBRARY): $(COSP_OBJS) ar -rvs $(LIBRARY) $(COSP_OBJS) diff --git a/driver/run/instrument_nls/cosp2_rttov_inst1.txt b/driver/run/instrument_nls/cosp2_rttov_inst1.txt index 0c74f31d5f..d012d34407 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst1.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst1.txt @@ -72,7 +72,7 @@ npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) !-------------- RTTOV Other --------------- ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=16, + rttov_nthreads=1, rttov_ZenAng=0.0, ! Satellite Zenith Angle ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index c536d60aea..c51b422566 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -577,10 +577,6 @@ program cosp2_test seconds(start_idx:end_idx) = 1._wp end where end if - - ! Time information (should depreciate soon) - cospstateIN%month = month(start_idx:end_idx) - cospstateIN%time_frac = (60*hour(start_idx:end_idx) + minute(start_idx:end_idx)) / (24*60) ! Time (UTC) expressed as a fraction on [0,1] ! Read in date and time objects for RTTOV cospstateIN%rttov_date(:,1) = year(start_idx:end_idx) @@ -1209,8 +1205,7 @@ subroutine construct_cospstateIN(npoints,nlevels,y) y%DeffLiq(nPoints,nLevels),y%DeffIce(nPoints,nLevels), & y%fl_snow(nPoints,nLevels),y%fl_rain(nPoints,nLevels), & y%tca(nPoints,nLevels),y%hgt_matrix_half(nPoints,nlevels), & - y%rttov_date(nPoints,3),y%rttov_time(nPoints,3), & - y%month(nPoints),y%time_frac(nPoints),y%sza(nPoints)) + y%rttov_date(nPoints,3),y%rttov_time(nPoints,3),y%sza(nPoints)) ! JKS - I should make this optional to save space. ! do i=1,N_rttov_instruments @@ -1641,8 +1636,6 @@ subroutine destroy_cospstateIN(y) if (allocated(y%surfelev)) deallocate(y%surfelev) if (allocated(y%rttov_date)) deallocate(y%rttov_date) if (allocated(y%rttov_time)) deallocate(y%rttov_time) - if (allocated(y%month)) deallocate(y%month) - if (allocated(y%time_frac)) deallocate(y%time_frac) if (allocated(y%sza)) deallocate(y%sza) if (allocated(y%co2)) deallocate(y%co2) if (allocated(y%ch4)) deallocate(y%ch4) diff --git a/src/cosp.F90 b/src/cosp.F90 index e3407f9c70..3ce55bbc74 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -110,8 +110,6 @@ MODULE MOD_COSP surfelev, & ! Surface Elevation (m) rttov_sfcmask ! Mask for RTTOV surface types (0 for ocean, 1 for land, 2 for sea ice) ! Fields used ONLY by RTTOV - integer,allocatable,dimension(:) :: & - month ! Month for surface emissivty atlas (1-12) real(wp),allocatable,dimension(:) :: & u_sfc, & ! Surface u-wind (m/s) v_sfc, & ! Surface v-wind (m/s) @@ -119,7 +117,6 @@ MODULE MOD_COSP q2m, & ! 2-meter specific humidity (kg/kg) lat, & ! Latitude (deg) lon, & ! Longitude (deg) - time_frac, & ! Time (UTC) expressed as a fraction on [0,1] sza ! Solar Zenith Angle in degrees real(wp),allocatable,dimension(:,:) :: & o3, & ! Ozone (kg/kg) @@ -789,8 +786,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) rttovIN%q => cospgridIN%qv rttovIN%o3 => cospgridIN%o3 ! Below only needed for all-sky RTTOV calculation - rttovIN%month => cospgridIN%month - rttovIN%time_frac => cospgridIN%time_frac rttovIN%rttov_date => cospgridIN%rttov_date rttovIN%rttov_time => cospgridIN%rttov_time rttovIN%sza => cospgridIN%sza ! JKS make optional? Defeats the purpose of the "associated" check in cosp_rttov_v13. @@ -1629,11 +1624,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospOUT % rttov_outputs(i) % rad_cloudy(ij:ik,:) = rttov_rad_cloudy if (associated(cospOUT % rttov_outputs(i) % refl_total)) & cospOUT % rttov_outputs(i) % refl_total(ij:ik,:) = rttov_refl_total - if (verbose) then - print*,'associated(cospOUT % rttov_outputs(i) % bt_total): ',associated(cospOUT % rttov_outputs(i) % bt_total) - print*,'associated(cospOUT % rttov_outputs(i) % refl_total): ',associated(cospOUT % rttov_outputs(i) % refl_total) - print*,'associated(cospOUT % rttov_outputs(i) % refl_clear): ',associated(cospOUT % rttov_outputs(i) % refl_clear) - end if if (associated(cospOUT % rttov_outputs(i) % refl_clear)) & cospOUT % rttov_outputs(i) % refl_clear(ij:ik,:) = rttov_refl_clear endif @@ -2692,16 +2682,6 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%tca has not been allocated' alloc_status = .false. endif - if (.not. allocated(cospgridIN%month)) then - nError=nError+1 - errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%month has not been allocated' - alloc_status = .false. - endif - if (.not. allocated(cospgridIN%time_frac)) then - nError=nError+1 - errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%time_frac has not been allocated' - alloc_status = .false. - endif if (.not. allocated(cospgridIN%sza)) then nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable (RTTOV): cospgridIN%sza has not been allocated' @@ -3482,44 +3462,6 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, end do end if endif - if (any(cospgridIN%month .lt. 1 .OR. cospgridIN%month .gt. 12)) then ! month on [1,12] - nError=nError+1 - errorMessage(nError) = 'ERROR: COSP input variable: cospIN%month contains values out of range' - Lrttov_column = .false. - if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument - if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 - if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF - end do - end if - endif - if (any(cospgridIN%time_frac .lt. 0 .OR. cospgridIN%time_frac .gt. 1)) then ! time_frac on [0,1] - nError=nError+1 - errorMessage(nError) = 'ERROR: COSP input variable: cospIN%time_frac contains values out of range' - Lrttov_column = .false. - if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument - if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 - if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%rad_total)) cospOUT%rttov_outputs(i)%rad_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%rad_clear)) cospOUT%rttov_outputs(i)%rad_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%rad_cloudy)) cospOUT%rttov_outputs(i)%rad_cloudy(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%refl_total)) cospOUT%rttov_outputs(i)%refl_total(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%refl_clear)) cospOUT%rttov_outputs(i)%refl_clear(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%bt_total_pc)) cospOUT%rttov_outputs(i)%bt_total_pc(:,:) = R_UNDEF - if (associated(cospOUT%rttov_outputs(i)%rad_total_pc)) cospOUT%rttov_outputs(i)%rad_total_pc(:,:) = R_UNDEF - end do - end if - endif if (any(cospgridIN%rttov_time(:,1) .lt. 0 .OR. cospgridIN%rttov_time(:,1) .gt. 24)) then ! rttov_time(1), hour on [0,24] nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospIN%rttov_time(1) contains values out of range' @@ -4434,19 +4376,6 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lrttov_column = .false. nError=nError+1 errorMessage(nError) = 'ERROR(rttov_simulator): The number of points in the input fields are inconsistent' - print*,'size(cospgridIN%pfull,1): ',size(cospgridIN%pfull,1) - print*,'size(cospgridIN%at,1): ',size(cospgridIN%at,1) - print*,'size(cospgridIN%qv,1): ',size(cospgridIN%qv,1) - print*,'size(cospgridIN%hgt_matrix_half,1): ',size(cospgridIN%hgt_matrix_half,1) - print*,'size(cospgridIN%u_sfc): ',size(cospgridIN%u_sfc) - print*,'size(cospgridIN%v_sfc): ',size(cospgridIN%v_sfc) - print*,'size(cospgridIN%skt): ',size(cospgridIN%skt) - print*,'size(cospgridIN%phalf,1): ',size(cospgridIN%phalf,1) - print*,'size(cospgridIN%cloudIce,1): ',size(cospgridIN%cloudIce,1) - print*,'size(cospgridIN%cloudLiq,1): ',size(cospgridIN%cloudLiq,1) - print*,'size(cospgridIN%rttov_sfcmask): ',size(cospgridIN%rttov_sfcmask) - print*,'size(cospgridIN%lon): ',size(cospgridIN%lon) - print*,'size(cospgridIN%lat): ',size(cospgridIN%lat) endif if (size(cospgridIN%pfull,2) .ne. cospIN%Nlevels .OR. & size(cospgridIN%at,2) .ne. cospIN%Nlevels .OR. & @@ -4456,7 +4385,6 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lrttov_column = .false. nError=nError+1 errorMessage(nError) = 'ERROR(rttov_simulator): The number of levels in the input fields are inconsistent' - endif endif end subroutine cosp_errorCheck diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index b595177c8d..423d72656d 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -526,7 +526,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & ! Ensure input number of channels is not higher than number stored in coefficient file if (nchannels_rec > rttov_config % coefs % coef % fmv_chn) then nchannels_rec = rttov_config % coefs % coef % fmv_chn - print*,'nchannels_rec cap hit' + if (verbose) print*,'nchannels_rec cap hit' end if end if @@ -723,7 +723,7 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, call cpu_time(driver_time(1)) if (allocated(rttovConfig % swath_mask)) deallocate(rttovConfig % swath_mask) allocate(rttovConfig % swath_mask(rttovIN % nPoints)) - if (verbose) print*,'Beginning "cosp_rttov_allocate".' +! if (verbose) print*,'Beginning "cosp_rttov_allocate".' call cosp_rttov_allocate(rttovIN, & rttovConfig % nChannels_rec, & rttovConfig % opts, & @@ -737,8 +737,7 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % swath_mask) call cpu_time(driver_time(2)) - if (verbose) print*,'Beginning "cosp_rttov_construct_profiles".' - +! if (verbose) print*,'Beginning "cosp_rttov_construct_profiles".' call cosp_rttov_construct_profiles(rttovIN, & rttovConfig % Lrttov_cld, & rttovConfig % Lrttov_aer, & @@ -762,7 +761,7 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, call cpu_time(driver_time(3)) - if (verbose) print*,'Beginning "cosp_rttov_setup_emissivity_reflectance".' +! if (verbose) print*,'Beginning "cosp_rttov_setup_emissivity_reflectance".' if (associated(rttovIN % emis_grey)) then call cosp_rttov_setup_emissivity_reflectance(emis_grey = rttovIN % emis_grey) ! Config agnostic after allocate step. else @@ -770,14 +769,14 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, end if call cpu_time(driver_time(4)) - if (verbose) print*,'Beginning "cosp_rttov_call_direct".' +! if (verbose) print*,'Beginning "cosp_rttov_call_direct".' call cosp_rttov_call_direct(rttovConfig % rttov_direct_nthreads, & rttovConfig % opts, & rttovConfig % coefs) call cpu_time(driver_time(5)) - if (verbose) print*,'Beginning "cosp_rttov_save_output".' +! if (verbose) print*,'Beginning "cosp_rttov_save_output".' call cosp_rttov_save_output(rttovIN % nPoints, & rttovConfig % nchan_out, & rttovConfig % swath_mask, & @@ -791,7 +790,7 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, refl_total,refl_clear) call cpu_time(driver_time(6)) - if (verbose) print*,'Beginning "cosp_rttov_deallocate_profiles".' +! if (verbose) print*,'Beginning "cosp_rttov_deallocate_profiles".' call cosp_rttov_deallocate_profiles(rttovConfig % nprof, & rttovConfig % nchanprof, & rttovIN % nLevels, & @@ -854,6 +853,7 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, call cpu_time(driver_time(1)) if (allocated(rttovConfig % swath_mask)) deallocate(rttovConfig % swath_mask) allocate(rttovConfig % swath_mask(rttovIN % nPoints)) +! if (verbose) print*,'Beginning "cosp_pc_rttov_allocate".' call cosp_pc_rttov_allocate(rttovIN, & rttovConfig % PC_coef_filepath, & rttovConfig % coefs, & @@ -868,6 +868,7 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % iChannel_out, & rttovConfig % swath_mask) call cpu_time(driver_time(2)) +! if (verbose) print*,'Beginning "cosp_rttov_construct_profiles".' call cosp_rttov_construct_profiles(rttovIN, & rttovConfig % Lrttov_cld, & rttovConfig % Lrttov_aer, & @@ -891,6 +892,7 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, call cpu_time(driver_time(3)) call cosp_pc_rttov_setup_emissivity() call cpu_time(driver_time(4)) +! if (verbose) print*,'Beginning "cosp_pc_rttov_call_direct".' call cosp_pc_rttov_call_direct(rttovConfig % rttov_direct_nthreads, & rttovConfig % opts, & rttovConfig % coefs, & @@ -898,6 +900,7 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % iChannel_out) ! iChannel_out should have been updated call cpu_time(driver_time(5)) +! if (verbose) print*,'Beginning "cosp_pc_rttov_save_output".' call cosp_pc_rttov_save_output(rttovIN % nPoints, & rttovConfig % nchannels_rec, & rttovConfig % swath_mask, & @@ -907,6 +910,7 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rad_clear) call cpu_time(driver_time(6)) +! if (verbose) print*,'Beginning "cosp_pc_rttov_deallocate_profiles".' call cosp_pc_rttov_deallocate_profiles(rttovConfig % nprof, & rttovConfig % nchanprof, & rttovIN % nlevels, & From c11718519cd2e3c7e49bb3f2c6702dc3389aab05 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 7 Nov 2023 15:54:23 -0700 Subject: [PATCH 097/159] Updated swathing to read from new date and time arrays. --- src/simulator/rttov/cosp_rttov_v13.F90 | 29 +++++++------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 9cc40aad7c..83f226c872 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -131,8 +131,6 @@ module mod_cosp_rttov nSubCols ! Number of subcolumns real(kind=wp),pointer :: & emis_grey => null() - integer(kind=jpim),dimension(:),pointer :: & - month ! real(wp),dimension(:),pointer :: & ! surfem ! Surface emissivities for the channels ! refl, & ! Surface reflectances for the channels @@ -147,7 +145,6 @@ module mod_cosp_rttov sfcmask, & ! sea-land-ice mask (0=sea, 1=land, 2=seaice) latitude, & ! Latitude (degrees) longitude, & ! Longitude (degrees) - time_frac, & ! Fractional UTC time [0-1] sza => null() ! Solar zenith angle (deg) real(wp),dimension(:,:),pointer :: & p, & ! Pressure @ model levels @@ -258,7 +255,7 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & ! Iterate over local times do j=1,rttov_Nlocaltime ! Calculate the central longitude for each gridcell and orbit - sat_lon(:,j) = 15.0 * (rttov_localtime(j) - (rttovIN%time_frac * 24.0)) + sat_lon(:,j) = 15.0 * (rttov_localtime(j) - (rttovIN%rttov_time(:,1) + rttovIN%rttov_time(:,2) / 60)) ! Calculate distance (in degrees) from each grid cell to the satellite central long dlon(:,j) = mod((rttovIN%longitude - sat_lon(:,j) + 180.0), 360.0) - 180.0 ! calculate distance to satellite in km. Remember to convert to radians for cos/sine calls @@ -408,7 +405,7 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, ! Iterate over local times do j=1,rttov_Nlocaltime ! Calculate the central longitude for each gridcell and orbit - sat_lon(:,j) = 15.0 * (rttov_localtime(j) - (rttovIN%time_frac * 24.0)) + sat_lon(:,j) = 15.0 * (rttov_localtime(j) - (rttovIN%rttov_time(:,1) + rttovIN%rttov_time(:,2) / 60)) ! Calculate distance (in degrees) from each grid cell to the satellite central long dlon(:,j) = mod((rttovIN%longitude - sat_lon(:,j) + 180.0), 360.0) - 180.0 ! calculate distance to satellite in km. Remember to convert to radians for cos/sine calls @@ -580,14 +577,6 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & profiles(:)%gas_units = 1 ! kg/kg over moist air (default) - if (verbose) then - print*,'shape(rttovIN%co2): ',shape(rttovIN%co2) - print*,'shape(rttovIN%n2o): ',shape(rttovIN%n2o) - print*,'rttovIN%co2(1,:): ',rttovIN%co2(1,1:10) - print*,'rttovIN%n2o(1,:): ',rttovIN%n2o(1,1:10) -! print*,'rttovIN%t_skin: ',rttovIN%t_skin - end if - ! Iterate over all columns j = 0 ! Initialize input do i = 1, rttovIN%nPoints @@ -784,13 +773,12 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & call RTTOV_CALC_SOLAR_ANGLES(errorstatus, profiles) call rttov_error('Error when calling RTTOV_CALC_SOLAR_ANGLES', lalloc = .false.) - !call RTTOV_CALC_GEO_SAT_ANGLES - if (verbose) then - print*,'profiles(:))%sunzenangle: ',profiles(:)%sunzenangle - print*,'profiles(:))%sunazangle: ',profiles(:)%sunazangle - print*,'profiles(:))%zenangle: ',profiles(:)%zenangle - print*,'profiles(:))%azangle: ',profiles(:)%azangle - end if +! if (verbose) then +! print*,'profiles(:))%sunzenangle: ',profiles(:)%sunzenangle +! print*,'profiles(:))%sunazangle: ',profiles(:)%sunazangle +! print*,'profiles(:))%zenangle: ',profiles(:)%zenangle +! print*,'profiles(:))%azangle: ',profiles(:)%azangle +! end if end if ! JKS - nothing to check here, this will never trigger. @@ -884,7 +872,6 @@ subroutine cosp_rttov_call_direct(inst_nthreads, & print*,'shape(chanprof%chan): ',shape(chanprof%chan) print*,'shape(profiles): ',shape(profiles) ! print*,'shape(profiles(:)%q): ',shape(profiles(:)%q) -! print*,'shape(bt_total): ',shape(bt_total) end if From 2ffece35119b9a8a0fd2a246fb8c81582b83ca2d Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 21 Nov 2023 15:44:36 -0700 Subject: [PATCH 098/159] Update functioning code before threading fix --- driver/run/cosp2_input_rttov_nl.txt | 6 +- .../run/instrument_nls/cosp2_rttov_inst5.txt | 79 +++++++++++++++++++ .../cosp2_rttov_inst6_AIRS_CESM2.txt | 79 +++++++++++++++++++ .../run/rttov_channel_input_AIRS_subset.csv | 26 ++++++ src/cosp.F90 | 11 ++- src/simulator/cosp_rttov_interface_v13.F90 | 4 +- src/simulator/rttov/cosp_rttov_v13.F90 | 5 +- 7 files changed, 205 insertions(+), 5 deletions(-) create mode 100644 driver/run/instrument_nls/cosp2_rttov_inst5.txt create mode 100644 driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2.txt create mode 100644 driver/run/rttov_channel_input_AIRS_subset.csv diff --git a/driver/run/cosp2_input_rttov_nl.txt b/driver/run/cosp2_input_rttov_nl.txt index b32d34274c..98fc378781 100644 --- a/driver/run/cosp2_input_rttov_nl.txt +++ b/driver/run/cosp2_input_rttov_nl.txt @@ -82,8 +82,10 @@ !---------------------------------------------------------------------------------- !-------------- RTTOV inputs !---------------------------------------------------------------------------------- - rttov_Ninstruments=4, - rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt','instrument_nls/cosp2_rttov_inst4.txt', + rttov_Ninstruments=6, + rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt','instrument_nls/cosp2_rttov_inst4.txt','instrument_nls/cosp2_rttov_inst5.txt','instrument_nls/cosp2_rttov_inst6_AIRS_CESM2.txt', +! rttov_Ninstruments=4, +! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt','instrument_nls/cosp2_rttov_inst4.txt', ! rttov_Ninstruments=3, ! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt', ! rttov_Ninstruments=1, diff --git a/driver/run/instrument_nls/cosp2_rttov_inst5.txt b/driver/run/instrument_nls/cosp2_rttov_inst5.txt new file mode 100644 index 0000000000..1b70d5ba32 --- /dev/null +++ b/driver/run/instrument_nls/cosp2_rttov_inst5.txt @@ -0,0 +1,79 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.false., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_pc=.false., ! Run with PC-RTTOV + Lrttov_solar=.false., ! Do solar calculations + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=0, ! 2300 + !-------------- RTTOV Filepaths + Lchannel_filepath=.false., + channel_filepath='rttov_channel_input_AIRS.csv', + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='PREFIRE/rtcoef_prefire_1_tirs_o3co2.dat', +! aer_coef_filepath='cldaer_visir/scaercoef_eos_2_modis-shifted_cams.dat', +! cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_modis-shifted.dat', +! OD_coef_filepath='rttov9pred101L/rtcoef_eos_2_airs_pcrttov_compat.H5', +! aer_coef_filepath='cldaer_visir/scaercoef_eos_2_airs_cams.H5', +! cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_airs.H5', + PC_coef_filepath='pc/pccoef_eos_2_airs_landsea.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.false., + CO_data=.false., + CO2_data=.true., + CH4_data=.false., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=0.0, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at +/ diff --git a/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2.txt new file mode 100644 index 0000000000..2f7a579f43 --- /dev/null +++ b/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2.txt @@ -0,0 +1,79 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.true., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=26, ! do a selection of AIRS channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.true., + channel_filepath='rttov_channel_input_AIRS_subset.csv', + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='rttov13pred101L/rtcoef_eos_2_airs_7gas.H5', + aer_coef_filepath='cldaer_visir/scaercoef_eos_2_airs_cams.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_airs.H5', +! OD_coef_filepath='rttov13pred54L/rtcoef_ticfire_1_mbfiri_o3co2.dat', +! aer_coef_filepath='cldaer_visir/scaercoef_ticfire_1_mbfiri_cams.dat', +! cld_coef_filepath='cldaer_visir/sccldcoef_ticfire_1_mbfiri.dat', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.true., + CO_data=.false., + CO2_data=.true., + CH4_data=.true., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=0.0, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at +! rttov_localtime=0.75,13.5, ! Local times to sample at in hrs [0,24] +! rttov_localtime_width=2.e3,5.6e3, ! Swath width (km) +/ diff --git a/driver/run/rttov_channel_input_AIRS_subset.csv b/driver/run/rttov_channel_input_AIRS_subset.csv new file mode 100644 index 0000000000..f019e78967 --- /dev/null +++ b/driver/run/rttov_channel_input_AIRS_subset.csv @@ -0,0 +1,26 @@ +71,1,0 +127,1,0 +212,1,0 +214,1,0 +313,1,0 +468,1,0 +584,1,0 +842,1,0 +881,1,0 +909,1,0 +998,1,0 +1077,1,0 +1130,1,0 +1262,1,0 +1287,1,0 +1375,1,0 +1496,1,0 +1507,1,0 +1592,1,0 +1636,1,0 +1839,1,0 +1865,1,0 +1901,1,0 +2095,1,0 +2131,1,0 +2332,1,0 \ No newline at end of file diff --git a/src/cosp.F90 b/src/cosp.F90 index 3ce55bbc74..9aaf931aa4 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -750,7 +750,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) endif endif - ! JKS: Will need to add cloud liquid and ice parameter (r_eff) if (Lrttov_column) then rttovIN%nPoints => Npoints rttovIN%nLevels => cospIN%nLevels @@ -1837,6 +1836,16 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (allocated(modisIN%notSunlit)) deallocate(modisIN%notSunlit) if (allocated(modisIN%pres)) deallocate(modisIN%pres) endif + + if (Lrttov_column) then + nullify(rttovIN%nPoints,rttovIN%nLevels,rttovIN%nSubCols,rttovIN%co2,rttovIN%ch4, & + rttovIN%n2o,rttovIN%co,rttovIN%h_surf,rttovIN%u_surf,rttovIN%v_surf, & + rttovIN%t_skin,rttovIN%p_surf,rttovIN%sfcmask,rttovIN%latitude, & + rttovIN%longitude,rttovIN%p,rttovIN%ph,rttovIN%q2m,rttovIN%t2m,rttovIN%t, & + rttovIN%q,rttovIN%o3,rttovIN%rttov_date,rttovIN%rttov_time,rttovIN%tca, & + rttovIN%cldLiq,rttovIN%cldIce,rttovIN%DeffLiq,rttovIN%DeffIce, & + rttovIN%fl_rain,rttovIN%fl_snow) + endif if (allocated(calipso_beta_tot)) deallocate(calipso_beta_tot) if (allocated(grLidar532_beta_tot)) deallocate(grLidar532_beta_tot) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 423d72656d..61ab2c51c1 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -735,7 +735,9 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % nchanprof, & rttovConfig % nprof, & rttovConfig % swath_mask) - + ! Could shortcut out if all values are swathed out +! if (rttovConfig % nprof .eq. 0) then print*,'swathed chunk' + call cpu_time(driver_time(2)) ! if (verbose) print*,'Beginning "cosp_rttov_construct_profiles".' call cosp_rttov_construct_profiles(rttovIN, & diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 83f226c872..dbafcf2d1b 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -873,7 +873,10 @@ subroutine cosp_rttov_call_direct(inst_nthreads, & print*,'shape(profiles): ',shape(profiles) ! print*,'shape(profiles(:)%q): ',shape(profiles(:)%q) end if - + +! print*,'NTHRDS tests' +! print*,'profiles(:)%s2m%p: ',profiles(:)%s2m%p +! print*,'profiles(1)%p_surf: ',profiles(1)%p if (inst_nthreads <= 1) then if (verbose) print*,'Calling rttov_direct' From 266cd143c0bad57f295e72603b83ed987bf05d2e Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 21 Nov 2023 19:59:59 -0700 Subject: [PATCH 099/159] Shifted RTTOV variables into subroutine calls for thread-safe operations. --- src/simulator/cosp_rttov_interface_v13.F90 | 131 ++++- src/simulator/rttov/cosp_rttov_v13.F90 | 589 +++++++++++++-------- 2 files changed, 472 insertions(+), 248 deletions(-) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 61ab2c51c1..81841331a3 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -46,7 +46,14 @@ MODULE MOD_COSP_RTTOV_INTERFACE rttov_options, & rttov_options_scatt, & rttov_coefs, & - rttov_scatt_coef + rttov_scatt_coef, & + rttov_pccomp, & + rttov_radiance, & + rttov_transmission, & + rttov_profile, & + rttov_emissivity, & + rttov_reflectance, & + rttov_chanprof ! jpim, jprb and jplm are the RTTOV integer, real and logical KINDs USE parkind1, ONLY : jpim, jprb, jplm @@ -66,10 +73,8 @@ MODULE MOD_COSP_RTTOV_INTERFACE #include "rttov_print_opts.interface" #include "rttov_get_pc_predictindex.interface" - ! RTTOV variables/structures + ! RTTOV variables/structures. Should not be global to make thread-safe. !==================== - LOGICAL(KIND=jplm), POINTER :: calcemis(:) => NULL() ! Flag to indicate calculation of emissivity within RTTOV - LOGICAL(KIND=jplm), POINTER :: calcrefl(:) => NULL() ! Flag to indicate calculation of BRDF within RTTOV INTEGER(KIND=jpim) :: errorstatus ! Return error status of RTTOV subroutine calls INTEGER(KIND=jpim) :: alloc_status(60) @@ -121,6 +126,8 @@ MODULE MOD_COSP_RTTOV_INTERFACE opts_scatt type(rttov_coefs) :: & coefs ! RTTOV coefficients structure + type(rttov_pccomp) :: & + pccomp logical(KIND=jplm), allocatable :: & swath_mask(:) end type rttov_cfg @@ -715,6 +722,17 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, refl_clear ! Clear-sky character(len=128),intent(inout) :: & error ! Error messages (only populated if error encountered) + + ! Local variables + type(rttov_radiance) :: radiance + type(rttov_transmission) :: transmission + type(rttov_profile), pointer :: profiles(:) => NULL() ! Input profiles + logical(kind=jplm), pointer :: calcemis(:) => NULL() ! Flag to indicate calculation of emissivity within RTTOV + type(rttov_emissivity), pointer :: emissivity(:) => NULL() ! Input/output surface emissivity + logical(kind=jplm), pointer :: calcrefl(:) => NULL() ! Flag to indicate calculation of BRDF within RTTOV + type(rttov_reflectance), pointer :: reflectance(:) => NULL() ! Input/output surface BRDF + type(rttov_chanprof), pointer :: chanprof(:) => NULL() ! Input channel/profile list + logical,intent(in) :: verbose real(wp),dimension(10) :: driver_time @@ -723,24 +741,33 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, call cpu_time(driver_time(1)) if (allocated(rttovConfig % swath_mask)) deallocate(rttovConfig % swath_mask) allocate(rttovConfig % swath_mask(rttovIN % nPoints)) -! if (verbose) print*,'Beginning "cosp_rttov_allocate".' + !if (verbose) print*,'Beginning "cosp_rttov_allocate".' call cosp_rttov_allocate(rttovIN, & rttovConfig % nChannels_rec, & rttovConfig % opts, & rttovConfig % coefs, & + profiles, & rttovConfig % iChannel, & rttovConfig % rttov_Nlocaltime, & rttovConfig % rttov_localtime, & rttovConfig % rttov_localtime_width, & + chanprof, & rttovConfig % nchanprof, & rttovConfig % nprof, & - rttovConfig % swath_mask) + rttovConfig % swath_mask, & + transmission, & + radiance, & + calcemis, & + emissivity, & + calcrefl, & + reflectance) ! Could shortcut out if all values are swathed out ! if (rttovConfig % nprof .eq. 0) then print*,'swathed chunk' call cpu_time(driver_time(2)) -! if (verbose) print*,'Beginning "cosp_rttov_construct_profiles".' + !if (verbose) print*,'Beginning "cosp_rttov_construct_profiles".' call cosp_rttov_construct_profiles(rttovIN, & + profiles, & rttovConfig % Lrttov_cld, & rttovConfig % Lrttov_aer, & rttovConfig % Lrttov_solar, & @@ -763,22 +790,37 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, call cpu_time(driver_time(3)) -! if (verbose) print*,'Beginning "cosp_rttov_setup_emissivity_reflectance".' + !if (verbose) print*,'Beginning "cosp_rttov_setup_emissivity_reflectance".' if (associated(rttovIN % emis_grey)) then - call cosp_rttov_setup_emissivity_reflectance(emis_grey = rttovIN % emis_grey) ! Config agnostic after allocate step. + call cosp_rttov_setup_emissivity_reflectance(calcemis, & + emissivity, & + calcrefl, & + reflectance, & + emis_grey = rttovIN % emis_grey) ! Config agnostic after allocate step. else - call cosp_rttov_setup_emissivity_reflectance() ! Config agnostic after allocate step. + call cosp_rttov_setup_emissivity_reflectance(calcemis, & + emissivity, & + calcrefl, & + reflectance) end if call cpu_time(driver_time(4)) -! if (verbose) print*,'Beginning "cosp_rttov_call_direct".' + !if (verbose) print*,'Beginning "cosp_rttov_call_direct".' call cosp_rttov_call_direct(rttovConfig % rttov_direct_nthreads, & rttovConfig % opts, & - rttovConfig % coefs) + profiles, & + rttovConfig % coefs, & + chanprof, & + transmission, & + radiance, & + calcemis, & + emissivity, & + calcrefl, & + reflectance) call cpu_time(driver_time(5)) -! if (verbose) print*,'Beginning "cosp_rttov_save_output".' + !if (verbose) print*,'Beginning "cosp_rttov_save_output".' call cosp_rttov_save_output(rttovIN % nPoints, & rttovConfig % nchan_out, & rttovConfig % swath_mask, & @@ -786,18 +828,27 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % Lrttov_rad, & rttovConfig % Lrttov_refl, & rttovConfig % Lrttov_cld, & - rttovConfig % Lrttov_aer, & + rttovConfig % Lrttov_aer, & + radiance, & bt_total,bt_clear, & rad_total,rad_clear,rad_cloudy, & refl_total,refl_clear) call cpu_time(driver_time(6)) -! if (verbose) print*,'Beginning "cosp_rttov_deallocate_profiles".' + !if (verbose) print*,'Beginning "cosp_rttov_deallocate_profiles".' call cosp_rttov_deallocate_profiles(rttovConfig % nprof, & rttovConfig % nchanprof, & - rttovIN % nLevels, & + rttovIN % nLevels, & rttovConfig % opts, & - rttovConfig % coefs) + profiles, & + rttovConfig % coefs, & + chanprof, & + transmission, & + radiance, & + calcemis, & + emissivity, & + calcrefl, & + reflectance) call cpu_time(driver_time(7)) ! print*,'Time to run "cosp_rttov_allocate": ', driver_time(2)-driver_time(1) @@ -846,9 +897,19 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, bt_clear, & ! All-sky rad_clear ! All-sky character(len=128),intent(inout) :: & - error ! Error messages (only populated if error encountered) - logical,intent(in) :: verbose + error ! Error messages (only populated if error encountered) + ! Local variables + type(rttov_radiance) :: radiance + type(rttov_transmission) :: transmission + type(rttov_profile), pointer :: profiles(:) => NULL() ! Input profiles + logical(kind=jplm), pointer :: calcemis(:) => NULL() ! Flag to indicate calculation of emissivity within RTTOV + type(rttov_emissivity), pointer :: emissivity(:) => NULL() ! Input/output surface emissivity + logical(kind=jplm), pointer :: calcrefl(:) => NULL() ! Flag to indicate calculation of BRDF within RTTOV + type(rttov_reflectance), pointer :: reflectance(:) => NULL() ! Input/output surface BRDF + type(rttov_chanprof), POINTER :: chanprof(:) => NULL() ! Input channel/profile list + + logical,intent(in) :: verbose real(wp),dimension(10) :: driver_time ! Run each step for running RTTOV from mod_cosp_rttov (and time them) @@ -860,18 +921,26 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % PC_coef_filepath, & rttovConfig % coefs, & rttovConfig % opts, & + profiles, & rttovConfig % nchannels_rec, & rttovConfig % iChannel, & rttovConfig % rttov_Nlocaltime, & rttovConfig % rttov_localtime, & rttovConfig % rttov_localtime_width, & + chanprof, & rttovConfig % nchanprof, & rttovConfig % nprof, & rttovConfig % iChannel_out, & - rttovConfig % swath_mask) + rttovConfig % swath_mask, & + transmission, & + radiance, & + calcemis, & + emissivity, & + rttovConfig % pccomp) call cpu_time(driver_time(2)) ! if (verbose) print*,'Beginning "cosp_rttov_construct_profiles".' call cosp_rttov_construct_profiles(rttovIN, & + profiles, & rttovConfig % Lrttov_cld, & rttovConfig % Lrttov_aer, & rttovConfig % Lrttov_solar, & @@ -892,20 +961,29 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovConfig % swath_mask, & verbose) call cpu_time(driver_time(3)) - call cosp_pc_rttov_setup_emissivity() + call cosp_pc_rttov_setup_emissivity(calcemis, & + emissivity) call cpu_time(driver_time(4)) ! if (verbose) print*,'Beginning "cosp_pc_rttov_call_direct".' call cosp_pc_rttov_call_direct(rttovConfig % rttov_direct_nthreads, & rttovConfig % opts, & + profiles, & rttovConfig % coefs, & + chanprof, & + transmission, & rttovConfig % nchannels_rec, & - rttovConfig % iChannel_out) ! iChannel_out should have been updated + rttovConfig % iChannel_out, & + radiance, & + calcemis, & + emissivity, & + rttovConfig % pccomp) call cpu_time(driver_time(5)) ! if (verbose) print*,'Beginning "cosp_pc_rttov_save_output".' call cosp_pc_rttov_save_output(rttovIN % nPoints, & rttovConfig % nchannels_rec, & rttovConfig % swath_mask, & + rttovConfig % pccomp, & rttovConfig % Lrttov_bt, & rttovConfig % Lrttov_rad, & bt_clear, & @@ -918,7 +996,14 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, rttovIN % nlevels, & rttovConfig % nChannels_rec, & rttovConfig % opts, & - rttovConfig % coefs) + profiles, & + rttovConfig % coefs, & + chanprof, & + transmission, & + radiance, & + calcemis, & + emissivity, & + rttovConfig % pccomp) call cpu_time(driver_time(7)) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index dbafcf2d1b..47f675d7d3 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -101,19 +101,8 @@ module mod_cosp_rttov ! module-wides variables for input !==================== - TYPE(rttov_chanprof), POINTER :: chanprof(:) => NULL() ! Input channel/profile list - LOGICAL(KIND=jplm), POINTER :: calcemis(:) => NULL() ! Flag to indicate calculation of emissivity within RTTOV - TYPE(rttov_emissivity), POINTER :: emissivity(:) => NULL() ! Input/output surface emissivity - LOGICAL(KIND=jplm), POINTER :: calcrefl(:) => NULL() ! Flag to indicate calculation of BRDF within RTTOV - TYPE(rttov_reflectance), POINTER :: reflectance(:) => NULL() ! Input/output surface BRDF - TYPE(rttov_profile), POINTER :: profiles(:) => NULL() ! Input profiles - TYPE(rttov_transmission) :: transmission ! Output transmittances - TYPE(rttov_radiance) :: radiance ! Output radiances - TYPE(rttov_pccomp) :: pccomp ! Output PC structure - INTEGER(KIND=jpim), POINTER :: channels_rec(:) => NULL() ! Reconstructed radiance channel list INTEGER(KIND=jpim) :: errorstatus ! Return error status of RTTOV subroutine calls - INTEGER(KIND=jpim) :: alloc_status(60) ! JKS additional variables used in PC-RTTOV @@ -195,13 +184,17 @@ end subroutine rttov_error ! SUBROUTINE rttov_allocate - JKS ! ------------------------------------------------------ ! 3. Allocate RTTOV input and output structures - ! 4. Build the list of profile/channel indices in chanprof + ! 4. Build the list of profile/channel indices in inst_chanprof ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & - inst_coefs,inst_iChannel,rttov_Nlocaltime, & - rttov_localtime,rttov_localtime_width, & - inst_nchanprof,inst_nprof,swath_mask,debug) + subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs, & + inst_profiles, inst_iChannel,rttov_Nlocaltime, & + rttov_localtime,rttov_localtime_width, & + inst_chanprof, & + inst_nchanprof,inst_nprof,inst_swath_mask, & + inst_transmission,inst_radiance,inst_calcemis, & + inst_emissivity,inst_calcrefl,inst_reflectance, & + debug) type(rttov_in),intent(in) :: & rttovIN @@ -211,6 +204,8 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & inst_opts type(rttov_coefs),intent(in) :: & inst_coefs + type(rttov_profile),pointer,intent(out) :: & + inst_profiles(:) integer(kind=jpim),dimension(inst_nChannels_rec),intent(in) :: & inst_iChannel integer(KIND=jpim),intent(in) :: & @@ -218,11 +213,25 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & real(kind=jprb), dimension(rttov_Nlocaltime), intent(in) :: & rttov_localtime, & rttov_localtime_width + type(rttov_chanprof),pointer,intent(inout) :: & + inst_chanprof(:) integer(kind=jpim),intent(inout) :: & inst_nchanprof, & inst_nprof ! Now accounting for orbits logical(jplm),dimension(rttovIN % nPoints),intent(inout) :: & - swath_mask + inst_swath_mask + type(rttov_transmission),intent(out) :: & + inst_transmission + type(rttov_radiance),intent(out) :: & + inst_radiance + logical(kind=jplm),pointer,intent(out) :: & + inst_calcemis(:) + type(rttov_emissivity),pointer,intent(out) :: & + inst_emissivity(:) + logical(kind=jplm),pointer,intent(out) :: & + inst_calcrefl(:) + type(rttov_reflectance),pointer,intent(out) :: & + inst_reflectance(:) logical,intent(in),optional :: & debug @@ -271,17 +280,17 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & end do ! Collapse along the Nlocaltimes dimension and shift to logicals - swath_mask(:) = .false. ! Initialize to false + inst_swath_mask(:) = .false. ! Initialize to false do j = 1,rttovIN % nPoints if ( ANY( swath_mask_all(j,:) .eq. 1) ) then - swath_mask(j) = .true. + inst_swath_mask(j) = .true. end if end do else - swath_mask(:) = .true. ! Compute on all columns in no local times are passed. + inst_swath_mask(:) = .true. ! Compute on all columns in no local times are passed. end if ! Determine the total number of radiances to simulate (nchanprof). - inst_nprof = count(swath_mask) + inst_nprof = count(inst_swath_mask) inst_nchanprof = inst_nChannels_rec * inst_nprof if (verbose) then @@ -297,16 +306,16 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & inst_nprof, & inst_nchanprof, & rttovIN%nLevels, & - chanprof, & + inst_chanprof, & inst_opts, & - profiles, & + inst_profiles, & inst_coefs, & - transmission, & - radiance, & - calcemis=calcemis, & - emissivity=emissivity, & - calcrefl=calcrefl, & - reflectance=reflectance, & + inst_transmission, & + inst_radiance, & + calcemis=inst_calcemis, & + emissivity=inst_emissivity, & + calcrefl=inst_calcrefl, & + reflectance=inst_reflectance, & init=.TRUE._jplm) call rttov_error('allocation error for rttov_direct structures' , lalloc = .false.) @@ -320,8 +329,8 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts, & do j = 1, inst_nprof do jch = 1, inst_nChannels_rec ! nChannels nch = nch + 1_jpim - chanprof(nch)%prof = j - chanprof(nch)%chan = inst_iChannel(jch) ! Example code used channel_list + inst_chanprof(nch)%prof = j + inst_chanprof(nch)%chan = inst_iChannel(jch) ! Example code used channel_list end do end do if (verbose) print*,'Done with "cosp_rttov_allocate"' @@ -336,11 +345,13 @@ end subroutine cosp_rttov_allocate ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, & - inst_coefs,inst_opts, & + inst_coefs,inst_opts,inst_profiles, & inst_nchannels_rec,inst_iChannel_in, & rttov_Nlocaltime,rttov_localtime,rttov_localtime_width, & - inst_nchanprof,inst_nprof,inst_iChannel_out,swath_mask, & - debug) + inst_chanprof, & + inst_nchanprof,inst_nprof,inst_iChannel_out, & + inst_swath_mask,inst_transmission,inst_radiance, & + inst_calcemis,inst_emissivity,inst_pccomp,debug) type(rttov_in),intent(in) :: & rttovIN @@ -350,6 +361,8 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, inst_coefs type(rttov_options),intent(inout) :: & inst_opts + type(rttov_profile),pointer,intent(out) :: & + inst_profiles(:) integer(kind=jpim),intent(inout) :: & inst_nchannels_rec integer(kind=jpim),intent(in),dimension(inst_nchannels_rec) :: & @@ -358,14 +371,26 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, rttov_Nlocaltime real(kind=jprb), dimension(rttov_Nlocaltime), intent(in) :: & rttov_localtime, & - rttov_localtime_width + rttov_localtime_width + type(rttov_chanprof),pointer,intent(inout) :: & + inst_chanprof(:) integer(kind=jpim),intent(inout) :: & inst_nchanprof, & inst_nprof integer(kind=jpim),intent(inout),allocatable :: & inst_iChannel_out(:) ! Passing out the channel indices logical(jplm),dimension(rttovIN % nPoints),intent(inout) :: & - swath_mask + inst_swath_mask + type(rttov_transmission),intent(out) :: & + inst_transmission + type(rttov_radiance),intent(out) :: & + inst_radiance + logical(kind=jplm),pointer,intent(out) :: & + inst_calcemis(:) + type(rttov_emissivity),pointer,intent(out) :: & + inst_emissivity(:) + type(rttov_pccomp),intent(inout) :: & + inst_pccomp ! Output PC structure logical,intent(in),optional :: & debug @@ -421,18 +446,18 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, end do ! Collapse along the Nlocaltimes dimension and shift to logicals - swath_mask(:) = .false. ! Initialize to false + inst_swath_mask(:) = .false. ! Initialize to false do j = 1,rttovIN % nPoints if ( ANY( swath_mask_all(j,:) .eq. 1) ) then - swath_mask(j) = .true. + inst_swath_mask(j) = .true. end if end do ! Determine the total number of radiances to simulate (nchanprof). else - swath_mask(:) = .true. ! Compute on all columns in no local times are passed. + inst_swath_mask(:) = .true. ! Compute on all columns in no local times are passed. end if ! Determine the total number of radiances to simulate (nchanprof). - inst_nprof = count(swath_mask) + inst_nprof = count(inst_swath_mask) ! npred_pc is only used in the pc_rttov_allocate step so I can remove the global definition later inst_npred_pc = SIZE(predictindex) @@ -475,17 +500,17 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, inst_nprof, & inst_nchanprof, & rttovIN%nLevels, & - chanprof, & ! Make this instrument-specific? The rttov_config DDT would then be assigned to this value. Allocation difficulties? + inst_chanprof, & ! Make this instrument-specific? The rttov_config DDT would then be assigned to this value. Allocation difficulties? inst_opts, & - profiles, & + inst_profiles, & inst_coefs, & - transmission, & - radiance, & - calcemis=calcemis, & - emissivity=emissivity, & + inst_transmission, & + inst_radiance, & + calcemis=inst_calcemis, & + emissivity=inst_emissivity, & npcscores=inst_opts%rt_ir%pc%npcscores * inst_nprof, & nchannels_rec=inst_nchannels_rec * inst_nprof, & - pccomp=pccomp, & + pccomp=inst_pccomp, & init=.TRUE._jplm) call rttov_error('allocation error for rttov_direct structures (PC-RTTOV)' , lalloc = .true.) @@ -499,8 +524,8 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, do j = 1, inst_nprof lo = (j - 1) * inst_npred_pc + 1 hi = lo + inst_npred_pc - 1 - chanprof(lo:hi)%prof = j - chanprof(lo:hi)%chan = predictindex(:) + inst_chanprof(lo:hi)%prof = j + inst_chanprof(lo:hi)%chan = predictindex(:) end do end subroutine cosp_pc_rttov_allocate @@ -513,6 +538,7 @@ end subroutine cosp_pc_rttov_allocate ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine cosp_rttov_construct_profiles(rttovIN, & + inst_profiles, & Lrttov_cld, & Lrttov_aer, & Lrttov_solar, & @@ -533,8 +559,10 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & inst_swath_mask,& debug) - type(rttov_in),intent(in) :: & ! What is the best way to do this? Should rttovIN be a module-wide DDT? Yes. + type(rttov_in),intent(in) :: & rttovIN + type(rttov_profile),pointer,intent(inout) :: & + inst_profiles(:) logical,intent(in) :: & Lrttov_cld, & Lrttov_aer, & @@ -575,115 +603,115 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & ! ozone_data, co2_data and so on in the options structure should be ! set to false." - profiles(:)%gas_units = 1 ! kg/kg over moist air (default) - + inst_profiles(:)%gas_units = 1 ! kg/kg over moist air (default) + ! Iterate over all columns j = 0 ! Initialize input do i = 1, rttovIN%nPoints if (inst_swath_mask(i)) then ! only added masked columns to profiles j = j + 1 ! Increment first - + ! Initialize trace gas concentrations from user input. if (Luser_tracegas) then - if (Ldo_co2) profiles(j)%co2(:) = inst_co2_mr - if (Ldo_n2o) profiles(j)%n2o(:) = inst_n2o_mr - if (Ldo_co) profiles(j)%co(:) = inst_co_mr - if (Ldo_ch4) profiles(j)%ch4(:) = inst_ch4_mr - if (Ldo_so2) profiles(j)%so2(:) = inst_so2_mr - if (Ldo_o3) profiles(j)%o3(:) = rttovIN%o3(i, :) ! no O3 user input set up + if (Ldo_co2) inst_profiles(j)%co2(:) = inst_co2_mr + if (Ldo_n2o) inst_profiles(j)%n2o(:) = inst_n2o_mr + if (Ldo_co) inst_profiles(j)%co(:) = inst_co_mr + if (Ldo_ch4) inst_profiles(j)%ch4(:) = inst_ch4_mr + if (Ldo_so2) inst_profiles(j)%so2(:) = inst_so2_mr + if (Ldo_o3) inst_profiles(j)%o3(:) = rttovIN%o3(i, :) ! no O3 user input set up else ! For when trace gas columns are supplied by the model. Units must match (kg/kg over moist air) - if (Ldo_co2) profiles(j)%co2(:) = rttovIN%co2(i,:) - if (Ldo_n2o) profiles(j)%n2o(:) = rttovIN%n2o(i,:) - if (Ldo_co) profiles(j)%co(:) = rttovIN%co(i,:) - if (Ldo_ch4) profiles(j)%ch4(:) = rttovIN%ch4(i,:) - if (Ldo_so2) profiles(j)%so2(:) = rttovIN%so2(i,:) - if (Ldo_o3) profiles(j)%o3(:) = rttovIN%o3(i, :) + if (Ldo_co2) inst_profiles(j)%co2(:) = rttovIN%co2(i,:) + if (Ldo_n2o) inst_profiles(j)%n2o(:) = rttovIN%n2o(i,:) + if (Ldo_co) inst_profiles(j)%co(:) = rttovIN%co(i,:) + if (Ldo_ch4) inst_profiles(j)%ch4(:) = rttovIN%ch4(i,:) + if (Ldo_so2) inst_profiles(j)%so2(:) = rttovIN%so2(i,:) + if (Ldo_o3) inst_profiles(j)%o3(:) = rttovIN%o3(i, :) end if ! Initialize column pressure, temperature, and humidity - profiles(j)%p(:) = rttovIN%p(i, :) * 1e-2 ! convert Pa to hPa - profiles(j)%t(:) = rttovIN%t(i, :) - profiles(j)%q(:) = rttovIN%q(i, :) + inst_profiles(j)%p(:) = rttovIN%p(i, :) * 1e-2 ! convert Pa to hPa + inst_profiles(j)%t(:) = rttovIN%t(i, :) + inst_profiles(j)%q(:) = rttovIN%q(i, :) ! q coefficient limit is 0.1e-10 - where(profiles(j)%q(:) < 0.1e-10) - profiles(j)%q(:) = 0.11e-10 + where(inst_profiles(j)%q(:) < 0.1e-10) + inst_profiles(j)%q(:) = 0.11e-10 end where - ! Gas profiles - profiles(j)%o3 = rttovIN%o3(i, :) + ! Gas inst_profiles + inst_profiles(j)%o3 = rttovIN%o3(i, :) ! 2m parameters - profiles(j)%s2m%p = rttovIN%p_surf(i) * 1e-2 ! convert Pa to hPa - profiles(j)%s2m%t = rttovIN%t2m(i) - profiles(j)%s2m%q = rttovIN%q2m(i) ! Should be the same as gas units (kg/kg) - profiles(j)%s2m%u = rttovIN%u_surf(i) - profiles(j)%s2m%v = rttovIN%v_surf(i) - profiles(j)%s2m%wfetc = 10000. ! only used by sea surface solar BRDF model. + inst_profiles(j)%s2m%p = rttovIN%p_surf(i) * 1e-2 ! convert Pa to hPa + inst_profiles(j)%s2m%t = rttovIN%t2m(i) + inst_profiles(j)%s2m%q = rttovIN%q2m(i) ! Should be the same as gas units (kg/kg) + inst_profiles(j)%s2m%u = rttovIN%u_surf(i) + inst_profiles(j)%s2m%v = rttovIN%v_surf(i) + inst_profiles(j)%s2m%wfetc = 10000. ! only used by sea surface solar BRDF model. ! skin variables for emissivity calculations - profiles(j)%skin%t = rttovIN%t_skin(i) + inst_profiles(j)%skin%t = rttovIN%t_skin(i) ! fastem coefficients - for mw calculations - profiles(j)%skin%fastem(1) = 3.0 - profiles(j)%skin%fastem(2) = 5.0 - profiles(j)%skin%fastem(3) = 15.0 - profiles(j)%skin%fastem(4) = 0.1 - profiles(j)%skin%fastem(5) = 0.3 + inst_profiles(j)%skin%fastem(1) = 3.0 + inst_profiles(j)%skin%fastem(2) = 5.0 + inst_profiles(j)%skin%fastem(3) = 15.0 + inst_profiles(j)%skin%fastem(4) = 0.1 + inst_profiles(j)%skin%fastem(5) = 0.3 ! Viewing angles - profiles(j)%zenangle = inst_zenang ! pass in from cosp - profiles(j)%azangle = 0. ! hard-coded in rttov9 int JKS-? + inst_profiles(j)%zenangle = inst_zenang ! pass in from cosp + inst_profiles(j)%azangle = 0. ! hard-coded in rttov9 int JKS-? - profiles(j)%latitude = rttovIN%latitude(i) - profiles(j)%longitude = rttovIN%longitude(i) - profiles(j)%elevation = rttovIN%h_surf(i) * 1e-3 ! Convert m to km + inst_profiles(j)%latitude = rttovIN%latitude(i) + inst_profiles(j)%longitude = rttovIN%longitude(i) + inst_profiles(j)%elevation = rttovIN%h_surf(i) * 1e-3 ! Convert m to km ! Solar angles. This is overwritten in the solar code now. if (associated(rttovIN%sza)) then - profiles(j)%sunzenangle = rttovIN%sza(i) ! SZA in degrees + inst_profiles(j)%sunzenangle = rttovIN%sza(i) ! SZA in degrees else if (verbose) print*,'No solar zenith angle passed. Setting to zero.' - profiles(j)%sunzenangle = 0. + inst_profiles(j)%sunzenangle = 0. end if - profiles(j)%sunazangle = 0. ! hard-coded in like rttov9 + inst_profiles(j)%sunazangle = 0. ! hard-coded in like rttov9 ! surface type. sfcmask is 0 for ocean, 1 for land, and 2 for sea ice if (rttovIN%sfcmask(i) .lt. 0.5) then - profiles(j)%skin%surftype = surftype_land + inst_profiles(j)%skin%surftype = surftype_land else if (rttovIN%sfcmask(i) .lt. 1.5) then - profiles(j)%skin%surftype = surftype_sea + inst_profiles(j)%skin%surftype = surftype_sea else - profiles(j)%skin%surftype = surftype_seaice + inst_profiles(j)%skin%surftype = surftype_seaice end if ! land-sea mask (lsmask) indicates proportion of land in grid (not in CESM implementation! just a binary mask there) ! if (rttovIN%lsmask(i) < 0.5) then -! profiles(j)%skin%surftype = surftype_sea +! inst_profiles(j)%skin%surftype = surftype_sea ! else -! profiles(j)%skin%surftype = surftype_land +! inst_profiles(j)%skin%surftype = surftype_land ! endif ! sea-ice fraction ! if (rttovIN%icefrac(i) >= 0.5) then -! profiles(j)%skin%surftype = surftype_seaice +! inst_profiles(j)%skin%surftype = surftype_seaice ! endif ! dar: hard-coded to 1 (=ocean water) in rttov 9 int - profiles(j)%skin%watertype = 1 - !profiles(j) %idg = 0. ! Depreciated? - !profiles(j) %ish = 0. ! Depreciated? + inst_profiles(j)%skin%watertype = 1 + !inst_profiles(j) %idg = 0. ! Depreciated? + !inst_profiles(j) %ish = 0. ! Depreciated? end if - end do - + end do + ! if (verbose) then -! print*,'profiles(1)%p(:): ',profiles(1)%p(:) -! print*,'profiles(1)%t(:): ',profiles(1)%t(:) -! print*,'profiles(1)%q(:): ',profiles(1)%q(:) -! print*,'profiles(1)%co2(:): ',profiles(1)%co2(:) -! print*,'profiles(1)%skin%t: ',profiles(1)%skin%t -! print*,'profiles(1)%s2m%t: ',profiles(1)%s2m%t +! print*,'inst_profiles(1)%p(:): ',inst_profiles(1)%p(:) +! print*,'inst_profiles(1)%t(:): ',inst_profiles(1)%t(:) +! print*,'inst_profiles(1)%q(:): ',inst_profiles(1)%q(:) +! print*,'inst_profiles(1)%co2(:): ',inst_profiles(1)%co2(:) +! print*,'inst_profiles(1)%skin%t: ',inst_profiles(1)%skin%t +! print*,'inst_profiles(1)%s2m%t: ',inst_profiles(1)%s2m%t ! end if ! JKS - nothing to check here, this will never trigger. @@ -696,12 +724,12 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & if (Lrttov_cld) then ! Set cloud mass mixing ratio units - profiles(:)%mmr_cldaer = .true. ! kg/kg for cloud and aerosol (default) + inst_profiles(:)%mmr_cldaer = .true. ! kg/kg for cloud and aerosol (default) - profiles(:)%clw_scheme = 2 ! Deff scheme avoids cloud types but requires an effective diameter value - ! profiles(:)%clwde_scheme = 1. ! Scheme for cloud liquid water cotent to effective diameter. User guide says do not change. - profiles(:)%ice_scheme = 1 !1:Baum 2:Baran(2014) 3:Baran(2018) - profiles(:)%icede_param = 2 ! 2:Wyser(recommended). Only used if ice effective diameter not input + inst_profiles(:)%clw_scheme = 2 ! Deff scheme avoids cloud types but requires an effective diameter value + ! inst_profiles(:)%clwde_scheme = 1. ! Scheme for cloud liquid water cotent to effective diameter. User guide says do not change. + inst_profiles(:)%ice_scheme = 1 !1:Baum 2:Baran(2014) 3:Baran(2018) + inst_profiles(:)%icede_param = 2 ! 2:Wyser(recommended). Only used if ice effective diameter not input j = 0 ! Initialize input do i = 1,rttovIN%nPoints @@ -710,30 +738,30 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & j = j + 1 ! Increment profile counter ! Cloud scheme stuff - profiles(j)%cfrac(:) = rttovIN%tca(i,:) ! Cloud fraction for each layer - profiles(j)%cloud(1,:) = rttovIN%cldLiq(i,:) ! Cloud water mixing ratio (all in the first type for Deff) - profiles(j)%cloud(6,:) = rttovIN%cldIce(i,:) ! Cloud ice mixing ratio (1 type). See pg 74. + inst_profiles(j)%cfrac(:) = rttovIN%tca(i,:) ! Cloud fraction for each layer + inst_profiles(j)%cloud(1,:) = rttovIN%cldLiq(i,:) ! Cloud water mixing ratio (all in the first type for Deff) + inst_profiles(j)%cloud(6,:) = rttovIN%cldIce(i,:) ! Cloud ice mixing ratio (1 type). See pg 74. - profiles(j)%clwde = rttovIN%DeffLiq(i,:) ! Cloud water effective diameter - profiles(j)%icede = rttovIN%DeffIce(i,:) ! Cloud ice effective diameter + inst_profiles(j)%clwde = rttovIN%DeffLiq(i,:) ! Cloud water effective diameter + inst_profiles(j)%icede = rttovIN%DeffIce(i,:) ! Cloud ice effective diameter ! Example UKMO input has effective radii for multiple cloud types, making identification of a single ! liquid droplet or ice crystal effective diameter difficult. ! I opt to let RTTOV decide on the effective radius values, but more complex implementation ! could do a more thorough conversion between UKMO output and RTTOV input - ! profiles(j)%clwde = ! Cloud water effective diameter - ! profiles(j)%icede = ! Cloud ice effective diameter + ! inst_profiles(j)%clwde = ! Cloud water effective diameter + ! inst_profiles(j)%icede = ! Cloud ice effective diameter ! Old code for simple cloud schemes only - ! profiles(j)%cfraction = 0. - ! profiles(j)%ctp = 500. + ! inst_profiles(j)%cfraction = 0. + ! inst_profiles(j)%ctp = 500. ! Other options not implemented -! profiles(j)%clw = ! Cloud liquid water (kg/kg) – MW only, +! inst_profiles(j)%clw = ! Cloud liquid water (kg/kg) – MW only, end if end do end if - + ! JKS - nothing to check here, this will never trigger. call rttov_error('error in cloud profile initialization' , lalloc = .false.) @@ -745,13 +773,13 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & if (Lrttov_aer) then ! Set aerosol mass mixing ratio units - profiles%mmr_cldaer = .true. ! kg/kg for cloud and aerosol (default) + inst_profiles%mmr_cldaer = .true. ! kg/kg for cloud and aerosol (default) ! Read in aerosol profiles ! j = 0 ! Initialize input ! do i = 1,rttovIN%nPoints ! if (inst_swath_mask(i)) then ! only added masked columns to profiles ! j = j + 1 ! Increment profile counter -! profiles(j)%aerosols(naertyp,nlayers) = rttovIN%aerosols ! Aerosols in different modes (see User Guide pg 80) +! inst_profiles(j)%aerosols(naertyp,nlayers) = rttovIN%aerosols ! Aerosols in different modes (see User Guide pg 80) ! end if ! end do end if @@ -764,20 +792,20 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & do i = 1,rttovIN%nPoints if (inst_swath_mask(i)) then ! only added masked columns to profiles j = j + 1 ! Increment profile counter - profiles(j)%date(:) = rttovIN%rttov_date(i,:) - profiles(j)%time(:) = rttovIN%rttov_time(i,:) + inst_profiles(j)%date(:) = rttovIN%rttov_date(i,:) + inst_profiles(j)%time(:) = rttovIN%rttov_time(i,:) end if end do ! Call functions to calculate the appropriate solar zenith and azimuthal angles. - call RTTOV_CALC_SOLAR_ANGLES(errorstatus, profiles) + call RTTOV_CALC_SOLAR_ANGLES(errorstatus, inst_profiles) call rttov_error('Error when calling RTTOV_CALC_SOLAR_ANGLES', lalloc = .false.) ! if (verbose) then -! print*,'profiles(:))%sunzenangle: ',profiles(:)%sunzenangle -! print*,'profiles(:))%sunazangle: ',profiles(:)%sunazangle -! print*,'profiles(:))%zenangle: ',profiles(:)%zenangle -! print*,'profiles(:))%azangle: ',profiles(:)%azangle +! print*,'inst_profiles(:))%sunzenangle: ',inst_profiles(:)%sunzenangle +! print*,'inst_profiles(:))%sunazangle: ',inst_profiles(:)%sunazangle +! print*,'inst_profiles(:))%zenangle: ',inst_profiles(:)%zenangle +! print*,'inst_profiles(:))%azangle: ',inst_profiles(:)%azangle ! end if end if @@ -806,24 +834,37 @@ end subroutine cosp_rttov_construct_profiles ! if (present(emis_in)) emissivity(:) % emis_in = emis_in ! if (present(refl_in)) reflectance(:) % refl_in = refl_in - subroutine cosp_rttov_setup_emissivity_reflectance(emis_grey) + subroutine cosp_rttov_setup_emissivity_reflectance(inst_calcemis, & + inst_emissivity, & + inst_calcrefl, & + inst_reflectance, & + emis_grey) + + logical(kind=jplm),pointer,intent(inout) :: & + inst_calcemis(:) + type(rttov_emissivity),pointer,intent(inout) :: & + inst_emissivity(:) + logical(kind=jplm),pointer,intent(inout) :: & + inst_calcrefl(:) + type(rttov_reflectance),pointer,intent(inout) :: & + inst_reflectance(:) real(kind=wp),intent(in),pointer,optional :: emis_grey ! In this example we have no values for input emissivities or reflectances ! so we initialise all inputs to zero - call rttov_init_emis_refl(emissivity, reflectance) + call rttov_init_emis_refl(inst_emissivity, inst_reflectance) call rttov_error('error for emissivity/reflectance initialization' , lalloc = .true.) - if (present(emis_grey)) emissivity(:) % emis_in = emis_grey ! Use greybody emissivity. + if (present(emis_grey)) inst_emissivity(:) % emis_in = emis_grey ! Use greybody emissivity. ! Calculate emissivity within RTTOV where the input emissivity value is ! zero or less (all channels in this case) - calcemis(:) = (emissivity(:) % emis_in <= 0._jprb) + inst_calcemis(:) = (inst_emissivity(:) % emis_in <= 0._jprb) ! Calculate reflectances within RTTOV where the input BRDF value is zero or ! less (all channels in this case) - calcrefl(:) = (reflectance(:) % refl_in <= 0._jprb) + inst_calcrefl(:) = (inst_reflectance(:) % refl_in <= 0._jprb) end subroutine cosp_rttov_setup_emissivity_reflectance @@ -833,12 +874,18 @@ end subroutine cosp_rttov_setup_emissivity_reflectance ! ------------------------------------------------------ ! From RTTOV example files. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_pc_rttov_setup_emissivity() - + subroutine cosp_pc_rttov_setup_emissivity(inst_calcemis, & + inst_emissivity) + + logical(kind=jplm),pointer,intent(inout) :: & + inst_calcemis(:) + type(rttov_emissivity),pointer,intent(inout) :: & + inst_emissivity(:) + ! PC-RTTOV requires using RTTOV to calculate the surface emissivities. ! Reflectances are never calculated for hyper-spectral IR sounders - call rttov_init_emis_refl(emissivity) - calcemis(:) = .TRUE. + call rttov_init_emis_refl(inst_emissivity) + inst_calcemis(:) = .TRUE. call rttov_error('error for emissivity initialization (PC-RTTOV)' , lalloc = .true.) end subroutine cosp_pc_rttov_setup_emissivity @@ -850,17 +897,41 @@ end subroutine cosp_pc_rttov_setup_emissivity ! From RTTOV example files. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_rttov_call_direct(inst_nthreads, & - inst_opts, & - inst_coefs, & + subroutine cosp_rttov_call_direct(inst_nthreads, & + inst_opts, & + inst_profiles, & + inst_coefs, & + inst_chanprof, & + inst_transmission, & + inst_radiance, & + inst_calcemis, & + inst_emissivity, & + inst_calcrefl, & + inst_reflectance, & debug) integer(KIND=jpim),intent(in) :: & inst_nthreads type(rttov_options),intent(in) :: & inst_opts + type(rttov_profile),pointer,intent(in) :: & + inst_profiles(:) type(rttov_coefs),intent(in) :: & inst_coefs + type(rttov_chanprof),pointer,intent(in) :: & + inst_chanprof(:) + type(rttov_transmission),intent(inout) :: & + inst_transmission + type(rttov_radiance),intent(inout) :: & + inst_radiance + logical(kind=jplm),pointer,intent(in) :: & + inst_calcemis(:) + type(rttov_emissivity),pointer,intent(in) :: & + inst_emissivity(:) + logical(kind=jplm),pointer,intent(in) :: & + inst_calcrefl(:) + type(rttov_reflectance),pointer,intent(in) :: & + inst_reflectance(:) logical,intent(in),optional :: & debug logical :: verbose = .false. @@ -868,44 +939,44 @@ subroutine cosp_rttov_call_direct(inst_nthreads, & if (present(debug)) verbose = debug if (verbose) then - print*,'shape(chanprof%prof): ',shape(chanprof%prof) - print*,'shape(chanprof%chan): ',shape(chanprof%chan) - print*,'shape(profiles): ',shape(profiles) -! print*,'shape(profiles(:)%q): ',shape(profiles(:)%q) + print*,'shape(inst_chanprof%prof): ',shape(inst_chanprof%prof) + print*,'shape(inst_chanprof%chan): ',shape(inst_chanprof%chan) + print*,'shape(inst_profiles): ',shape(inst_profiles) +! print*,'shape(inst_profiles(:)%q): ',shape(inst_profiles(:)%q) end if ! print*,'NTHRDS tests' -! print*,'profiles(:)%s2m%p: ',profiles(:)%s2m%p -! print*,'profiles(1)%p_surf: ',profiles(1)%p +! print*,'inst_profiles(:)%s2m%p: ',inst_profiles(:)%s2m%p +! print*,'inst_profiles(1)%p_surf: ',inst_profiles(1)%p if (inst_nthreads <= 1) then if (verbose) print*,'Calling rttov_direct' call rttov_direct( & errorstatus, &! out error flag - chanprof, &! in channel and profile index structure + inst_chanprof, &! in channel and profile index structure inst_opts, &! in options structure - profiles, &! in profile array + inst_profiles, &! in profile array inst_coefs, &! in coefficients structure - transmission, &! inout computed transmittances - radiance, &! inout computed radiances - calcemis = calcemis, &! in flag for internal emissivity calcs - emissivity = emissivity, &! inout input/output emissivities per channel - calcrefl = calcrefl, &! in flag for internal BRDF calcs - reflectance = reflectance) ! inout input/output BRDFs per channel + inst_transmission, &! inout computed transmittances + inst_radiance, &! inout computed radiances + calcemis = inst_calcemis, &! in flag for internal emissivity calcs + emissivity = inst_emissivity, &! inout input/output emissivities per channel + calcrefl = inst_calcrefl, &! in flag for internal BRDF calcs + reflectance = inst_reflectance) ! inout input/output BRDFs per channel else if (verbose) print*,'Calling rttov_parallel_direct' call rttov_parallel_direct( & errorstatus, &! out error flag - chanprof, &! in channel and profile index structure + inst_chanprof, &! in channel and profile index structure inst_opts, &! in options structure - profiles, &! in profile array + inst_profiles, &! in profile array inst_coefs, &! in coefficients structure - transmission, &! inout computed transmittances - radiance, &! inout computed radiances - calcemis = calcemis, &! in flag for internal emissivity calcs - emissivity = emissivity, &! inout input/output emissivities per channel - calcrefl = calcrefl, &! in flag for internal BRDF calcs - reflectance = reflectance,&! inout input/output BRDFs per channel + inst_transmission, &! inout computed transmittances + inst_radiance, &! inout computed radiances + calcemis = inst_calcemis, &! in flag for internal emissivity calcs + emissivity = inst_emissivity, &! inout input/output emissivities per channel + calcrefl = inst_calcrefl, &! in flag for internal BRDF calcs + reflectance = inst_reflectance,&! inout input/output BRDFs per channel nthreads = inst_nthreads) ! in number of threads to use endif call rttov_error('rttov_direct error', lalloc = .true.) @@ -920,21 +991,43 @@ end subroutine cosp_rttov_call_direct ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine cosp_pc_rttov_call_direct(inst_nthreads, & inst_opts, & + inst_profiles, & inst_coefs, & + inst_chanprof, & + inst_transmission, & inst_nchannels_rec, & inst_channels_rec, & + inst_radiance, & + inst_calcemis, & + inst_emissivity, & + inst_pccomp, & debug) integer(KIND=jpim),intent(in) :: & inst_nthreads type(rttov_options),intent(in) :: & inst_opts + type(rttov_profile),pointer,intent(in) :: & + inst_profiles(:) type(rttov_coefs),intent(in) :: & inst_coefs + type(rttov_chanprof),pointer,intent(in) :: & + inst_chanprof(:) + type(rttov_transmission),intent(inout) :: & + inst_transmission integer(jpim),intent(in) :: & inst_nchannels_rec integer(jpim),dimension(inst_nchannels_rec),intent(in) :: & inst_channels_rec + type(rttov_radiance),intent(inout) :: & + inst_radiance + logical(kind=jplm),pointer,intent(in) :: & + inst_calcemis(:) + type(rttov_emissivity),pointer,intent(in) :: & + inst_emissivity(:) + type(rttov_pccomp),intent(inout) :: & + inst_pccomp ! Output PC structure + logical,intent(in),optional :: & debug logical :: verbose = .false. @@ -945,29 +1038,29 @@ subroutine cosp_pc_rttov_call_direct(inst_nthreads, & if (verbose) print*,'Calling rttov_direct (PC-RTTOV)' call rttov_direct( & errorstatus, &! out error flag - chanprof, &! in channel and profile index structure + inst_chanprof, &! in channel and profile index structure inst_opts, &! in options structure - profiles, &! in profile array + inst_profiles, &! in profile array inst_coefs, &! in coefficients structure - transmission, &! inout computed transmittances - radiance, &! inout computed radiances - calcemis = calcemis, &! in flag for internal emissivity calcs - emissivity = emissivity, &! inout input/output emissivities per channel - pccomp = pccomp, &! inout computed PC scores + inst_transmission, &! inout computed transmittances + inst_radiance, &! inout computed radiances + calcemis = inst_calcemis, &! in flag for internal emissivity calcs + emissivity = inst_emissivity, &! inout input/output emissivities per channel + pccomp = inst_pccomp,&! inout computed PC scores channels_rec = inst_channels_rec) ! in reconstructed channel list else if (verbose) print*,'Calling rttov_parallel_direct (PC-RTTOV)' call rttov_parallel_direct( & errorstatus, &! out error flag - chanprof, &! in channel and profile index structure + inst_chanprof, &! in channel and profile index structure inst_opts, &! in options structure - profiles, &! in profile array + inst_profiles, &! in profile array inst_coefs, &! in coefficients structure - transmission, &! inout computed transmittances - radiance, &! inout computed radiances - calcemis = calcemis, &! in flag for internal emissivity calcs - emissivity = emissivity, &! inout input/output emissivities per channel - pccomp = pccomp, &! inout computed PC scores + inst_transmission, &! inout computed transmittances + inst_radiance, &! inout computed radiances + calcemis = inst_calcemis, &! in flag for internal emissivity calcs + emissivity = inst_emissivity, &! inout input/output emissivities per channel + pccomp = inst_pccomp, &! inout computed PC scores channels_rec = inst_channels_rec,&! in reconstructed channel list nthreads = inst_nthreads) ! in number of threads to use endif @@ -981,7 +1074,7 @@ end subroutine cosp_pc_rttov_call_direct subroutine cosp_rttov_save_output(nPoints,inst_nchan_out,inst_swath_mask, & Lrttov_bt,Lrttov_rad,Lrttov_refl, & - Lrttov_cld,Lrttov_aer, & + Lrttov_cld,Lrttov_aer,inst_radiance, & bt_total,bt_clear, & rad_total,rad_clear,rad_cloudy, & refl_total,refl_clear) @@ -996,6 +1089,8 @@ subroutine cosp_rttov_save_output(nPoints,inst_nchan_out,inst_swath_mask, & Lrttov_refl, & Lrttov_cld, & Lrttov_aer + type(rttov_radiance),intent(in) :: & + inst_radiance real(wp),dimension(nPoints,inst_nchan_out),intent(inout) :: & bt_total, & bt_clear, & @@ -1014,54 +1109,54 @@ subroutine cosp_rttov_save_output(nPoints,inst_nchan_out,inst_swath_mask, & if (count(inst_swath_mask) .eq. nPoints) then ! No swathing, save all output if (Lrttov_bt) then bt_total(1:nPoints, 1:inst_nchan_out) = & - transpose(reshape(radiance%bt(1:inst_nchan_out * nPoints), (/ inst_nchan_out, nPoints/) )) + transpose(reshape(inst_radiance%bt(1:inst_nchan_out * nPoints), (/ inst_nchan_out, nPoints/) )) end if if (Lrttov_bt .and. (Lrttov_cld .or. Lrttov_aer)) then bt_clear(1:nPoints, 1:inst_nchan_out) = & - transpose(reshape(radiance%bt_clear(1:inst_nchan_out * nPoints), (/ inst_nchan_out, nPoints/) )) + transpose(reshape(inst_radiance%bt_clear(1:inst_nchan_out * nPoints), (/ inst_nchan_out, nPoints/) )) end if if (Lrttov_rad) then rad_total(1:nPoints, 1:inst_nchan_out) = & - transpose(reshape(radiance%total(1:inst_nchan_out * nPoints), (/ inst_nchan_out, nPoints/) )) + transpose(reshape(inst_radiance%total(1:inst_nchan_out * nPoints), (/ inst_nchan_out, nPoints/) )) end if if (Lrttov_rad .and. (Lrttov_cld .or. Lrttov_aer)) then rad_clear(1:nPoints, 1:inst_nchan_out) = & - transpose(reshape(radiance%clear(1:inst_nchan_out * nPoints), (/ inst_nchan_out, nPoints/) )) + transpose(reshape(inst_radiance%clear(1:inst_nchan_out * nPoints), (/ inst_nchan_out, nPoints/) )) rad_cloudy(1:nPoints, 1:inst_nchan_out) = & - transpose(reshape(radiance%cloudy(1:inst_nchan_out * nPoints), (/ inst_nchan_out, nPoints/) )) + transpose(reshape(inst_radiance%cloudy(1:inst_nchan_out * nPoints), (/ inst_nchan_out, nPoints/) )) end if if (Lrttov_refl) then refl_total(1:nPoints, 1:inst_nchan_out) = & - transpose(reshape(radiance%refl(1:inst_nchan_out * nPoints), (/ inst_nchan_out, nPoints/) )) + transpose(reshape(inst_radiance%refl(1:inst_nchan_out * nPoints), (/ inst_nchan_out, nPoints/) )) end if if (Lrttov_refl .and. (Lrttov_cld .or. Lrttov_aer)) then refl_clear(1:nPoints, 1:inst_nchan_out) = & - transpose(reshape(radiance%refl_clear(1:inst_nchan_out * nPoints), (/ inst_nchan_out, nPoints/) )) + transpose(reshape(inst_radiance%refl_clear(1:inst_nchan_out * nPoints), (/ inst_nchan_out, nPoints/) )) end if else ! If swathing is occurring, assign the outputs appropriately j = 0 do i=1,nPoints if (inst_swath_mask(i)) then ! only added masked columns to profiles if (Lrttov_bt) then - bt_total(i, 1:inst_nchan_out) = radiance%bt(1 + (j * inst_nchan_out):(j+1) * inst_nchan_out) + bt_total(i, 1:inst_nchan_out) = inst_radiance%bt(1 + (j * inst_nchan_out):(j+1) * inst_nchan_out) end if if (Lrttov_bt .and. (Lrttov_cld .or. Lrttov_aer)) then - bt_clear(i, 1:inst_nchan_out) = radiance%bt_clear(1 + (j * inst_nchan_out):(j+1) * inst_nchan_out) + bt_clear(i, 1:inst_nchan_out) = inst_radiance%bt_clear(1 + (j * inst_nchan_out):(j+1) * inst_nchan_out) end if if (Lrttov_rad) then - rad_total(i, 1:inst_nchan_out) = radiance%total(1 + (j * inst_nchan_out):(j+1) * inst_nchan_out) + rad_total(i, 1:inst_nchan_out) = inst_radiance%total(1 + (j * inst_nchan_out):(j+1) * inst_nchan_out) end if if (Lrttov_rad .and. (Lrttov_cld .or. Lrttov_aer)) then - rad_clear(i, 1:inst_nchan_out) = radiance%clear(1 + (j * inst_nchan_out):(j+1) * inst_nchan_out) - rad_cloudy(i, 1:inst_nchan_out) = radiance%cloudy(1 + (j * inst_nchan_out):(j+1) * inst_nchan_out) + rad_clear(i, 1:inst_nchan_out) = inst_radiance%clear(1 + (j * inst_nchan_out):(j+1) * inst_nchan_out) + rad_cloudy(i, 1:inst_nchan_out) = inst_radiance%cloudy(1 + (j * inst_nchan_out):(j+1) * inst_nchan_out) end if if (Lrttov_refl) then - refl_total(i, 1:inst_nchan_out) = radiance%refl(1 + (j * inst_nchan_out):(j+1) * inst_nchan_out) + refl_total(i, 1:inst_nchan_out) = inst_radiance%refl(1 + (j * inst_nchan_out):(j+1) * inst_nchan_out) end if if (Lrttov_refl .and. (Lrttov_cld .or. Lrttov_aer)) then - refl_clear(i, 1:inst_nchan_out) = radiance%refl_clear(1 + (j * inst_nchan_out):(j+1) * inst_nchan_out) + refl_clear(i, 1:inst_nchan_out) = inst_radiance%refl_clear(1 + (j * inst_nchan_out):(j+1) * inst_nchan_out) end if j = j + 1 ! Increment profile counter afterwards end if @@ -1080,6 +1175,7 @@ end subroutine cosp_rttov_save_output subroutine cosp_pc_rttov_save_output(nPoints, & inst_nchannels_rec, & inst_swath_mask, & + inst_pccomp, & Lrttov_bt, & Lrttov_rad, & bt_clear, & @@ -1091,12 +1187,14 @@ subroutine cosp_pc_rttov_save_output(nPoints, & inst_nchannels_rec logical,dimension(nPoints),intent(in) :: & inst_swath_mask + type(rttov_pccomp),intent(in) :: & + inst_pccomp ! Output PC structure logical,intent(in) :: & Lrttov_bt, & Lrttov_rad real(wp),dimension(nPoints,inst_nchannels_rec),intent(inout) :: & ! Can I do this? I guess so! bt_clear, & - rad_clear + rad_clear logical,intent(in),optional :: & debug @@ -1111,8 +1209,8 @@ subroutine cosp_pc_rttov_save_output(nPoints, & print*,'shape(rad_total): ',shape(rad_clear) print*,'nPoints: ',nPoints print*,'inst_nchannels_rec: ',inst_nchannels_rec - print*,'size(pccomp%bt_pccomp): ',size(pccomp%bt_pccomp) - print*,'size(pccomp%total_pccomp): ',size(pccomp%total_pccomp) + print*,'size(inst_pccomp%bt_pccomp): ',size(inst_pccomp%bt_pccomp) + print*,'size(inst_pccomp%total_pccomp): ',size(inst_pccomp%total_pccomp) print*,'inst_nchannels_rec * nPoints: ',inst_nchannels_rec * nPoints end if @@ -1122,21 +1220,21 @@ subroutine cosp_pc_rttov_save_output(nPoints, & if (count(inst_swath_mask) .eq. nPoints) then ! No swathing, save all output if (Lrttov_bt) then bt_clear(1:nPoints, 1:inst_nchannels_rec) = & - transpose(reshape(pccomp%bt_pccomp(1:(inst_nchannels_rec * nPoints)), (/ inst_nchannels_rec, nPoints/) )) + transpose(reshape(inst_pccomp%bt_pccomp(1:(inst_nchannels_rec * nPoints)), (/ inst_nchannels_rec, nPoints/) )) end if if (Lrttov_rad) then rad_clear(1:nPoints, 1:inst_nchannels_rec) = & - transpose(reshape(pccomp%total_pccomp(1:(inst_nchannels_rec * nPoints)), (/ inst_nchannels_rec, nPoints/) )) + transpose(reshape(inst_pccomp%total_pccomp(1:(inst_nchannels_rec * nPoints)), (/ inst_nchannels_rec, nPoints/) )) end if else ! If swathing is occurring, assign the outputs appropriately j = 0 do i=1,nPoints if (inst_swath_mask(i)) then ! only added masked columns to profiles if (Lrttov_bt) then - bt_clear(i, 1:inst_nchannels_rec) = pccomp%bt_pccomp(1 + (j * inst_nchannels_rec):(j+1) * inst_nchannels_rec) + bt_clear(i, 1:inst_nchannels_rec) = inst_pccomp%bt_pccomp(1 + (j * inst_nchannels_rec):(j+1) * inst_nchannels_rec) end if if (Lrttov_rad) then - rad_clear(i, 1:inst_nchannels_rec) = pccomp%total_pccomp(1 + (j * inst_nchannels_rec):(j+1) * inst_nchannels_rec) + rad_clear(i, 1:inst_nchannels_rec) = inst_pccomp%total_pccomp(1 + (j * inst_nchannels_rec):(j+1) * inst_nchannels_rec) end if j = j + 1 ! Increment profile counter afterwards end if @@ -1155,7 +1253,15 @@ subroutine cosp_rttov_deallocate_profiles(inst_nprof, & inst_nchanprof, & nLevels, & inst_opts, & - inst_coefs) + inst_profiles, & + inst_coefs, & + inst_chanprof, & + inst_transmission, & + inst_radiance, & + inst_calcemis, & + inst_emissivity, & + inst_calcrefl, & + inst_reflectance) integer(kind=jpim),intent(in) :: & inst_nprof, & @@ -1163,9 +1269,24 @@ subroutine cosp_rttov_deallocate_profiles(inst_nprof, & nLevels type(rttov_options),intent(in) :: & inst_opts + type(rttov_profile),pointer,intent(in) :: & + inst_profiles(:) type(rttov_coefs),intent(in) :: & inst_coefs - + type(rttov_chanprof),pointer,intent(inout) :: & + inst_chanprof(:) + type(rttov_transmission),intent(inout) :: & + inst_transmission + type(rttov_radiance),intent(inout) :: & + inst_radiance + logical(kind=jplm),pointer,intent(inout) :: & + inst_calcemis(:) + type(rttov_emissivity),pointer,intent(inout) :: & + inst_emissivity(:) + logical(kind=jplm),pointer,intent(inout) :: & + inst_calcrefl(:) + type(rttov_reflectance),pointer,intent(inout) :: & + inst_reflectance(:) ! Deallocate structures for rttov_direct call rttov_alloc_direct( & @@ -1174,16 +1295,16 @@ subroutine cosp_rttov_deallocate_profiles(inst_nprof, & inst_nprof, & inst_nchanprof, & nLevels, & - chanprof, & ! JKS + inst_chanprof, & inst_opts, & - profiles, & + inst_profiles, & inst_coefs, & - transmission, & - radiance, & - calcemis=calcemis, & - emissivity=emissivity, & - calcrefl=calcrefl, & - reflectance=reflectance) + inst_transmission, & + inst_radiance, & + calcemis=inst_calcemis, & + emissivity=inst_emissivity, & + calcrefl=inst_calcrefl, & + reflectance=inst_reflectance) call rttov_error('deallocation error for rttov_direct structures', lalloc = .true.) end subroutine cosp_rttov_deallocate_profiles @@ -1199,7 +1320,14 @@ subroutine cosp_pc_rttov_deallocate_profiles(inst_nprof, & nlevels, & inst_nChannels_rec, & inst_opts, & - inst_coefs) + inst_profiles, & + inst_coefs, & + inst_chanprof, & + inst_transmission, & + inst_radiance, & + inst_calcemis, & + inst_emissivity, & + inst_pccomp) integer(kind=jpim),intent(in) :: & inst_nprof, & @@ -1208,14 +1336,25 @@ subroutine cosp_pc_rttov_deallocate_profiles(inst_nprof, & inst_nChannels_rec type(rttov_options),intent(in) :: & inst_opts + type(rttov_profile),pointer,intent(in) :: & + inst_profiles(:) type(rttov_coefs),intent(in) :: & inst_coefs + type(rttov_chanprof),pointer,intent(inout) :: & + inst_chanprof(:) + type(rttov_transmission),intent(inout) :: & + inst_transmission + type(rttov_radiance),intent(inout) :: & + inst_radiance + logical(kind=jplm),pointer,intent(inout) :: & + inst_calcemis(:) + type(rttov_emissivity),pointer,intent(inout) :: & + inst_emissivity(:) + type(rttov_pccomp),intent(inout) :: & + inst_pccomp ! Output PC structure if (ASSOCIATED(predictindex)) deallocate (predictindex, stat=alloc_status(10)) call rttov_error('mem dellocation error for "predictindex"', lalloc = .true.) - - if (ASSOCIATED(channels_rec)) deallocate (channels_rec, stat=alloc_status(11)) - call rttov_error('mem dellocation error for "channels_rec"', lalloc = .true.) ! Deallocate structures for rttov_direct call rttov_alloc_direct( & @@ -1224,17 +1363,17 @@ subroutine cosp_pc_rttov_deallocate_profiles(inst_nprof, & inst_nprof, & inst_nchanprof, & nLevels, & - chanprof, & + inst_chanprof, & inst_opts, & - profiles, & + inst_profiles, & inst_coefs, & - transmission, & - radiance, & - calcemis=calcemis, & - emissivity=emissivity, & + inst_transmission, & + inst_radiance, & + calcemis=inst_calcemis, & + emissivity=inst_emissivity, & npcscores=inst_opts%rt_ir%pc%npcscores * inst_nprof, & nchannels_rec=inst_nChannels_rec * inst_nprof, & - pccomp=pccomp) + pccomp=inst_pccomp) call rttov_error('deallocation error for rttov_direct structures (PC-RTTOV)', lalloc = .true.) end subroutine cosp_pc_rttov_deallocate_profiles From 4ae0d11675fc96d5411545fa12cad1a3a15b4521 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 22 Nov 2023 09:30:36 -0700 Subject: [PATCH 100/159] Another attempt at thread-safe changes... --- src/simulator/cosp_rttov_interface_v13.F90 | 18 ++++---- src/simulator/rttov/cosp_rttov_v13.F90 | 50 ++++++++++------------ 2 files changed, 33 insertions(+), 35 deletions(-) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 81841331a3..6b528cf1bb 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -73,11 +73,8 @@ MODULE MOD_COSP_RTTOV_INTERFACE #include "rttov_print_opts.interface" #include "rttov_get_pc_predictindex.interface" - ! RTTOV variables/structures. Should not be global to make thread-safe. + ! RTTOV variables/structures. !==================== - INTEGER(KIND=jpim) :: errorstatus ! Return error status of RTTOV subroutine calls - - INTEGER(KIND=jpim) :: alloc_status(60) ! DDT for each instrument being simulated. Values to be assigned during the cosp_rttov_init subroutine type rttov_cfg @@ -266,6 +263,8 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & ! JKS for checking errors in filenames. character(len=256) :: imsg !<-- some suitable length, say XX=256 integer :: erro + integer(kind=jplm) :: errorstatus ! Return error status of RTTOV subroutine calls + integer(kind=jpim) :: alloc_status(60) logical :: verbose = .false. if (present(debug)) verbose = debug @@ -645,7 +644,7 @@ END SUBROUTINE DESTROY_RTTOV_CONFIG !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_simulate - Call subroutines in mod_cosp_rttov to run RTTOV !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup,error, & ! Inputs + RECURSIVE SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup,error, & ! Inputs bt_total,bt_clear, & ! Brightness Temp Outputs rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs refl_total,refl_clear, & ! Reflectance Outputs @@ -907,7 +906,8 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, type(rttov_emissivity), pointer :: emissivity(:) => NULL() ! Input/output surface emissivity logical(kind=jplm), pointer :: calcrefl(:) => NULL() ! Flag to indicate calculation of BRDF within RTTOV type(rttov_reflectance), pointer :: reflectance(:) => NULL() ! Input/output surface BRDF - type(rttov_chanprof), POINTER :: chanprof(:) => NULL() ! Input channel/profile list + type(rttov_chanprof), pointer :: chanprof(:) => NULL() ! Input channel/profile list + integer(KIND=jpim), pointer :: predictindex(:) logical,intent(in) :: verbose real(wp),dimension(10) :: driver_time @@ -936,7 +936,8 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, radiance, & calcemis, & emissivity, & - rttovConfig % pccomp) + rttovConfig % pccomp, & + predictindex) call cpu_time(driver_time(2)) ! if (verbose) print*,'Beginning "cosp_rttov_construct_profiles".' call cosp_rttov_construct_profiles(rttovIN, & @@ -1003,7 +1004,8 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, radiance, & calcemis, & emissivity, & - rttovConfig % pccomp) + rttovConfig % pccomp, & + predictindex) call cpu_time(driver_time(7)) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 47f675d7d3..ce121a6349 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -64,7 +64,6 @@ module mod_cosp_rttov implicit none - ! New includes for v13 (will need to clean up others) #include "rttov_direct.interface" #include "rttov_parallel_direct.interface" @@ -87,27 +86,17 @@ module mod_cosp_rttov #include "rttov_bpr_dealloc.interface" #include "rttov_legcoef_calc.interface" #include "rttov_calc_solar_angles.interface" - - ! Module parameters - integer, parameter :: maxlim = 10000 - real(wp),parameter :: eps = 0.622 - - ! Initialization parameters ! Scattering coefficients (read in once during initialization) ! JKS - KISS ! type(rttov_scatt_coef) :: & ! coef_scatt - ! module-wides variables for input + ! module-wides variables for input. Not sure if unsafe for threading. !==================== - INTEGER(KIND=jpim) :: errorstatus ! Return error status of RTTOV subroutine calls + INTEGER(KIND=jpim) :: errorstatus ! Return error status of RTTOV subroutine calls INTEGER(KIND=jpim) :: alloc_status(60) - - ! JKS additional variables used in PC-RTTOV - INTEGER(KIND=jpim), POINTER :: predictindex(:) - INTEGER(KIND=jpim) :: nchannels_comp, npcscores, npred_pc ! npred to go here ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! TYPE rttov_in @@ -351,7 +340,8 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, inst_chanprof, & inst_nchanprof,inst_nprof,inst_iChannel_out, & inst_swath_mask,inst_transmission,inst_radiance, & - inst_calcemis,inst_emissivity,inst_pccomp,debug) + inst_calcemis,inst_emissivity,inst_pccomp, & + inst_predictindex,debug) type(rttov_in),intent(in) :: & rttovIN @@ -390,7 +380,9 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, type(rttov_emissivity),pointer,intent(out) :: & inst_emissivity(:) type(rttov_pccomp),intent(inout) :: & - inst_pccomp ! Output PC structure + inst_pccomp ! Output PC structure + integer(kind=jpim),pointer,intent(inout) :: & + inst_predictindex(:) logical,intent(in),optional :: & debug @@ -421,8 +413,8 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, ! Largely from RTTOV documentation. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - nullify(predictindex) - call rttov_get_pc_predictindex(errorstatus, inst_opts, predictindex, file_pccoef=inst_PC_coef_filepath) + nullify(inst_predictindex) + call rttov_get_pc_predictindex(errorstatus, inst_opts, inst_predictindex, file_pccoef=inst_PC_coef_filepath) call rttov_error('rttov_get_pc_predictindex fatal error' , lalloc = .false.) ! Handle swathing here. Initial code from Genevieve with minor changes. @@ -459,8 +451,7 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, ! Determine the total number of radiances to simulate (nchanprof). inst_nprof = count(inst_swath_mask) - ! npred_pc is only used in the pc_rttov_allocate step so I can remove the global definition later - inst_npred_pc = SIZE(predictindex) + inst_npred_pc = SIZE(inst_predictindex) inst_nchanprof = inst_npred_pc * inst_nprof ! Size of chanprof array is total number of predictors over all profiles if (verbose) then @@ -520,12 +511,12 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, ! Largely from RTTOV documentation. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Populate chanprof using the channel list obtained above in predictindex(:) + ! Populate chanprof using the channel list obtained above in inst_predictindex(:) do j = 1, inst_nprof lo = (j - 1) * inst_npred_pc + 1 hi = lo + inst_npred_pc - 1 inst_chanprof(lo:hi)%prof = j - inst_chanprof(lo:hi)%chan = predictindex(:) + inst_chanprof(lo:hi)%chan = inst_predictindex(:) end do end subroutine cosp_pc_rttov_allocate @@ -589,7 +580,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & debug ! Loop variables - integer(kind=jpim) :: i, j ! Use i to iterate over profile, j for swath_mask. + integer(kind=jpim) :: i, j ! Use i to iterate over profile, j for swath_mask. logical :: verbose = .false. if (present(debug)) verbose = debug @@ -934,6 +925,8 @@ subroutine cosp_rttov_call_direct(inst_nthreads, & inst_reflectance(:) logical,intent(in),optional :: & debug + + ! Local variables logical :: verbose = .false. if (present(debug)) verbose = debug @@ -953,7 +946,7 @@ subroutine cosp_rttov_call_direct(inst_nthreads, & if (verbose) print*,'Calling rttov_direct' call rttov_direct( & errorstatus, &! out error flag - inst_chanprof, &! in channel and profile index structure + inst_chanprof, &! in channel and profile index structure inst_opts, &! in options structure inst_profiles, &! in profile array inst_coefs, &! in coefficients structure @@ -1287,7 +1280,7 @@ subroutine cosp_rttov_deallocate_profiles(inst_nprof, & inst_calcrefl(:) type(rttov_reflectance),pointer,intent(inout) :: & inst_reflectance(:) - + ! Deallocate structures for rttov_direct call rttov_alloc_direct( & errorstatus, & @@ -1327,7 +1320,8 @@ subroutine cosp_pc_rttov_deallocate_profiles(inst_nprof, & inst_radiance, & inst_calcemis, & inst_emissivity, & - inst_pccomp) + inst_pccomp, & + inst_predictindex) integer(kind=jpim),intent(in) :: & inst_nprof, & @@ -1352,9 +1346,11 @@ subroutine cosp_pc_rttov_deallocate_profiles(inst_nprof, & inst_emissivity(:) type(rttov_pccomp),intent(inout) :: & inst_pccomp ! Output PC structure + integer(kind=jpim),pointer,intent(inout) :: & + inst_predictindex(:) - if (ASSOCIATED(predictindex)) deallocate (predictindex, stat=alloc_status(10)) - call rttov_error('mem dellocation error for "predictindex"', lalloc = .true.) + if (ASSOCIATED(inst_predictindex)) deallocate (inst_predictindex, stat=alloc_status(10)) + call rttov_error('mem dellocation error for "inst_predictindex"', lalloc = .true.) ! Deallocate structures for rttov_direct call rttov_alloc_direct( & From a740198cc016cb044666c1c746d379eb85173965 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Thu, 11 Jan 2024 13:45:53 -0700 Subject: [PATCH 101/159] Port COSP2 Makefiles to Derecho. No HDF5 install. --- build/Makefile.conf | 7 ++++++- build/Makefile.rttov | 11 ++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/build/Makefile.conf b/build/Makefile.conf index d5c9ba6d29..a0d59278ad 100644 --- a/build/Makefile.conf +++ b/build/Makefile.conf @@ -1,7 +1,12 @@ +F90 = ifort #F90 = gfortran #F90FLAGS = -O3 -ffree-line-length-none -fcheck=bounds -finit-real=nan -F90_LIB = /home/runner/netcdf-fortran +# Old Cheyenne F90 path? +# F90_LIB = /glade/u/apps/ch/opt/ncarcompilers/0.5.0/intel/19.1.1/ifort +# Updated Derecho F90 path? +F90_LIB = /glade/u/apps/common/23.04/spack/opt/spack/intel-oneapi-compilers/2023.0.0/compiler/2023.0.0/linux/bin/intel64/ifort +#F90_LIB = /home/runner/netcdf-fortran #F90_LIB = /glade/u/apps/dav/opt/netcdf/4.8.1/gnu/9.1.0 #F90_LIB = /glade/u/apps/dav/opt/netcdf/4.8.1/gnu/10.1.0 NC_INC = -I$(F90_LIB)/include diff --git a/build/Makefile.rttov b/build/Makefile.rttov index 1e885c7f6b..3f93e7e89e 100644 --- a/build/Makefile.rttov +++ b/build/Makefile.rttov @@ -20,10 +20,15 @@ # RTTOVDIR=../../ -RTTOVDIR=/glade/u/home/jonahshaw/w/RTTOV +# Cheyenne version (with HDF5) +# RTTOVDIR=/glade/u/home/jonahshaw/w/RTTOV + +# Derecho version (without HDF5). Note: You need a copy of Makefile.local in the RTTOVDIR directory in a build/ subdirectory +RTTOVDIR=/glade/u/home/jonahshaw/w/RTTOV/alt_build FC=gfortran -FFLAGS= -I$(RTTOVDIR)/mod -I$(RTTOVDIR)/include -fPIC -O3 -fopenmp -ffree-line-length-none +#FFLAGS= -I$(RTTOVDIR)/mod -I$(RTTOVDIR)/include -fPIC -O3 -fopenmp -ffree-line-length-none +FFLAGS= -I$(RTTOVDIR)/mod -I$(RTTOVDIR)/include -fPIC -O3 -fopenmp LDFLAGS_ARCH=-fopenmp @@ -83,4 +88,4 @@ else -lrttov$(RTTOV_VERSION)_coef_io \ -lrttov$(RTTOV_VERSION)_parallel \ -lrttov$(RTTOV_VERSION)_main -endif \ No newline at end of file +endif From fd48359106a5023ae0f0e3235a887f220e12a0b8 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Thu, 11 Jan 2024 13:48:43 -0700 Subject: [PATCH 102/159] Namelist + other inputs changes for CESM2 AGU sims --- driver/run/cosp2_input_rttov_nl.txt | 8 +- driver/run/cosp2_input_rttov_nl.um_global.txt | 4 +- .../run/instrument_nls/cosp2_rttov_inst5.txt | 79 ------------------ .../cosp2_rttov_inst5PREFIRE_CESM2.txt | 0 .../cosp2_rttov_inst5_PREFIRE_CESM2.txt | 80 +++++++++++++++++++ .../cosp2_rttov_inst6_AIRS_CESM2_bin.txt | 77 ++++++++++++++++++ .../cosp2_rttov_inst7_VIIRS_CESM2.txt | 80 +++++++++++++++++++ .../rttov_channel_input_PREFIRE_subset.csv | 55 +++++++++++++ .../run/rttov_channel_input_VIIRS_subset.csv | 2 + 9 files changed, 301 insertions(+), 84 deletions(-) create mode 100644 driver/run/instrument_nls/cosp2_rttov_inst5PREFIRE_CESM2.txt create mode 100644 driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt create mode 100644 driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt create mode 100644 driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt create mode 100644 driver/run/rttov_channel_input_PREFIRE_subset.csv create mode 100644 driver/run/rttov_channel_input_VIIRS_subset.csv diff --git a/driver/run/cosp2_input_rttov_nl.txt b/driver/run/cosp2_input_rttov_nl.txt index 98fc378781..6d95739e52 100644 --- a/driver/run/cosp2_input_rttov_nl.txt +++ b/driver/run/cosp2_input_rttov_nl.txt @@ -36,7 +36,7 @@ DINPUT='./', ! Directory where the input files are located. Useful when processing multiple files. ! Leave blank ('') if you are using the full path in FINPUT. FINPUT='../data/inputs/UKMO/cosp_input_um.nc', ! List input NetCDF files - FOUTPUT='../data/outputs/UKMO/cosp2_output_rttov_um.nc', + FOUTPUT='../data/outputs/UKMO/cosp2_output_rttov_um_bin.nc', !---------------------------------------------------------------------------------- !--------------- Inputs related to radar simulations !---------------------------------------------------------------------------------- @@ -82,8 +82,10 @@ !---------------------------------------------------------------------------------- !-------------- RTTOV inputs !---------------------------------------------------------------------------------- - rttov_Ninstruments=6, - rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt','instrument_nls/cosp2_rttov_inst4.txt','instrument_nls/cosp2_rttov_inst5.txt','instrument_nls/cosp2_rttov_inst6_AIRS_CESM2.txt', +rttov_Ninstruments=3, + rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt','instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt','instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt', +! rttov_Ninstruments=7, +! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt','instrument_nls/cosp2_rttov_inst4.txt','instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt','instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt','instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt', ! rttov_Ninstruments=4, ! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt','instrument_nls/cosp2_rttov_inst4.txt', ! rttov_Ninstruments=3, diff --git a/driver/run/cosp2_input_rttov_nl.um_global.txt b/driver/run/cosp2_input_rttov_nl.um_global.txt index 8d48eb7a87..f2a99159f4 100644 --- a/driver/run/cosp2_input_rttov_nl.um_global.txt +++ b/driver/run/cosp2_input_rttov_nl.um_global.txt @@ -82,8 +82,8 @@ !---------------------------------------------------------------------------------- !-------------- RTTOV inputs !---------------------------------------------------------------------------------- - rttov_Ninstruments=3, - rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt', + rttov_Ninstruments=4, + rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt','instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt', ! rttov_Ninstruments=1, ! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt', rttov_verbose=.true. diff --git a/driver/run/instrument_nls/cosp2_rttov_inst5.txt b/driver/run/instrument_nls/cosp2_rttov_inst5.txt index 1b70d5ba32..e69de29bb2 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst5.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst5.txt @@ -1,79 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.false., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_pc=.false., ! Run with PC-RTTOV - Lrttov_solar=.false., ! Do solar calculations - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=0, ! 2300 - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_AIRS.csv', - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='PREFIRE/rtcoef_prefire_1_tirs_o3co2.dat', -! aer_coef_filepath='cldaer_visir/scaercoef_eos_2_modis-shifted_cams.dat', -! cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_modis-shifted.dat', -! OD_coef_filepath='rttov9pred101L/rtcoef_eos_2_airs_pcrttov_compat.H5', -! aer_coef_filepath='cldaer_visir/scaercoef_eos_2_airs_cams.H5', -! cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_airs.H5', - PC_coef_filepath='pc/pccoef_eos_2_airs_landsea.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.false., - CO_data=.false., - CO2_data=.true., - CH4_data=.false., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_ZenAng=0.0, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at -/ diff --git a/driver/run/instrument_nls/cosp2_rttov_inst5PREFIRE_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_inst5PREFIRE_CESM2.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt new file mode 100644 index 0000000000..e8f926ae0e --- /dev/null +++ b/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt @@ -0,0 +1,80 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.false., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_pc=.false., ! Run with PC-RTTOV + Lrttov_solar=.false., ! Do solar calculations + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=55, ! + !-------------- RTTOV Filepaths + Lchannel_filepath=.true., + channel_filepath='rttov_channel_input_PREFIRE_subset.csv', + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='PREFIRE/rtcoef_prefire_1_tirs_o3co2.dat', + cld_coef_filepath='PREFIRE/sccldcoef_prefire_1_tirs.dat', +! aer_coef_filepath='cldaer_visir/scaercoef_eos_2_modis-shifted_cams.dat', +! cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_modis-shifted.dat', +! OD_coef_filepath='rttov9pred101L/rtcoef_eos_2_airs_pcrttov_compat.H5', +! aer_coef_filepath='cldaer_visir/scaercoef_eos_2_airs_cams.H5', +! cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_airs.H5', + PC_coef_filepath='pc/pccoef_eos_2_airs_landsea.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.false., + CO_data=.false., + CO2_data=.true., + CH4_data=.false., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=0.0, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at +/ diff --git a/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt b/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt new file mode 100644 index 0000000000..7a3186572b --- /dev/null +++ b/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt @@ -0,0 +1,77 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.true., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=26, ! do a selection of AIRS channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.true., + channel_filepath='rttov_channel_input_AIRS_subset.csv', + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='AIRS_alt/rtcoef_eos_2_airs_7gas.bin', + cld_coef_filepath='AIRS_alt/sccldcoef_eos_2_airs.bin', +! OD_coef_filepath='AIRS_alt/rtcoef_eos_2_airs_7gas.dat', +! cld_coef_filepath='AIRS_alt/sccldcoef_eos_2_airs.dat', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.true., + CO_data=.false., + CO2_data=.true., + CH4_data=.true., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=0.0, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at +! rttov_localtime=0.75,13.5, ! Local times to sample at in hrs [0,24] +! rttov_localtime_width=2.e3,5.6e3, ! Swath width (km) +/ diff --git a/driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt new file mode 100644 index 0000000000..5295d190a3 --- /dev/null +++ b/driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt @@ -0,0 +1,80 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.true., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.true., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_pc=.false., ! Run with PC-RTTOV + Lrttov_solar=.true., ! Do solar calculations + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=2, ! do a selection of VIIRS channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.true., + channel_filepath='rttov_channel_input_VIIRS_subset.csv', + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='/rttov13pred54L/rtcoef_noaa_21_viirs_7gas.dat', + aer_coef_filepath='/cldaer_visir/scaercoef_noaa_21_viirs_cams.dat', + cld_coef_filepath='cldaer_visir/sccldcoef_noaa_21_viirs.dat', +! OD_coef_filepath='rttov13pred54L/rtcoef_ticfire_1_mbfiri_o3co2.dat', +! aer_coef_filepath='cldaer_visir/scaercoef_ticfire_1_mbfiri_cams.dat', +! cld_coef_filepath='cldaer_visir/sccldcoef_ticfire_1_mbfiri.dat', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.true., + CO_data=.false., + CO2_data=.true., + CH4_data=.true., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=0.0, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at +! rttov_localtime=0.75,13.5, ! Local times to sample at in hrs [0,24] +! rttov_localtime_width=2.e3,5.6e3, ! Swath width (km) +/ diff --git a/driver/run/rttov_channel_input_PREFIRE_subset.csv b/driver/run/rttov_channel_input_PREFIRE_subset.csv new file mode 100644 index 0000000000..10d0447249 --- /dev/null +++ b/driver/run/rttov_channel_input_PREFIRE_subset.csv @@ -0,0 +1,55 @@ +4,1,0 +5,1,0 +6,1,0 +7,1,0 +8,1,0 +11,1,0 +12,1,0 +13,1,0 +14,1,0 +15,1,0 +16,1,0 +17,1,0 +20,1,0 +21,1,0 +22,1,0 +23,1,0 +24,1,0 +25,1,0 +26,1,0 +27,1,0 +28,1,0 +29,1,0 +30,1,0 +31,1,0 +32,1,0 +33,1,0 +34,1,0 +35,1,0 +38,1,0 +39,1,0 +40,1,0 +41,1,0 +42,1,0 +43,1,0 +44,1,0 +45,1,0 +46,1,0 +47,1,0 +48,1,0 +49,1,0 +50,1,0 +51,1,0 +52,1,0 +53,1,0 +54,1,0 +55,1,0 +56,1,0 +57,1,0 +58,1,0 +59,1,0 +60,1,0 +61,1,0 +62,1,0 +63,1,0 +64,1,0 \ No newline at end of file diff --git a/driver/run/rttov_channel_input_VIIRS_subset.csv b/driver/run/rttov_channel_input_VIIRS_subset.csv new file mode 100644 index 0000000000..ccc407dcfd --- /dev/null +++ b/driver/run/rttov_channel_input_VIIRS_subset.csv @@ -0,0 +1,2 @@ +12,1,0 +13,1,0 \ No newline at end of file From b32f159a1228020d51737034c9b7acda208b2369 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Thu, 11 Jan 2024 13:53:01 -0700 Subject: [PATCH 103/159] Fix spectral axis labeling in offline COSP2 --- driver/src/cosp2_io.f90 | 4 ++-- src/simulator/cosp_rttov_interface_v13.F90 | 8 +++++--- src/simulator/rttov/cosp_rttov_v13.F90 | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/driver/src/cosp2_io.f90 b/driver/src/cosp2_io.f90 index bb8d2ef9db..e9c4039807 100644 --- a/driver/src/cosp2_io.f90 +++ b/driver/src/cosp2_io.f90 @@ -1440,10 +1440,10 @@ subroutine write_cosp2_output(Npoints, Ncolumns, Nlevels, Ninst_rttov, lev, lon, ii = 165 ! RTTOV variable indices start at 165 if (allocated(cospOUT%rttov_outputs)) then do i=1,Ninst_rttov - write (i_str,fmt) i ! converting integer to string i_str using a 'internal file' + write (i_str,fmt) i ! converting integer to string i_str using a 'internal file' if (associated(cospOUT%rttov_outputs(i)%channel_indices)) then ii = ii + 1 - status = nf90_def_var(fileID,"rttov_ichannel_inst"//trim(i_str),nf90_float, (/dimID(20+i)/),varID(ii)) + status = nf90_def_var(fileID,"RTTOV_CHAN_INST"//trim(i_str),nf90_float, (/dimID(20+i)/),varID(ii)) if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) status = nf90_put_att(fileID,varID(ii),"long_name","RTTOV Channel Indices") if (status .ne. nf90_NoERR) print*,trim(nf90_strerror(status)) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 6b528cf1bb..bb1b71687f 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -572,9 +572,10 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Read in channel indices, emissivities, and reflectivities from .csv if file is passed !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - + + allocate(rttov_config % iChannel(rttov_config % nchan_out)) ! There is a need for these variables to be separate somewhere... + allocate(rttov_config % iChannel_out(rttov_config % nchan_out)) if (Lchannel_filepath) then - allocate(rttov_config % iChannel(rttov_config % nchan_out)) allocate(rttov_config % emisChannel(rttov_config % nchan_out)) allocate(rttov_config % reflChannel(rttov_config % nchan_out)) @@ -583,9 +584,10 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & read(18,*) rttov_config % iChannel(i), rttov_config % emisChannel(i), rttov_config % reflChannel(i) end do close(18) + rttov_config % iChannel_out = rttov_config % iChannel else ! If nothing is passed, compute the first "nchan_out" channels. Ignore emissivity and reflectivity for now. - allocate(rttov_config % iChannel(rttov_config % nchan_out)) rttov_config % iChannel(:) = (/ (i, i = 1, rttov_config % nchan_out) /) + rttov_config % iChannel_out = rttov_config % iChannel endif if (verbose) then diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index ce121a6349..eac59c928d 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -733,8 +733,8 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & inst_profiles(j)%cloud(1,:) = rttovIN%cldLiq(i,:) ! Cloud water mixing ratio (all in the first type for Deff) inst_profiles(j)%cloud(6,:) = rttovIN%cldIce(i,:) ! Cloud ice mixing ratio (1 type). See pg 74. - inst_profiles(j)%clwde = rttovIN%DeffLiq(i,:) ! Cloud water effective diameter - inst_profiles(j)%icede = rttovIN%DeffIce(i,:) ! Cloud ice effective diameter + inst_profiles(j)%clwde = rttovIN%DeffLiq(i,:) ! Cloud water effective diameter (um) + inst_profiles(j)%icede = rttovIN%DeffIce(i,:) ! Cloud ice effective diameter (um) ! Example UKMO input has effective radii for multiple cloud types, making identification of a single ! liquid droplet or ice crystal effective diameter difficult. From c4d6cd0b49bc36b417767feca0d45d014f900171 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Mon, 15 Jan 2024 14:20:08 -0700 Subject: [PATCH 104/159] Separate coefficient dealloc from RTTOV run --- src/cosp.F90 | 7 +-- src/simulator/cosp_rttov_interface_v13.F90 | 51 ++++++---------------- 2 files changed, 16 insertions(+), 42 deletions(-) diff --git a/src/cosp.F90 b/src/cosp.F90 index 9aaf931aa4..9a80277041 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -377,7 +377,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ok_lidar_cfad = .false., & ok_lidar_cfad_grLidar532 = .false., & ok_lidar_cfad_atlid = .false., & - lrttov_cleanUp = .false., & verbose = .false. real(wp),dimension(10) :: driver_time integer, dimension(:),allocatable :: & @@ -522,8 +521,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) Lrttov_column = .true. endif - ! Set flag to deallocate rttov types (only done on final call to simulator) - if (size(cospOUT%isccp_meantb) .eq. stop_idx) lrttov_cleanUp = .true. ! ISCCP column if (associated(cospOUT%isccp_fq) .or. & @@ -1566,7 +1563,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) rttov_rad_clear(:,:) = R_UNDEF ! Run simulator call cpu_time(driver_time(3)) - call cosp_rttov_simulate(rttovIN,cospIN%cfg_rttov(i),Lrttov_cleanUp, & ! Inputs + call cosp_rttov_simulate(rttovIN,cospIN%cfg_rttov(i), & ! Inputs cosp_simulator(nError+1), & ! Error message holder bt_clear=rttov_bt_clear, & ! Clear-sky BT rad_clear=rttov_rad_clear) ! Clear-sky radiance @@ -1589,7 +1586,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) rttov_refl_clear(:,:) = R_UNDEF ! Run simulator call cpu_time(driver_time(3)) - call cosp_rttov_simulate(rttovIN,cospIN%cfg_rttov(i),Lrttov_cleanUp, & ! Inputs + call cosp_rttov_simulate(rttovIN,cospIN%cfg_rttov(i), & ! Inputs cosp_simulator(nError+1), & ! Error message holder bt_total=rttov_bt_total, & ! Brightness Temp Outputs bt_clear=rttov_bt_clear, & diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index bb1b71687f..345cae9ed8 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -302,7 +302,6 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & user_tracegas_input, & CO2_mr,CH4_mr,CO_mr,N2O_mr,SO2_mr, & ! Mixing ratios ipcbnd,ipcreg,npcscores, & ! PC-RTTOV config values -! rttov_nthreads,rttov_ZenAng rttov_nthreads,rttov_ZenAng,rttov_Nlocaltime, & rttov_localtime,rttov_localtime_width @@ -629,6 +628,7 @@ END SUBROUTINE COSP_RTTOV_INIT_S SUBROUTINE DESTROY_RTTOV_CONFIG(rttovConfig) + use mod_cosp_rttov, only: cosp_rttov_deallocate_coefs type(rttov_cfg),intent(inout) :: & rttovConfig @@ -640,24 +640,24 @@ SUBROUTINE DESTROY_RTTOV_CONFIG(rttovConfig) if (allocated(rttovConfig % rttov_localtime)) deallocate(rttovConfig % rttov_localtime) if (allocated(rttovConfig % rttov_localtime_width)) deallocate(rttovConfig % rttov_localtime_width) if (allocated(rttovConfig % swath_mask)) deallocate(rttovConfig % swath_mask) + + call cosp_rttov_deallocate_coefs(rttovConfig % coefs) END SUBROUTINE DESTROY_RTTOV_CONFIG !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_simulate - Call subroutines in mod_cosp_rttov to run RTTOV !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - RECURSIVE SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup,error, & ! Inputs - bt_total,bt_clear, & ! Brightness Temp Outputs - rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs - refl_total,refl_clear, & ! Reflectance Outputs - debug) + RECURSIVE SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,error, & ! Inputs + bt_total,bt_clear, & ! Brightness Temp Outputs + rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs + refl_total,refl_clear, & ! Reflectance Outputs + debug) type(rttov_in),intent(in) :: & rttovIN type(rttov_cfg),intent(inout) :: & rttovConfig - logical,intent(in) :: & - lCleanup ! Flag to determine whether to deallocate RTTOV types character(len=128),intent(inout) :: & error ! Error messages (only populated if error encountered) real(wp),intent(inout),dimension(rttovIN%nPoints,rttovConfig%nchan_out),optional :: & ! Can I do this? I guess so! @@ -676,11 +676,11 @@ RECURSIVE SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup,error, ! Check options to determine if the principal component approach should be run if (rttovConfig % opts % rt_ir % pc % addpc) then - call COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & + call COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig, & bt_clear,rad_clear, & error,verbose) else - call COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & + call COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig, & bt_total,bt_clear, & rad_total,rad_clear,rad_cloudy, & refl_total,refl_clear, & @@ -692,7 +692,7 @@ END SUBROUTINE COSP_RTTOV_SIMULATE !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_reg_rttov_simulate - Call regular subroutines in mod_cosp_rttov to run RTTOV !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & ! Inputs + SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig, & ! Inputs bt_total,bt_clear, & ! Brightness Temp Outputs rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs refl_total,refl_clear, & ! Reflectance Outputs @@ -704,15 +704,12 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, cosp_rttov_setup_emissivity_reflectance, & cosp_rttov_call_direct, & cosp_rttov_save_output, & - cosp_rttov_deallocate_profiles, & - cosp_rttov_deallocate_coefs + cosp_rttov_deallocate_profiles type(rttov_in),intent(in) :: & rttovIN type(rttov_cfg),intent(inout) :: & rttovConfig - logical,intent(in) :: & - lCleanup ! Flag to determine whether to deallocate RTTOV types real(wp),intent(inout),dimension(rttovIN%nPoints,rttovConfig%nchan_out) :: & bt_total, & ! All-sky bt_clear, & ! Clear-sky @@ -858,15 +855,6 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, ! print*,'Time to run "cosp_rttov_call_direct": ', driver_time(5)-driver_time(4) ! print*,'Time to run "cosp_rttov_save_output": ', driver_time(6)-driver_time(5) ! print*,'Time to run "cosp_rttov_deallocate_profiles": ', driver_time(7)-driver_time(6) - - ! Deallocate the coefficient files if directed - if (lCleanup) then - call cpu_time(driver_time(8)) - call cosp_rttov_deallocate_coefs(rttovConfig % coefs) - call cpu_time(driver_time(9)) -! print*,'Time to run "cosp_rttov_deallocate_coefs": ',driver_time(9)-driver_time(8) - endif - ! print*,'Total RTTOV run time: ',driver_time(8)-driver_time(1) END SUBROUTINE COSP_REG_RTTOV_SIMULATE @@ -875,7 +863,7 @@ END SUBROUTINE COSP_REG_RTTOV_SIMULATE !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_pc_rttov_simulate - Call subroutines in mod_cosp_rttov to run RTTOV !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, & ! Inputs + SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig, & ! Inputs bt_clear,rad_clear, & ! Outputs error,verbose) @@ -885,15 +873,12 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, cosp_pc_rttov_setup_emissivity, & cosp_pc_rttov_call_direct, & cosp_pc_rttov_save_output, & - cosp_pc_rttov_deallocate_profiles, & - cosp_rttov_deallocate_coefs + cosp_pc_rttov_deallocate_profiles type(rttov_in),intent(in) :: & rttovIN type(rttov_cfg),intent(inout) :: & rttovConfig - logical,intent(in) :: & - lCleanup ! Flag to determine whether to deallocate RTTOV types real(wp),intent(inout),dimension(rttovIN%nPoints,rttovConfig%nchan_out) :: & ! Can I do this? I guess so! bt_clear, & ! All-sky rad_clear ! All-sky @@ -1017,14 +1002,6 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup, ! print*,'Time to run "cosp_pc_rttov_call_direct": ', driver_time(5)-driver_time(4) ! print*,'Time to run "cosp_pc_rttov_save_output": ', driver_time(6)-driver_time(5) ! print*,'Time to run "cosp_pc_rttov_deallocate_profiles": ', driver_time(7)-driver_time(6) - - ! Deallocate the coefficient files if directed - if (lCleanup) then - call cpu_time(driver_time(8)) -! call cosp_rttov_deallocate_coefs(rttovConfig % coefs) ! JKS this again with PC-RTTOV... - call cpu_time(driver_time(9)) -! print*,'Time to run "cosp_rttov_deallocate_coefs": ',driver_time(9)-driver_time(8) - endif END SUBROUTINE COSP_PC_RTTOV_SIMULATE From 153ee034ac05cd7d6c89a5d07bbb4f4ca3011349 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 16 Jan 2024 15:39:18 -0700 Subject: [PATCH 105/159] Update stub to work with externalized deallocation --- src/simulator/cosp_rttov_interfaceSTUB.F90 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/simulator/cosp_rttov_interfaceSTUB.F90 b/src/simulator/cosp_rttov_interfaceSTUB.F90 index 02bf7dbc88..ce93b34724 100644 --- a/src/simulator/cosp_rttov_interfaceSTUB.F90 +++ b/src/simulator/cosp_rttov_interfaceSTUB.F90 @@ -143,7 +143,7 @@ END SUBROUTINE DESTROY_RTTOV_CONFIG !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_simulate !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup,error, & ! Inputs + SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,error, & ! Inputs bt_total,bt_clear, & ! Brightness Temp Outputs rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs refl_total,refl_clear, & ! Reflectance Outputs @@ -153,8 +153,6 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,lCleanup,error, rttovIN type(rttov_cfg),intent(inout) :: & rttovConfig - logical,intent(in) :: & - lCleanup ! Flag to determine whether to deallocate RTTOV types character(len=128) :: & error ! Error messages (only populated if error encountered) real(wp),intent(inout),dimension(rttovIN%nPoints,rttovConfig%nchan_out),optional :: & From 4d5c4b93ad665554cb9901da0c2d81143a839b99 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Fri, 26 Jan 2024 15:24:29 -0700 Subject: [PATCH 106/159] Derecho/RTTOV corrections --- build/Makefile.rttov | 17 ++++++++++++++--- src/simulator/rttov/cosp_rttov_v13.F90 | 4 ++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/build/Makefile.rttov b/build/Makefile.rttov index 3f93e7e89e..6bafefd813 100644 --- a/build/Makefile.rttov +++ b/build/Makefile.rttov @@ -24,14 +24,25 @@ # RTTOVDIR=/glade/u/home/jonahshaw/w/RTTOV # Derecho version (without HDF5). Note: You need a copy of Makefile.local in the RTTOVDIR directory in a build/ subdirectory -RTTOVDIR=/glade/u/home/jonahshaw/w/RTTOV/alt_build +#RTTOVDIR=/glade/u/home/jonahshaw/w/RTTOV/alt_build -FC=gfortran +#FC=gfortran #FFLAGS= -I$(RTTOVDIR)/mod -I$(RTTOVDIR)/include -fPIC -O3 -fopenmp -ffree-line-length-none +#FFLAGS= -I$(RTTOVDIR)/mod -I$(RTTOVDIR)/include -fPIC -O3 -fopenmp +#LDFLAGS_ARCH=-fopenmp + +# Original Derecho settings +#RTTOVDIR=/glade/u/home/jonahshaw/w/RTTOV/alt_build +#FC=gfortran +#FFLAGS= -I$(RTTOVDIR)/mod -I$(RTTOVDIR)/include -fPIC -O3 -fopenmp +#LDFLAGS_ARCH=-fopenmp + +# Derecho with debug changes (01/23/2024) +RTTOVDIR=/glade/u/home/jonahshaw/w/RTTOV2 +FC=ifort FFLAGS= -I$(RTTOVDIR)/mod -I$(RTTOVDIR)/include -fPIC -O3 -fopenmp LDFLAGS_ARCH=-fopenmp - RTTOV_VERSION=13 EXT_BIN=.exe EXT_OBJ=.o diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index eac59c928d..5a755cfd5f 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -248,7 +248,7 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs, ! Largely from RTTOV documentation. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Handle swathing here. Initial code from Genevieve with minor changes. + ! Handle swathing here. Initial code from Genevieve with implementation changes. if (rttov_Nlocaltime .gt. 0) then ! Iterate over local times do j=1,rttov_Nlocaltime @@ -960,7 +960,7 @@ subroutine cosp_rttov_call_direct(inst_nthreads, & if (verbose) print*,'Calling rttov_parallel_direct' call rttov_parallel_direct( & errorstatus, &! out error flag - inst_chanprof, &! in channel and profile index structure + inst_chanprof, &! in channel and profile index structure inst_opts, &! in options structure inst_profiles, &! in profile array inst_coefs, &! in coefficients structure From 1b58f377f459885ae3ef0bf81d92db6e5d52bc0b Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Fri, 26 Jan 2024 15:26:34 -0700 Subject: [PATCH 107/159] Initial non-RTTOV swathing implementation. Post-COSP in driver. --- driver/run/cosp2_input_rttov_nl.txt | 26 +- driver/src/cosp2_test.F90 | 373 ++++++++++++++++++++++++++-- 2 files changed, 382 insertions(+), 17 deletions(-) diff --git a/driver/run/cosp2_input_rttov_nl.txt b/driver/run/cosp2_input_rttov_nl.txt index 6d95739e52..29e8dab57a 100644 --- a/driver/run/cosp2_input_rttov_nl.txt +++ b/driver/run/cosp2_input_rttov_nl.txt @@ -82,7 +82,7 @@ !---------------------------------------------------------------------------------- !-------------- RTTOV inputs !---------------------------------------------------------------------------------- -rttov_Ninstruments=3, + rttov_Ninstruments=3, rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt','instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt','instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt', ! rttov_Ninstruments=7, ! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt','instrument_nls/cosp2_rttov_inst4.txt','instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt','instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt','instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt', @@ -93,4 +93,28 @@ rttov_Ninstruments=3, ! rttov_Ninstruments=1, ! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt', rttov_verbose=.true. + !---------------------------------------------------------------------------------- + !-------------- Swathing inputs + !---------------------------------------------------------------------------------- + N_SWATHS_ISCCP=2, + SWATH_LOCALTIMES_ISCCP=1,10, + SWATH_WIDTHS_ISCCP=1000,1200, + N_SWATHS_MISR=0, + SWATH_LOCALTIMES_MISR=1,10, + SWATH_WIDTHS_MISR=1000,1200, + N_SWATHS_MODIS=0, + SWATH_LOCALTIMES_MODIS=1,10, + SWATH_WIDTHS_MODIS=1000,1200, + N_SWATHS_CALIPSO=0, + SWATH_LOCALTIMES_CALIPSO=1,10, + SWATH_WIDTHS_CALIPSO=1000,1200, + N_SWATHS_PARASOL=0, + SWATH_LOCALTIMES_PARASOL=1,10, + SWATH_WIDTHS_PARASOL=1000,1200, + N_SWATHS_ClOUDSAT=0, + SWATH_LOCALTIMES_ClOUDSAT=1,10, + SWATH_WIDTHS_ClOUDSAT=1000,1200, + N_SWATHS_ATLID=0, + SWATH_LOCALTIMES_ATLID=1,10, + SWATH_WIDTHS_ATLID=1000,1200, / diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index c51b422566..2a37a5e9c4 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -164,12 +164,42 @@ program cosp2_test rttov_instrument_namelists ! Input of paths to RTTOV instrument namelists character(len=256), allocatable :: & rttov_instrument_namelists_final(:) ! Array of paths to RTTOV instrument namelists + + ! Inputs for orbit swathing + integer :: N_SWATHS_ISCCP = 0 ! Number of ISCCP swaths + integer :: N_SWATHS_MISR = 0 ! Number of MISR swaths + integer :: N_SWATHS_MODIS = 0 ! Number of MODIS swaths + integer :: N_SWATHS_CALIPSO = 0 ! Number of CALIPSO swaths + integer :: N_SWATHS_PARASOL = 0 ! Number of PARASOL swaths + integer :: N_SWATHS_ClOUDSAT = 0 ! Number of CLOUDSAT swaths + integer :: N_SWATHS_ATLID = 0 ! Number of ATLID swaths + real(wp),dimension(10) :: & ! Arbitrary limit of 10 swaths seems reasonable. + SWATH_LOCALTIMES_ISCCP, & ! Local time of ISCCP satellite overpasses (hrs GMT) + SWATH_LOCALTIMES_MISR, & ! Local time of MISR satellite overpasses (hrs GMT) + SWATH_LOCALTIMES_MODIS, & ! Local time of MODIS satellite overpasses (hrs GMT) + SWATH_LOCALTIMES_CALIPSO, & ! Local time of CALIPSO satellite overpasses (hrs GMT) + SWATH_LOCALTIMES_PARASOL, & ! Local time of PARASOL satellite overpasses (hrs GMT) + SWATH_LOCALTIMES_ClOUDSAT, & ! Local time of CLOUDSAT satellite overpasses (hrs GMT) + SWATH_LOCALTIMES_ATLID, & ! Local time of ATLID satellite overpasses (hrs GMT) + SWATH_WIDTHS_ISCCP, & ! Width in km of ISCCP satellite overpasses + SWATH_WIDTHS_MISR, & ! Width in km of MISR satellite overpasses + SWATH_WIDTHS_MODIS, & ! Width in km of MODIS satellite overpasses + SWATH_WIDTHS_CALIPSO, & ! Width in km of CALIPSO satellite overpasses + SWATH_WIDTHS_PARASOL, & ! Width in km of PARASOL satellite overpasses + SWATH_WIDTHS_ClOUDSAT, & ! Width in km of CLOUDSAT satellite overpasses + SWATH_WIDTHS_ATLID ! Width in km of ATLID satellite overpasses namelist/COSP_INPUT/overlap, isccp_topheight, isccp_topheight_direction, npoints, & npoints_it, ncolumns, nlevels, use_vgrid, Nlvgrid, csat_vgrid, dinput, finput, & foutput, cloudsat_radar_freq, surface_radar, cloudsat_use_gas_abs,cloudsat_do_ray,& cloudsat_k2, cloudsat_micro_scheme, lidar_ice_type, use_precipitation_fluxes, & - rttov_Ninstruments, rttov_instrument_namelists, rttov_verbose + rttov_Ninstruments, rttov_instrument_namelists, rttov_verbose, & + N_SWATHS_ISCCP, SWATH_LOCALTIMES_ISCCP, SWATH_WIDTHS_ISCCP, N_SWATHS_MISR, & + SWATH_LOCALTIMES_MISR, SWATH_WIDTHS_MISR, N_SWATHS_MODIS, SWATH_LOCALTIMES_MODIS, & + SWATH_WIDTHS_MODIS, N_SWATHS_CALIPSO, SWATH_LOCALTIMES_CALIPSO, & + SWATH_WIDTHS_CALIPSO, N_SWATHS_PARASOL, SWATH_LOCALTIMES_PARASOL, & + SWATH_WIDTHS_PARASOL, N_SWATHS_ClOUDSAT, SWATH_LOCALTIMES_ClOUDSAT, & + SWATH_WIDTHS_ClOUDSAT, N_SWATHS_ATLID, SWATH_LOCALTIMES_ATLID, SWATH_WIDTHS_ATLID ! Output namelist logical :: Lcfaddbze94,Ldbze94,Latb532,LcfadLidarsr532,Lclcalipso,Lclhcalipso, & @@ -285,6 +315,14 @@ program cosp2_test gamma_3 = (/-1., -1., 2.0, 2.0, -1., -1., 2.0, 2.0, 2.0/),& gamma_4 = (/-1., -1., 6.0, 6.0, -1., -1., 6.0, 6.0, 6.0/) + ! Local variables for orbit swathing + real(wp),dimension(:),allocatable :: & + cosp_localtime, & + cosp_localtime_width + + logical,dimension(:),allocatable :: & + swath_mask_out ! Mask of reals over all local times + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% call cpu_time(driver_time(1)) @@ -622,20 +660,6 @@ program cosp2_test elsewhere (mr_ccice(start_idx:end_idx,Nlevels:1:-1) .gt. 0._wp) cospstateIN%DeffIce(:,:) = 2._wp * 1.0e6 * Reff(start_idx:end_idx,Nlevels:1:-1,I_CVCICE) end where - -! print*,'Reff(9,Nlevels:1:-1,I_CVCLIQ): ',Reff(9,Nlevels:1:-1,I_CVCLIQ) -! print*,'Reff(9,Nlevels:1:-1,I_LSCLIQ): ',Reff(9,Nlevels:1:-1,I_LSCLIQ) -! print*,'mr_lsliq(9,Nlevels:1:-1): ',mr_lsliq(9,Nlevels:1:-1) -! print*,'mr_ccliq(9,Nlevels:1:-1): ',mr_ccliq(9,Nlevels:1:-1) - -! print*,'cospstateIN%DeffLiq(9,:): ',cospstateIN%DeffLiq(9,:) - -! print*,'Reff(2:4,Nlevels:1:-1,I_CVCICE): ',Reff(2:4,Nlevels:1:-1,I_CVCICE) -! print*,'Reff(2:4,Nlevels:1:-1,I_LSCICE): ',Reff(2:4,Nlevels:1:-1,I_LSCICE) -! print*,'mr_lsice(2:4,Nlevels:1:-1): ',mr_lsice(2:4,Nlevels:1:-1) -! print*,'mr_ccice(2:4,Nlevels:1:-1): ',mr_ccice(2:4,Nlevels:1:-1) - -! print*,'cospstateIN%DeffIce(2:4,:): ',cospstateIN%DeffIce(2:4,:) ! RTTOV doesn't consider precip flux for longwave, but it could be used when simulating MW instruments. ! Graupel goes in the snow category, arbitrarily @@ -673,6 +697,186 @@ program cosp2_test call cpu_time(driver_time(7)) end do + + ! ###################################################################################### + ! Set un-observed scenes to fill value to implement satellite orbit swathing. + ! ###################################################################################### + + !------------------ ISCCP ------------------! + if (N_SWATHS_ISCCP .gt. 0) then + allocate(swath_mask_out(Npoints)) + + ! print*,'N_SWATHS_ISCCP: ',N_SWATHS_ISCCP + ! print*,'SWATH_LOCALTIMES_ISCCP: ',SWATH_LOCALTIMES_ISCCP + ! print*,'SWATH_WIDTHS_ISCCP: ',SWATH_WIDTHS_ISCCP + + call compute_orbitmasks(Npoints,N_SWATHS_ISCCP,SWATH_LOCALTIMES_ISCCP,SWATH_WIDTHS_ISCCP, & + cospstateIN%lat,cospstateIN%lon,cospstateIN%rttov_time(:,1), & + cospstateIN%rttov_time(:,2),swath_mask_out) + ! Mask out areas that are not observed. Need different statements for outputs of different dimensionality because apparently fortran is dumb at broadcasting :( + ! 1-D + where ( swath_mask_out ) + cospOUT%isccp_totalcldarea(1:Npoints) = R_UNDEF + cospOUT%isccp_meanptop(1:Npoints) = R_UNDEF + cospOUT%isccp_meantaucld(1:Npoints) = R_UNDEF + cospOUT%isccp_meanalbedocld(1:Npoints) = R_UNDEF + cospOUT%isccp_meantb(1:Npoints) = R_UNDEF + cospOUT%isccp_meantbclr(1:Npoints) = R_UNDEF + end where + ! 2-D + call mask_outputs_2d(Npoints,Ncolumns,swath_mask_out,cospOUT%isccp_boxtau) + call mask_outputs_2d(Npoints,Ncolumns,swath_mask_out,cospOUT%isccp_boxptop) + ! 3D + call mask_outputs_3d(Npoints,numISCCPTauBins,numISCCPPresBins,swath_mask_out,cospOUT%isccp_fq) + deallocate(swath_mask_out) + end if + + !------------------ MISR ------------------! + if (N_SWATHS_MISR .gt. 0) then + allocate(swath_mask_out(Npoints)) + + call compute_orbitmasks(Npoints,N_SWATHS_MISR,SWATH_LOCALTIMES_MISR,SWATH_WIDTHS_MISR, & + cospstateIN%lat,cospstateIN%lon,cospstateIN%rttov_time(:,1), & + cospstateIN%rttov_time(:,2),swath_mask_out) + ! Mask out areas that are not observed. Need different statements for outputs of different dimensionality because apparently fortran is dumb at broadcasting :( + ! 1-D + where ( swath_mask_out ) + cospOUT%misr_meanztop(1:Npoints) = R_UNDEF + cospOUT%misr_cldarea(1:Npoints) = R_UNDEF + end where + ! 2-D + call mask_outputs_2d(Npoints,numMISRHgtBins,swath_mask_out,cospOUT%misr_dist_model_layertops) + ! 3D + call mask_outputs_3d(Npoints,numMISRTauBins,numISCCPPresBins,swath_mask_out,cospOUT%misr_fq) + deallocate(swath_mask_out) + end if + + !------------------ MODIS ------------------! + if (N_SWATHS_MODIS .gt. 0) then + + call compute_orbitmasks(Npoints,N_SWATHS_MODIS,SWATH_LOCALTIMES_MODIS,SWATH_WIDTHS_MODIS, & + cospstateIN%lat,cospstateIN%lon,cospstateIN%rttov_time(:,1), & + cospstateIN%rttov_time(:,2),swath_mask_out) + ! Mask out areas that are not observed. Need different statements for outputs of different dimensionality because apparently fortran is dumb at broadcasting :( + ! 1-D + where ( swath_mask_out ) + cospOUT%modis_Cloud_Fraction_Total_Mean(1:Npoints) = R_UNDEF + cospOUT%modis_Cloud_Fraction_Water_Mean(1:Npoints) = R_UNDEF + cospOUT%modis_Cloud_Fraction_Ice_Mean(1:Npoints) = R_UNDEF + cospOUT%modis_Cloud_Fraction_High_Mean(1:Npoints) = R_UNDEF + cospOUT%modis_Cloud_Fraction_Mid_Mean(1:Npoints) = R_UNDEF + cospOUT%modis_Cloud_Fraction_Low_Mean(1:Npoints) = R_UNDEF + cospOUT%modis_Optical_Thickness_Total_Mean(1:Npoints) = R_UNDEF + cospOUT%modis_Optical_Thickness_Water_Mean(1:Npoints) = R_UNDEF + cospOUT%modis_Optical_Thickness_Ice_Mean(1:Npoints) = R_UNDEF + cospOUT%modis_Optical_Thickness_Total_LogMean(1:Npoints) = R_UNDEF + cospOUT%modis_Optical_Thickness_Water_LogMean(1:Npoints) = R_UNDEF + cospOUT%modis_Optical_Thickness_Ice_LogMean(1:Npoints) = R_UNDEF + cospOUT%modis_Cloud_Particle_Size_Water_Mean(1:Npoints) = R_UNDEF + cospOUT%modis_Cloud_Particle_Size_Ice_Mean(1:Npoints) = R_UNDEF + cospOUT%modis_Cloud_Top_Pressure_Total_Mean(1:Npoints) = R_UNDEF + cospOUT%modis_Liquid_Water_Path_Mean(1:Npoints) = R_UNDEF + cospOUT%modis_Ice_Water_Path_Mean(1:Npoints) = R_UNDEF + end where + ! 3D + call mask_outputs_3d(Npoints,numModisTauBins,numMODISPresBins,swath_mask_out,cospOUT%modis_Optical_Thickness_vs_Cloud_Top_Pressure) + call mask_outputs_3d(Npoints,numMODISReffIceBins,numMODISPresBins,swath_mask_out,cospOUT%modis_Optical_Thickness_vs_ReffICE) + call mask_outputs_3d(Npoints,numMODISReffLiqBins,numMODISPresBins,swath_mask_out,cospOUT%modis_Optical_Thickness_vs_ReffLIQ) + deallocate(cosp_localtime_width,cosp_localtime,swath_mask_out) + end if + + !------------------ CALIPSO ------------------! + if (N_SWATHS_CALIPSO .gt. 0) then + + call compute_orbitmasks(Npoints,N_SWATHS_CALIPSO,SWATH_LOCALTIMES_CALIPSO,SWATH_WIDTHS_CALIPSO, & + cospstateIN%lat,cospstateIN%lon,cospstateIN%rttov_time(:,1), & + cospstateIN%rttov_time(:,2),swath_mask_out) + ! Mask out areas that are not observed. Need different statements for outputs of different dimensionality because apparently fortran is dumb at broadcasting :( + ! 1-D + where ( swath_mask_out ) + cospOUT%calipso_cldthinemis(1:Npoints) = R_UNDEF + end where + ! 2-D + call mask_outputs_2d(Npoints,Nlevels,swath_mask_out,cospOUT%calipso_beta_mol) + call mask_outputs_2d(Npoints,Nlevels,swath_mask_out,cospOUT%calipso_temp_tot) + call mask_outputs_2d(Npoints,Nlvgrid,swath_mask_out,cospOUT%calipso_lidarcld) + call mask_outputs_2d(Npoints,LIDAR_NCAT,swath_mask_out,cospOUT%calipso_cldlayer) + call mask_outputs_2d(Npoints,LIDAR_NTYPE,swath_mask_out,cospOUT%calipso_cldtype) + call mask_outputs_2d(Npoints,LIDAR_NTYPE,swath_mask_out,cospOUT%calipso_cldtypetemp) + call mask_outputs_2d(Npoints,2,swath_mask_out,cospOUT%calipso_cldtypemeanz) + call mask_outputs_2d(Npoints,3,swath_mask_out,cospOUT%calipso_cldtypemeanzse) + ! 3D + call mask_outputs_3d(Npoints,Ncolumns,Nlevels,swath_mask_out,cospOUT%calipso_betaperp_tot) + call mask_outputs_3d(Npoints,Ncolumns,Nlevels,swath_mask_out,cospOUT%calipso_beta_tot) + call mask_outputs_3d(Npoints,Ncolumns,Nlevels,swath_mask_out,cospOUT%calipso_tau_tot) + call mask_outputs_3d(Npoints,Nlvgrid,6,swath_mask_out,cospOUT%calipso_lidarcldphase) + call mask_outputs_3d(Npoints,Nlvgrid,LIDAR_NTYPE+1,swath_mask_out,cospOUT%calipso_lidarcldtype) + call mask_outputs_3d(Npoints,LIDAR_NCAT,6,swath_mask_out,cospOUT%calipso_cldlayerphase) + call mask_outputs_3d(Npoints,LIDAR_NTEMP,5,swath_mask_out,cospOUT%calipso_lidarcldtmp) + call mask_outputs_3d(Npoints,SR_BINS,Nlvgrid,swath_mask_out,cospOUT%calipso_cfad_sr) + deallocate(cosp_localtime_width,cosp_localtime,swath_mask_out) + end if + + !------------------ PARASOL ------------------! + if (N_SWATHS_PARASOL .gt. 0) then + + call compute_orbitmasks(Npoints,N_SWATHS_PARASOL,SWATH_LOCALTIMES_PARASOL,SWATH_WIDTHS_PARASOL, & + cospstateIN%lat,cospstateIN%lon,cospstateIN%rttov_time(:,1), & + cospstateIN%rttov_time(:,2),swath_mask_out) + ! Mask out areas that are not observed. Need different statements for outputs of different dimensionality because apparently fortran is dumb at broadcasting :( + ! 2-D + call mask_outputs_2d(Npoints,PARASOL_NREFL,swath_mask_out,cospOUT%parasolGrid_refl) + ! 3D + call mask_outputs_3d(Npoints,Ncolumns,PARASOL_NREFL,swath_mask_out,cospOUT%parasolPix_refl) + deallocate(cosp_localtime_width,cosp_localtime,swath_mask_out) + end if + + !------------------ CLOUDSAT ------------------! + if (N_SWATHS_ClOUDSAT .gt. 0) then + + call compute_orbitmasks(Npoints,N_SWATHS_ClOUDSAT,SWATH_LOCALTIMES_ClOUDSAT,SWATH_WIDTHS_ClOUDSAT, & + cospstateIN%lat,cospstateIN%lon,cospstateIN%rttov_time(:,1), & + cospstateIN%rttov_time(:,2),swath_mask_out) + ! Mask out areas that are not observed. Need different statements for outputs of different dimensionality because apparently fortran is dumb at broadcasting :( + ! 1-D + where ( swath_mask_out ) + cospOUT%cloudsat_tcc(1:Npoints) = R_UNDEF + cospOUT%cloudsat_tcc2(1:Npoints) = R_UNDEF + cospOUT%radar_lidar_tcc(1:Npoints) = R_UNDEF + cospOUT%cloudsat_pia(1:Npoints) = R_UNDEF + end where + ! 2-D + call mask_outputs_2d(Npoints,Nlevels,swath_mask_out,cospOUT%lidar_only_freq_cloud) + call mask_outputs_2d(Npoints,cloudsat_DBZE_BINS,swath_mask_out,cospOUT%cloudsat_precip_cover) + ! 3D + call mask_outputs_3d(Npoints,Ncolumns,Nlevels,swath_mask_out,cospOUT%cloudsat_Ze_tot) + call mask_outputs_3d(Npoints,cloudsat_DBZE_BINS,Nlevels,swath_mask_out,cospOUT%cloudsat_cfad_ze) + + !---------- Joint CloudSat+MODIS simulators outputs ----------! + ! 2-D + call mask_outputs_2d(Npoints,WR_NREGIME,swath_mask_out,cospOUT%wr_occfreq_ntotal) + ! 4-D + call mask_outputs_4d(Npoints,CFODD_NDBZE,CFODD_NICOD,CFODD_NCLASS,swath_mask_out,cospOUT%cfodd_ntotal) + deallocate(cosp_localtime_width,cosp_localtime,swath_mask_out) + end if + + !------------------ ATLID Lidar ------------------! + if (N_SWATHS_ATLID .gt. 0) then + + call compute_orbitmasks(Npoints,N_SWATHS_ATLID,SWATH_LOCALTIMES_ATLID,SWATH_WIDTHS_ATLID, & + cospstateIN%lat,cospstateIN%lon,cospstateIN%rttov_time(:,1), & + cospstateIN%rttov_time(:,2),swath_mask_out) + ! Mask out areas that are not observed. Need different statements for outputs of different dimensionality because apparently fortran is dumb at broadcasting :( + ! The "atlid_srbval" variable doesn't have a spatial dimension so it is excluded here. + ! 2-D + call mask_outputs_2d(Npoints,Nlvgrid,swath_mask_out,cospOUT%atlid_lidarcld) + call mask_outputs_2d(Npoints,LIDAR_NCAT,swath_mask_out,cospOUT%atlid_cldlayer) + call mask_outputs_2d(Npoints,Nlevels,swath_mask_out,cospOUT%atlid_beta_mol) + ! 3D + call mask_outputs_3d(Npoints,Ncolumns,Nlevels,swath_mask_out,cospOUT%atlid_beta_tot) + call mask_outputs_3d(Npoints,SR_BINS,Nlvgrid,swath_mask_out,cospOUT%atlid_cfad_sr) + deallocate(cosp_localtime_width,cosp_localtime,swath_mask_out) + end if print*,'Time to read in data: ',driver_time(2)-driver_time(1) print*,'Time to initialize: ',driver_time(3)-driver_time(2) @@ -1102,7 +1306,144 @@ subroutine subsample_and_optics(nPoints, nLevels, nColumns, nHydro, overlap, use Np,Reff) endif end subroutine subsample_and_optics - + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE compute_orbitmasks + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine compute_orbitmasks(Npoints,Nlocaltimes,localtimes,localtime_widths, & + lat,lon,hour,minute,swath_mask_out) + + ! Inputs + integer,intent(in) :: & + Npoints, & + Nlocaltimes + + real(wp),dimension(Nlocaltimes),intent(in) :: & + localtimes, & + localtime_widths + + real(wp),dimension(Npoints),intent(in) :: & + lat, & + lon, & + hour, & + minute + + ! Output + logical,dimension(Npoints),intent(out) :: & + swath_mask_out ! Mask of reals over all gridcells + + ! Local variables + integer :: i ! iterators + + real(wp),parameter :: & + pi = 4.D0*DATAN(1.D0), & ! yum + radius = 6371.0 ! Earth's radius in km (mean volumetric) + + real(wp),dimension(Npoints,Nlocaltimes) :: & + sat_lon, & ! Central longitude of the instrument. + dlon, & ! distance to satellite longitude in degrees + dx ! distance to satellite longitude in km? + + logical,dimension(Npoints,Nlocaltimes) :: & + swath_mask_all ! Mask of logicals over all local times, gridcells + + ! Iterate over local times + swath_mask_all(:,:) = 0 + do i=1,Nlocaltimes + ! Calculate the central longitude for each gridcell and orbit + sat_lon(:,i) = 15.0 * (localtimes(i) - (hour + minute / 60)) + ! Calculate distance (in degrees) from each grid cell to the satellite central long + dlon(:,i) = mod((lon - sat_lon(:,i) + 180.0), 360.0) - 180.0 + ! calculate distance to satellite in km. Remember to convert to radians for cos/sine calls + dx(:,i) = dlon(:,i) * (pi/180.0) * COS(lat * pi / 180) * radius + ! Determine if a gridcell falls in the swath width + where (abs(dx(:,i))<(localtime_widths(i)*0.5)) + swath_mask_all(:,i) = .true. + end where + end do + + ! Mask is true where values should be masked to R_UNDEF + swath_mask_out = ALL( swath_mask_all(:,:) .eq. .false.,2) ! Compute mask by collapsing the localtimes dimension ! ANY(swath_mask_all,dim=1) + + end subroutine compute_orbitmasks + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE mask_outputs_2d - Mask out a 2d array + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine mask_outputs_2d(dim1,dim2,mask,data_array) + ! Inputs + integer,intent(in) :: & + dim1, & + dim2 + logical,dimension(dim1),intent(in) :: & + mask + real(wp),dimension(dim1,dim2),intent(inout) :: & + data_array + + ! Local variables + integer :: i ! iterator + + do i=1,dim2 + where ( mask ) data_array(1:dim1,i) = R_UNDEF + end do + + end subroutine mask_outputs_2d + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE mask_outputs_3d - Mask out a 3d array + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine mask_outputs_3d(dim1,dim2,dim3,mask,data_array) + + ! Inputs + integer,intent(in) :: & + dim1, & + dim2, & + dim3 + logical,dimension(dim1),intent(in) :: & + mask + real(wp),dimension(dim1,dim2,dim3),intent(inout) :: & + data_array + + ! Local variables + integer :: i,j ! iterator + + do i=1,dim2 + do j=1,dim3 + where ( mask ) data_array(1:dim1,i,j) = R_UNDEF + end do + end do + + end subroutine mask_outputs_3d + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE mask_outputs_4d - Mask out a 3d array + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine mask_outputs_4d(dim1,dim2,dim3,dim4,mask,data_array) + + ! Inputs + integer,intent(in) :: & + dim1, & + dim2, & + dim3, & + dim4 + logical,dimension(dim1),intent(in) :: & + mask + real(wp),dimension(dim1,dim2,dim3,dim4),intent(inout) :: & + data_array + + ! Local variables + integer :: i,j,k ! iterator + + do i=1,dim2 + do j=1,dim3 + do k=1,dim4 + where ( mask ) data_array(1:dim1,i,j,k) = R_UNDEF + end do + end do + end do + + end subroutine mask_outputs_4d + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE construct_cospIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From e9d6fd41d172bb4e1e489e60a03abcecfc3ae34e Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 31 Jan 2024 11:39:40 -0700 Subject: [PATCH 108/159] Inital code with ISCCP swathing working, need to extend to other simulators --- driver/run/cosp2_input_rttov_nl.txt | 4 +- driver/src/cosp2_test.F90 | 296 +------ src/cosp.F90 | 882 ++++++++++++++++++--- src/simulator/cosp_rttov_interface_v13.F90 | 10 +- 4 files changed, 797 insertions(+), 395 deletions(-) diff --git a/driver/run/cosp2_input_rttov_nl.txt b/driver/run/cosp2_input_rttov_nl.txt index 29e8dab57a..2c1c65f518 100644 --- a/driver/run/cosp2_input_rttov_nl.txt +++ b/driver/run/cosp2_input_rttov_nl.txt @@ -97,8 +97,8 @@ !-------------- Swathing inputs !---------------------------------------------------------------------------------- N_SWATHS_ISCCP=2, - SWATH_LOCALTIMES_ISCCP=1,10, - SWATH_WIDTHS_ISCCP=1000,1200, + SWATH_LOCALTIMES_ISCCP=6,18, + SWATH_WIDTHS_ISCCP=20000,20000, N_SWATHS_MISR=0, SWATH_LOCALTIMES_MISR=1,10, SWATH_WIDTHS_MISR=1000,1200, diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 2a37a5e9c4..bf527ad206 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -59,7 +59,7 @@ program cosp2_test quickbeam_optics_init,gases use quickbeam, only: radar_cfg use mod_cosp, only: cosp_init,cosp_optical_inputs,cosp_column_inputs, & - cosp_outputs,cosp_cleanUp,cosp_simulator + cosp_outputs,swath_inputs,cosp_cleanUp,cosp_simulator USE mod_rng, ONLY: rng_state, init_rng USE mod_scops, ONLY: scops USE mod_prec_scops, ONLY: prec_scops @@ -173,7 +173,7 @@ program cosp2_test integer :: N_SWATHS_PARASOL = 0 ! Number of PARASOL swaths integer :: N_SWATHS_ClOUDSAT = 0 ! Number of CLOUDSAT swaths integer :: N_SWATHS_ATLID = 0 ! Number of ATLID swaths - real(wp),dimension(10) :: & ! Arbitrary limit of 10 swaths seems reasonable. + real(wp),dimension(10),target :: & ! Arbitrary limit of 10 swaths seems reasonable. SWATH_LOCALTIMES_ISCCP, & ! Local time of ISCCP satellite overpasses (hrs GMT) SWATH_LOCALTIMES_MISR, & ! Local time of MISR satellite overpasses (hrs GMT) SWATH_LOCALTIMES_MODIS, & ! Local time of MODIS satellite overpasses (hrs GMT) @@ -321,7 +321,11 @@ program cosp2_test cosp_localtime_width logical,dimension(:),allocatable :: & - swath_mask_out ! Mask of reals over all local times + swath_mask_out ! Mask of reals over all local times + + ! Swathing DDT array + type(swath_inputs),dimension(7) :: & + cospswathsIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -349,6 +353,30 @@ program cosp2_test ! Shift the namelists read in into a shorter array for cosp_init: allocate(rttov_instrument_namelists_final(rttov_Ninstruments)) rttov_instrument_namelists_final(:) = rttov_instrument_namelists(1:rttov_Ninstruments) + + ! Read orbital swathing inputs into structure: + ! Indexing order is ISCCP, MISR, CALIPSO, ATLID, PARASOL, CLOUDSAT, MODIS + cospswathsIN(1) % N_inst_swaths = N_SWATHS_ISCCP + cospswathsIN(1) % inst_localtimes => SWATH_LOCALTIMES_ISCCP(1:N_SWATHS_ISCCP) + cospswathsIN(1) % inst_localtime_widths => SWATH_WIDTHS_ISCCP(1:N_SWATHS_ISCCP) + cospswathsIN(2) % N_inst_swaths = N_SWATHS_MISR + cospswathsIN(2) % inst_localtimes => SWATH_LOCALTIMES_MISR(1:N_SWATHS_MISR) + cospswathsIN(2) % inst_localtime_widths => SWATH_WIDTHS_MISR(1:N_SWATHS_MISR) + cospswathsIN(3) % N_inst_swaths = N_SWATHS_CALIPSO + cospswathsIN(3) % inst_localtimes => SWATH_LOCALTIMES_CALIPSO(1:N_SWATHS_CALIPSO) + cospswathsIN(3) % inst_localtime_widths => SWATH_WIDTHS_CALIPSO(1:N_SWATHS_CALIPSO) + cospswathsIN(4) % N_inst_swaths = N_SWATHS_ATLID + cospswathsIN(4) % inst_localtimes => SWATH_LOCALTIMES_ATLID(1:N_SWATHS_ATLID) + cospswathsIN(4) % inst_localtime_widths => SWATH_WIDTHS_ATLID(1:N_SWATHS_ATLID) + cospswathsIN(5) % N_inst_swaths = N_SWATHS_PARASOL + cospswathsIN(5) % inst_localtimes => SWATH_LOCALTIMES_PARASOL(1:N_SWATHS_PARASOL) + cospswathsIN(5) % inst_localtime_widths => SWATH_WIDTHS_PARASOL(1:N_SWATHS_PARASOL) + cospswathsIN(6) % N_inst_swaths = N_SWATHS_CLOUDSAT + cospswathsIN(6) % inst_localtimes => SWATH_LOCALTIMES_CLOUDSAT(1:N_SWATHS_CLOUDSAT) + cospswathsIN(6) % inst_localtime_widths => SWATH_WIDTHS_CLOUDSAT(1:N_SWATHS_CLOUDSAT) + cospswathsIN(7) % N_inst_swaths = N_SWATHS_MODIS + cospswathsIN(7) % inst_localtimes => SWATH_LOCALTIMES_MODIS(1:N_SWATHS_MODIS) + cospswathsIN(7) % inst_localtime_widths => SWATH_WIDTHS_MODIS(1:N_SWATHS_MODIS) !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Read in sample input data. @@ -548,6 +576,7 @@ program cosp2_test cospIN%emsfc_lw = emsfc_lw cospIN%rcfg_cloudsat = rcfg_cloudsat cospIN%cfg_rttov => rttov_configs ! JKS - Not sure why the cloudsat isn't a pointer. The config files for RTTOV are large and I don't want them duplicated in memory + cospIN%cospswathsIN = cospswathsIN ! Swathing information for each non-RTTOV simulator. cospstateIN%hgt_matrix = zlev(start_idx:end_idx,Nlevels:1:-1) ! km cospstateIN%sunlit = sunlit(start_idx:end_idx) ! 0-1 @@ -698,185 +727,6 @@ program cosp2_test call cpu_time(driver_time(7)) end do - ! ###################################################################################### - ! Set un-observed scenes to fill value to implement satellite orbit swathing. - ! ###################################################################################### - - !------------------ ISCCP ------------------! - if (N_SWATHS_ISCCP .gt. 0) then - allocate(swath_mask_out(Npoints)) - - ! print*,'N_SWATHS_ISCCP: ',N_SWATHS_ISCCP - ! print*,'SWATH_LOCALTIMES_ISCCP: ',SWATH_LOCALTIMES_ISCCP - ! print*,'SWATH_WIDTHS_ISCCP: ',SWATH_WIDTHS_ISCCP - - call compute_orbitmasks(Npoints,N_SWATHS_ISCCP,SWATH_LOCALTIMES_ISCCP,SWATH_WIDTHS_ISCCP, & - cospstateIN%lat,cospstateIN%lon,cospstateIN%rttov_time(:,1), & - cospstateIN%rttov_time(:,2),swath_mask_out) - ! Mask out areas that are not observed. Need different statements for outputs of different dimensionality because apparently fortran is dumb at broadcasting :( - ! 1-D - where ( swath_mask_out ) - cospOUT%isccp_totalcldarea(1:Npoints) = R_UNDEF - cospOUT%isccp_meanptop(1:Npoints) = R_UNDEF - cospOUT%isccp_meantaucld(1:Npoints) = R_UNDEF - cospOUT%isccp_meanalbedocld(1:Npoints) = R_UNDEF - cospOUT%isccp_meantb(1:Npoints) = R_UNDEF - cospOUT%isccp_meantbclr(1:Npoints) = R_UNDEF - end where - ! 2-D - call mask_outputs_2d(Npoints,Ncolumns,swath_mask_out,cospOUT%isccp_boxtau) - call mask_outputs_2d(Npoints,Ncolumns,swath_mask_out,cospOUT%isccp_boxptop) - ! 3D - call mask_outputs_3d(Npoints,numISCCPTauBins,numISCCPPresBins,swath_mask_out,cospOUT%isccp_fq) - deallocate(swath_mask_out) - end if - - !------------------ MISR ------------------! - if (N_SWATHS_MISR .gt. 0) then - allocate(swath_mask_out(Npoints)) - - call compute_orbitmasks(Npoints,N_SWATHS_MISR,SWATH_LOCALTIMES_MISR,SWATH_WIDTHS_MISR, & - cospstateIN%lat,cospstateIN%lon,cospstateIN%rttov_time(:,1), & - cospstateIN%rttov_time(:,2),swath_mask_out) - ! Mask out areas that are not observed. Need different statements for outputs of different dimensionality because apparently fortran is dumb at broadcasting :( - ! 1-D - where ( swath_mask_out ) - cospOUT%misr_meanztop(1:Npoints) = R_UNDEF - cospOUT%misr_cldarea(1:Npoints) = R_UNDEF - end where - ! 2-D - call mask_outputs_2d(Npoints,numMISRHgtBins,swath_mask_out,cospOUT%misr_dist_model_layertops) - ! 3D - call mask_outputs_3d(Npoints,numMISRTauBins,numISCCPPresBins,swath_mask_out,cospOUT%misr_fq) - deallocate(swath_mask_out) - end if - - !------------------ MODIS ------------------! - if (N_SWATHS_MODIS .gt. 0) then - - call compute_orbitmasks(Npoints,N_SWATHS_MODIS,SWATH_LOCALTIMES_MODIS,SWATH_WIDTHS_MODIS, & - cospstateIN%lat,cospstateIN%lon,cospstateIN%rttov_time(:,1), & - cospstateIN%rttov_time(:,2),swath_mask_out) - ! Mask out areas that are not observed. Need different statements for outputs of different dimensionality because apparently fortran is dumb at broadcasting :( - ! 1-D - where ( swath_mask_out ) - cospOUT%modis_Cloud_Fraction_Total_Mean(1:Npoints) = R_UNDEF - cospOUT%modis_Cloud_Fraction_Water_Mean(1:Npoints) = R_UNDEF - cospOUT%modis_Cloud_Fraction_Ice_Mean(1:Npoints) = R_UNDEF - cospOUT%modis_Cloud_Fraction_High_Mean(1:Npoints) = R_UNDEF - cospOUT%modis_Cloud_Fraction_Mid_Mean(1:Npoints) = R_UNDEF - cospOUT%modis_Cloud_Fraction_Low_Mean(1:Npoints) = R_UNDEF - cospOUT%modis_Optical_Thickness_Total_Mean(1:Npoints) = R_UNDEF - cospOUT%modis_Optical_Thickness_Water_Mean(1:Npoints) = R_UNDEF - cospOUT%modis_Optical_Thickness_Ice_Mean(1:Npoints) = R_UNDEF - cospOUT%modis_Optical_Thickness_Total_LogMean(1:Npoints) = R_UNDEF - cospOUT%modis_Optical_Thickness_Water_LogMean(1:Npoints) = R_UNDEF - cospOUT%modis_Optical_Thickness_Ice_LogMean(1:Npoints) = R_UNDEF - cospOUT%modis_Cloud_Particle_Size_Water_Mean(1:Npoints) = R_UNDEF - cospOUT%modis_Cloud_Particle_Size_Ice_Mean(1:Npoints) = R_UNDEF - cospOUT%modis_Cloud_Top_Pressure_Total_Mean(1:Npoints) = R_UNDEF - cospOUT%modis_Liquid_Water_Path_Mean(1:Npoints) = R_UNDEF - cospOUT%modis_Ice_Water_Path_Mean(1:Npoints) = R_UNDEF - end where - ! 3D - call mask_outputs_3d(Npoints,numModisTauBins,numMODISPresBins,swath_mask_out,cospOUT%modis_Optical_Thickness_vs_Cloud_Top_Pressure) - call mask_outputs_3d(Npoints,numMODISReffIceBins,numMODISPresBins,swath_mask_out,cospOUT%modis_Optical_Thickness_vs_ReffICE) - call mask_outputs_3d(Npoints,numMODISReffLiqBins,numMODISPresBins,swath_mask_out,cospOUT%modis_Optical_Thickness_vs_ReffLIQ) - deallocate(cosp_localtime_width,cosp_localtime,swath_mask_out) - end if - - !------------------ CALIPSO ------------------! - if (N_SWATHS_CALIPSO .gt. 0) then - - call compute_orbitmasks(Npoints,N_SWATHS_CALIPSO,SWATH_LOCALTIMES_CALIPSO,SWATH_WIDTHS_CALIPSO, & - cospstateIN%lat,cospstateIN%lon,cospstateIN%rttov_time(:,1), & - cospstateIN%rttov_time(:,2),swath_mask_out) - ! Mask out areas that are not observed. Need different statements for outputs of different dimensionality because apparently fortran is dumb at broadcasting :( - ! 1-D - where ( swath_mask_out ) - cospOUT%calipso_cldthinemis(1:Npoints) = R_UNDEF - end where - ! 2-D - call mask_outputs_2d(Npoints,Nlevels,swath_mask_out,cospOUT%calipso_beta_mol) - call mask_outputs_2d(Npoints,Nlevels,swath_mask_out,cospOUT%calipso_temp_tot) - call mask_outputs_2d(Npoints,Nlvgrid,swath_mask_out,cospOUT%calipso_lidarcld) - call mask_outputs_2d(Npoints,LIDAR_NCAT,swath_mask_out,cospOUT%calipso_cldlayer) - call mask_outputs_2d(Npoints,LIDAR_NTYPE,swath_mask_out,cospOUT%calipso_cldtype) - call mask_outputs_2d(Npoints,LIDAR_NTYPE,swath_mask_out,cospOUT%calipso_cldtypetemp) - call mask_outputs_2d(Npoints,2,swath_mask_out,cospOUT%calipso_cldtypemeanz) - call mask_outputs_2d(Npoints,3,swath_mask_out,cospOUT%calipso_cldtypemeanzse) - ! 3D - call mask_outputs_3d(Npoints,Ncolumns,Nlevels,swath_mask_out,cospOUT%calipso_betaperp_tot) - call mask_outputs_3d(Npoints,Ncolumns,Nlevels,swath_mask_out,cospOUT%calipso_beta_tot) - call mask_outputs_3d(Npoints,Ncolumns,Nlevels,swath_mask_out,cospOUT%calipso_tau_tot) - call mask_outputs_3d(Npoints,Nlvgrid,6,swath_mask_out,cospOUT%calipso_lidarcldphase) - call mask_outputs_3d(Npoints,Nlvgrid,LIDAR_NTYPE+1,swath_mask_out,cospOUT%calipso_lidarcldtype) - call mask_outputs_3d(Npoints,LIDAR_NCAT,6,swath_mask_out,cospOUT%calipso_cldlayerphase) - call mask_outputs_3d(Npoints,LIDAR_NTEMP,5,swath_mask_out,cospOUT%calipso_lidarcldtmp) - call mask_outputs_3d(Npoints,SR_BINS,Nlvgrid,swath_mask_out,cospOUT%calipso_cfad_sr) - deallocate(cosp_localtime_width,cosp_localtime,swath_mask_out) - end if - - !------------------ PARASOL ------------------! - if (N_SWATHS_PARASOL .gt. 0) then - - call compute_orbitmasks(Npoints,N_SWATHS_PARASOL,SWATH_LOCALTIMES_PARASOL,SWATH_WIDTHS_PARASOL, & - cospstateIN%lat,cospstateIN%lon,cospstateIN%rttov_time(:,1), & - cospstateIN%rttov_time(:,2),swath_mask_out) - ! Mask out areas that are not observed. Need different statements for outputs of different dimensionality because apparently fortran is dumb at broadcasting :( - ! 2-D - call mask_outputs_2d(Npoints,PARASOL_NREFL,swath_mask_out,cospOUT%parasolGrid_refl) - ! 3D - call mask_outputs_3d(Npoints,Ncolumns,PARASOL_NREFL,swath_mask_out,cospOUT%parasolPix_refl) - deallocate(cosp_localtime_width,cosp_localtime,swath_mask_out) - end if - - !------------------ CLOUDSAT ------------------! - if (N_SWATHS_ClOUDSAT .gt. 0) then - - call compute_orbitmasks(Npoints,N_SWATHS_ClOUDSAT,SWATH_LOCALTIMES_ClOUDSAT,SWATH_WIDTHS_ClOUDSAT, & - cospstateIN%lat,cospstateIN%lon,cospstateIN%rttov_time(:,1), & - cospstateIN%rttov_time(:,2),swath_mask_out) - ! Mask out areas that are not observed. Need different statements for outputs of different dimensionality because apparently fortran is dumb at broadcasting :( - ! 1-D - where ( swath_mask_out ) - cospOUT%cloudsat_tcc(1:Npoints) = R_UNDEF - cospOUT%cloudsat_tcc2(1:Npoints) = R_UNDEF - cospOUT%radar_lidar_tcc(1:Npoints) = R_UNDEF - cospOUT%cloudsat_pia(1:Npoints) = R_UNDEF - end where - ! 2-D - call mask_outputs_2d(Npoints,Nlevels,swath_mask_out,cospOUT%lidar_only_freq_cloud) - call mask_outputs_2d(Npoints,cloudsat_DBZE_BINS,swath_mask_out,cospOUT%cloudsat_precip_cover) - ! 3D - call mask_outputs_3d(Npoints,Ncolumns,Nlevels,swath_mask_out,cospOUT%cloudsat_Ze_tot) - call mask_outputs_3d(Npoints,cloudsat_DBZE_BINS,Nlevels,swath_mask_out,cospOUT%cloudsat_cfad_ze) - - !---------- Joint CloudSat+MODIS simulators outputs ----------! - ! 2-D - call mask_outputs_2d(Npoints,WR_NREGIME,swath_mask_out,cospOUT%wr_occfreq_ntotal) - ! 4-D - call mask_outputs_4d(Npoints,CFODD_NDBZE,CFODD_NICOD,CFODD_NCLASS,swath_mask_out,cospOUT%cfodd_ntotal) - deallocate(cosp_localtime_width,cosp_localtime,swath_mask_out) - end if - - !------------------ ATLID Lidar ------------------! - if (N_SWATHS_ATLID .gt. 0) then - - call compute_orbitmasks(Npoints,N_SWATHS_ATLID,SWATH_LOCALTIMES_ATLID,SWATH_WIDTHS_ATLID, & - cospstateIN%lat,cospstateIN%lon,cospstateIN%rttov_time(:,1), & - cospstateIN%rttov_time(:,2),swath_mask_out) - ! Mask out areas that are not observed. Need different statements for outputs of different dimensionality because apparently fortran is dumb at broadcasting :( - ! The "atlid_srbval" variable doesn't have a spatial dimension so it is excluded here. - ! 2-D - call mask_outputs_2d(Npoints,Nlvgrid,swath_mask_out,cospOUT%atlid_lidarcld) - call mask_outputs_2d(Npoints,LIDAR_NCAT,swath_mask_out,cospOUT%atlid_cldlayer) - call mask_outputs_2d(Npoints,Nlevels,swath_mask_out,cospOUT%atlid_beta_mol) - ! 3D - call mask_outputs_3d(Npoints,Ncolumns,Nlevels,swath_mask_out,cospOUT%atlid_beta_tot) - call mask_outputs_3d(Npoints,SR_BINS,Nlvgrid,swath_mask_out,cospOUT%atlid_cfad_sr) - deallocate(cosp_localtime_width,cosp_localtime,swath_mask_out) - end if print*,'Time to read in data: ',driver_time(2)-driver_time(1) print*,'Time to initialize: ',driver_time(3)-driver_time(2) @@ -906,6 +756,11 @@ program cosp2_test call destroy_cospstateIN(cospstateIN) if (rttov_verbose) print*,'Calling "cosp_cleanUp".' call cosp_cleanUp() + ! Clean swathing DDT + do ij=1,7 + if (associated(cospswathsIN(ij) % inst_localtimes)) nullify(cospswathsIN(ij) % inst_localtimes) + if (associated(cospswathsIN(ij) % inst_localtime_widths)) nullify(cospswathsIN(ij) % inst_localtime_widths) + end do if (rttov_verbose) print*,'all done.' contains @@ -1367,83 +1222,6 @@ subroutine compute_orbitmasks(Npoints,Nlocaltimes,localtimes,localtime_widths, end subroutine compute_orbitmasks - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE mask_outputs_2d - Mask out a 2d array - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine mask_outputs_2d(dim1,dim2,mask,data_array) - ! Inputs - integer,intent(in) :: & - dim1, & - dim2 - logical,dimension(dim1),intent(in) :: & - mask - real(wp),dimension(dim1,dim2),intent(inout) :: & - data_array - - ! Local variables - integer :: i ! iterator - - do i=1,dim2 - where ( mask ) data_array(1:dim1,i) = R_UNDEF - end do - - end subroutine mask_outputs_2d - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE mask_outputs_3d - Mask out a 3d array - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine mask_outputs_3d(dim1,dim2,dim3,mask,data_array) - - ! Inputs - integer,intent(in) :: & - dim1, & - dim2, & - dim3 - logical,dimension(dim1),intent(in) :: & - mask - real(wp),dimension(dim1,dim2,dim3),intent(inout) :: & - data_array - - ! Local variables - integer :: i,j ! iterator - - do i=1,dim2 - do j=1,dim3 - where ( mask ) data_array(1:dim1,i,j) = R_UNDEF - end do - end do - - end subroutine mask_outputs_3d - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE mask_outputs_4d - Mask out a 3d array - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine mask_outputs_4d(dim1,dim2,dim3,dim4,mask,data_array) - - ! Inputs - integer,intent(in) :: & - dim1, & - dim2, & - dim3, & - dim4 - logical,dimension(dim1),intent(in) :: & - mask - real(wp),dimension(dim1,dim2,dim3,dim4),intent(inout) :: & - data_array - - ! Local variables - integer :: i,j,k ! iterator - - do i=1,dim2 - do j=1,dim3 - do k=1,dim4 - where ( mask ) data_array(1:dim1,i,j,k) = R_UNDEF - end do - end do - end do - - end subroutine mask_outputs_4d - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE construct_cospIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/cosp.F90 b/src/cosp.F90 index 9a80277041..14c053516b 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -133,6 +133,19 @@ MODULE MOD_COSP fl_snow ! Precipitation (snow) flux (kg/m2/s) end type cosp_column_inputs + ! ###################################################################################### + ! TYPE swath_inputs + ! ###################################################################################### + type swath_inputs + + integer :: & + N_inst_swaths = 0 + real(wp),dimension(:),pointer :: & + inst_localtimes, & + inst_localtime_widths + + end type swath_inputs + ! ###################################################################################### ! TYPE cosp_optical_inputs ! ###################################################################################### @@ -182,6 +195,8 @@ MODULE MOD_COSP rcfg_cloudsat ! Radar configuration information (CLOUDSAT) type(rttov_cfg),dimension(:),pointer :: & cfg_rttov ! RTTOV configuration information (multiple instruments) + type(swath_inputs),dimension(7) :: & ! Could be a pointer but fine + cospswathsIN end type cosp_optical_inputs ! ###################################################################################### @@ -414,6 +429,89 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cfodd_ntotal (:,:,:,:), & ! # of total samples for CFODD (Npoints,CFODD_NDBZE,CFODD_NICOD,CFODD_NCLASS) wr_occfreq_ntotal(:,:) ! # of warm-rain (nonprecip/drizzle/precip) (Npoints,WR_NREGIME) + ! Fields used in orbit swathing of gridcells. + logical,dimension(:),allocatable :: & ! Mask of reals over all local times + ISCCP_SWATH_MASK, & + MISR_SWATH_MASK, & + CALIPSO_SWATH_MASK, & + CLOUDSAT_SWATH_MASK, & + MODIS_SWATH_MASK, & + PARASOL_SWATH_MASK, & + ATLID_SWATH_MASK + + integer :: j + integer,target :: & ! Number of gridcell points to computer on after swathing + N_ISCCP_SWATHED, & + N_MISR_SWATHED, & + N_CALIPSO_SWATHED, & + N_CLOUDSAT_SWATHED, & + N_MODIS_SWATHED, & + N_PARASOL_SWATHED, & + N_ATLID_SWATHED + ! ISCCP swathing variables + integer,dimension(:),target,allocatable :: & + temp_isccp_sunlit + real(wp),dimension(:),target,allocatable :: & + temp_isccp_skt, & + temp_isccp_meanalbedocld, & + temp_isccp_meanptop, & + temp_isccp_meantaucld, & + temp_isccp_totalcldarea, & + temp_isccp_meantb + real(wp),dimension(:,:),target,allocatable :: & + temp_isccp_qv, & + temp_isccp_at, & + temp_isccp_phalf, & + temp_isccp_pfull + real(wp),dimension(:,:,:),target,allocatable :: & + temp_isccp_frac_out, & + temp_isccp_tau_067, & + temp_isccp_emiss_11, & + temp_isccp_fq + ! MISR swathing variables + integer,dimension(:),target,allocatable :: & + temp_misr_sunlit + real(wp),dimension(:,:),target,allocatable :: & + temp_misr_zfull, & + temp_misr_at + real(wp),dimension(:,:,:),target,allocatable :: & + temp_misr_dtau + ! CALIPSO swathing variables + real(wp),dimension(:,:),target,allocatable :: & + temp_beta_mol_calipso, & + temp_tau_mol_calipso + real(wp),dimension(:,:,:),target,allocatable :: & + temp_betatot_calipso, & + temp_tautot_calipso, & + temp_betatot_liq_calipso, & + temp_tautot_liq_calipso, & + temp_betatot_ice_calipso, & + temp_tautot_ice_calipso + ! ATLID swathing variables + real(wp),dimension(:,:),target,allocatable :: & + temp_beta_mol_atlid, & + temp_tau_mol_atlid + real(wp),dimension(:,:,:),target,allocatable :: & + temp_betatot_atlid, & + temp_tautot_atlid + ! PARASOL swathing variables + real(wp),dimension(:,:),target,allocatable :: & + temp_tautot_S_liq, & + temp_tautot_S_ice + ! CLOUDSAT swathing variables + real(wp),dimension(:,:),target,allocatable :: & + temp_hgt_matrix + real(wp),dimension(:,:,:),target,allocatable :: & + temp_z_vol_cloudsat, & + temp_kr_vol_cloudsat, & + temp_g_vol_cloudsat + ! MODIS swathing variables. + real(wp),dimension(:,:,:),target,allocatable :: & + temp_modis_liqFrac, & + temp_modis_tau, & + temp_modis_g, & + temp_modis_w0 + ! Initialize error reporting for output cosp_simulator(:)='' if (present(debug)) verbose = debug @@ -647,44 +745,191 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 3) Populate instrument simulator inputs !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + ! JKS need to encode swathing inputs here. + print*,'cospIN % cospswathsIN(1) % N_inst_swaths: ',cospIN % cospswathsIN(1) % N_inst_swaths + print*,'cospIN % cospswathsIN(1) % inst_localtime_widths: ',cospIN % cospswathsIN(1) % inst_localtime_widths + print*,'cospIN % cospswathsIN(1) % inst_localtimes: ',cospIN % cospswathsIN(1) % inst_localtimes + ! Indexing order is ISCCP, MISR, CALIPSO, ATLID, PARASOL, CLOUDSAT, MODIS + if (Lisccp_subcolumn .or. Lmodis_subcolumn) then - isccpIN%Npoints => Npoints - isccpIN%Ncolumns => cospIN%Ncolumns - isccpIN%Nlevels => cospIN%Nlevels - isccpIN%emsfc_lw => cospIN%emsfc_lw - isccpIN%skt => cospgridIN%skt - isccpIN%qv => cospgridIN%qv - isccpIN%at => cospgridIN%at - isccpIN%frac_out => cospIN%frac_out - isccpIN%dtau => cospIN%tau_067 - isccpIN%dem => cospIN%emiss_11 - isccpIN%phalf => cospgridIN%phalf - isccpIN%sunlit => cospgridIN%sunlit - isccpIN%pfull => cospgridIN%pfull + if (cospIN % cospswathsIN(1) % N_inst_swaths .gt. 0) then + allocate(ISCCP_SWATH_MASK(Npoints)) + ! Do swathing to figure out which cells to simulate on + call compute_orbitmasks(Npoints, & + cospIN % cospswathsIN(1) % N_inst_swaths, & + cospIN % cospswathsIN(1) % inst_localtimes, & + cospIN % cospswathsIN(1) % inst_localtime_widths, & + cospgridIN%lat, cospgridIN%lon, & + cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute + ISCCP_SWATH_MASK) ! Output: logical mask array + + N_ISCCP_SWATHED = COUNT(ISCCP_SWATH_MASK) ! number of points to actually operate on + + print*,'N_ISCCP_SWATHED: ',N_ISCCP_SWATHED + print*,'ISCCP_SWATH_MASK: ',ISCCP_SWATH_MASK + ! Allocate swathed arrays. + allocate(temp_isccp_skt(N_ISCCP_SWATHED),temp_isccp_qv(N_ISCCP_SWATHED,cospIN%Nlevels),temp_isccp_at(N_ISCCP_SWATHED,cospIN%Nlevels), & + temp_isccp_frac_out(N_ISCCP_SWATHED,cospIN%Ncolumns,cospIN%Nlevels),temp_isccp_tau_067(N_ISCCP_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & + temp_isccp_emiss_11(N_ISCCP_SWATHED,cospIN%Ncolumns,cospIN%Nlevels),temp_isccp_phalf(N_ISCCP_SWATHED,cospIN%Nlevels+1), & + temp_isccp_pfull(N_ISCCP_SWATHED,cospIN%Nlevels),temp_isccp_sunlit(N_ISCCP_SWATHED)) + + ! Encode step: Read only appropriate values into the new temp arrays. + j = 0 ! Initialize input + do i=1,Npoints + if (ISCCP_SWATH_MASK(i)) then + j = j + 1 ! Increment first + temp_isccp_skt(j) = cospgridIN%skt(i) + temp_isccp_qv(j,:) = cospgridIN%qv(i,:) + temp_isccp_at(j,:) = cospgridIN%at(i,:) + temp_isccp_frac_out(j,:,:) = cospIN%frac_out(i,:,:) + temp_isccp_tau_067(j,:,:) = cospIN%tau_067(i,:,:) + temp_isccp_emiss_11(j,:,:) = cospIN%emiss_11(i,:,:) + temp_isccp_phalf(j,:) = cospgridIN%phalf(i,:) + temp_isccp_pfull(j,:) = cospgridIN%pfull(i,:) + temp_isccp_sunlit(j) = cospgridIN%sunlit(i) + end if + end do + + isccpIN%Npoints => N_ISCCP_SWATHED + isccpIN%Ncolumns => cospIN%Ncolumns + isccpIN%Nlevels => cospIN%Nlevels + isccpIN%emsfc_lw => cospIN%emsfc_lw + isccpIN%skt => temp_isccp_skt + isccpIN%qv => temp_isccp_qv + isccpIN%at => temp_isccp_at + isccpIN%frac_out => temp_isccp_frac_out + isccpIN%dtau => temp_isccp_tau_067 + isccpIN%dem => temp_isccp_emiss_11 + isccpIN%phalf => temp_isccp_phalf + isccpIN%pfull => temp_isccp_pfull + isccpIN%sunlit => temp_isccp_sunlit + else + isccpIN%Npoints => Npoints + isccpIN%Ncolumns => cospIN%Ncolumns + isccpIN%Nlevels => cospIN%Nlevels + isccpIN%emsfc_lw => cospIN%emsfc_lw + isccpIN%skt => cospgridIN%skt + isccpIN%qv => cospgridIN%qv + isccpIN%at => cospgridIN%at + isccpIN%frac_out => cospIN%frac_out + isccpIN%dtau => cospIN%tau_067 + isccpIN%dem => cospIN%emiss_11 + isccpIN%phalf => cospgridIN%phalf + isccpIN%pfull => cospgridIN%pfull + isccpIN%sunlit => cospgridIN%sunlit + end if endif if (Lmisr_subcolumn) then - misrIN%Npoints => Npoints - misrIN%Ncolumns => cospIN%Ncolumns - misrIN%Nlevels => cospIN%Nlevels - misrIN%dtau => cospIN%tau_067 - misrIN%sunlit => cospgridIN%sunlit - misrIN%zfull => cospgridIN%hgt_matrix - misrIN%at => cospgridIN%at + if (cospIN % cospswathsIN(2) % N_inst_swaths .gt. 0) then + allocate(MISR_SWATH_MASK(Npoints)) + ! Do swathing to figure out which cells to simulate on + call compute_orbitmasks(Npoints, & + cospIN % cospswathsIN(2) % N_inst_swaths, & + cospIN % cospswathsIN(2) % inst_localtimes, & + cospIN % cospswathsIN(2) % inst_localtime_widths, & + cospgridIN%lat, cospgridIN%lon, & + cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute + MISR_SWATH_MASK) ! Output: logical mask array + + N_MISR_SWATHED = COUNT(MISR_SWATH_MASK) ! number of points to actually operate on + + ! Allocate swathed arrays. + allocate(temp_misr_dtau(N_MISR_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & + temp_misr_sunlit(N_MISR_SWATHED), & + temp_misr_zfull(N_MISR_SWATHED,cospIN%Nlevels), & + temp_misr_at(N_MISR_SWATHED,cospIN%Nlevels)) + + ! Encode step: Read only appropriate values into the new temp arrays. + j = 0 ! Initialize input + do i=1,Npoints + if (MISR_SWATH_MASK(i)) then + j = j + 1 ! Increment first + temp_misr_dtau(j,:,:) = cospIN%tau_067(i,:,:) + temp_misr_at(j,:) = cospgridIN%at(i,:) + temp_misr_zfull(j,:) = cospgridIN%hgt_matrix(i,:) + temp_misr_sunlit(j) = cospgridIN%sunlit(i) + end if + end do + misrIN%Npoints => N_MISR_SWATHED + misrIN%Ncolumns => cospIN%Ncolumns + misrIN%Nlevels => cospIN%Nlevels + misrIN%dtau => temp_misr_dtau + misrIN%sunlit => temp_misr_sunlit + misrIN%zfull => temp_misr_zfull + misrIN%at => temp_misr_at + else + misrIN%Npoints => Npoints + misrIN%Ncolumns => cospIN%Ncolumns + misrIN%Nlevels => cospIN%Nlevels + misrIN%dtau => cospIN%tau_067 + misrIN%sunlit => cospgridIN%sunlit + misrIN%zfull => cospgridIN%hgt_matrix + misrIN%at => cospgridIN%at + end if endif if (Lcalipso_subcolumn) then - calipsoIN%Npoints => Npoints - calipsoIN%Ncolumns => cospIN%Ncolumns - calipsoIN%Nlevels => cospIN%Nlevels - calipsoIN%beta_mol => cospIN%beta_mol_calipso - calipsoIN%betatot => cospIN%betatot_calipso - calipsoIN%betatot_liq => cospIN%betatot_liq_calipso - calipsoIN%betatot_ice => cospIN%betatot_ice_calipso - calipsoIN%tau_mol => cospIN%tau_mol_calipso - calipsoIN%tautot => cospIN%tautot_calipso - calipsoIN%tautot_liq => cospIN%tautot_liq_calipso - calipsoIN%tautot_ice => cospIN%tautot_ice_calipso + if (cospIN % cospswathsIN(1) % N_inst_swaths .gt. 0) then + allocate(CALIPSO_SWATH_MASK(Npoints)) + ! Do swathing to figure out which cells to simulate on + call compute_orbitmasks(Npoints, & + cospIN % cospswathsIN(3) % N_inst_swaths, & + cospIN % cospswathsIN(3) % inst_localtimes, & + cospIN % cospswathsIN(3) % inst_localtime_widths, & + cospgridIN%lat, cospgridIN%lon, & + cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute + CALIPSO_SWATH_MASK) ! Output: logical mask array + N_CALIPSO_SWATHED = COUNT(CALIPSO_SWATH_MASK) ! number of points to actually operate on + ! Allocate swathed arrays. + allocate(temp_beta_mol_calipso(N_CALIPSO_SWATHED,cospIN%Nlevels), & + temp_tau_mol_calipso(N_CALIPSO_SWATHED,cospIN%Nlevels), & + temp_betatot_calipso(N_CALIPSO_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & + temp_tautot_calipso(N_CALIPSO_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & + temp_betatot_liq_calipso(N_CALIPSO_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & + temp_tautot_liq_calipso(N_CALIPSO_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & + temp_betatot_ice_calipso(N_CALIPSO_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & + temp_tautot_ice_calipso(N_CALIPSO_SWATHED,cospIN%Ncolumns,cospIN%Nlevels)) + ! Encode step: Read only appropriate values into the new temp arrays. + j = 0 ! Initialize input + do i=1,Npoints + if (CALIPSO_SWATH_MASK(i)) then + j = j + 1 + temp_beta_mol_calipso(j,:) = cospIN%beta_mol_calipso(i,:) + temp_tau_mol_calipso(j,:) = cospIN%tau_mol_calipso(i,:) + temp_betatot_calipso(j,:,:) = cospIN%betatot_calipso(i,:,:) + temp_tautot_calipso(j,:,:) = cospIN%tautot_calipso(i,:,:) + temp_betatot_liq_calipso(j,:,:) = cospIN%betatot_liq_calipso(i,:,:) + temp_tautot_liq_calipso(j,:,:) = cospIN%tautot_liq_calipso(i,:,:) + temp_betatot_ice_calipso(j,:,:) = cospIN%betatot_ice_calipso(i,:,:) + temp_tautot_ice_calipso(j,:,:) = cospIN%tautot_ice_calipso(i,:,:) + end if + end do + calipsoIN%Npoints => N_CALIPSO_SWATHED + calipsoIN%Ncolumns => cospIN%Ncolumns + calipsoIN%Nlevels => cospIN%Nlevels + calipsoIN%beta_mol => cospIN%beta_mol_calipso + calipsoIN%betatot => cospIN%betatot_calipso + calipsoIN%betatot_liq => cospIN%betatot_liq_calipso + calipsoIN%betatot_ice => cospIN%betatot_ice_calipso + calipsoIN%tau_mol => cospIN%tau_mol_calipso + calipsoIN%tautot => cospIN%tautot_calipso + calipsoIN%tautot_liq => cospIN%tautot_liq_calipso + calipsoIN%tautot_ice => cospIN%tautot_ice_calipso + else + calipsoIN%Npoints => Npoints + calipsoIN%Ncolumns => cospIN%Ncolumns + calipsoIN%Nlevels => cospIN%Nlevels + calipsoIN%beta_mol => cospIN%beta_mol_calipso + calipsoIN%betatot => cospIN%betatot_calipso + calipsoIN%betatot_liq => cospIN%betatot_liq_calipso + calipsoIN%betatot_ice => cospIN%betatot_ice_calipso + calipsoIN%tau_mol => cospIN%tau_mol_calipso + calipsoIN%tautot => cospIN%tautot_calipso + calipsoIN%tautot_liq => cospIN%tautot_liq_calipso + calipsoIN%tautot_ice => cospIN%tautot_ice_calipso + endif endif if (LgrLidar532_subcolumn) then @@ -698,53 +943,201 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) endif if (Latlid_subcolumn) then - atlidIN%Npoints => Npoints - atlidIN%Ncolumns => cospIN%Ncolumns - atlidIN%Nlevels => cospIN%Nlevels - atlidIN%beta_mol_atlid => cospIN%beta_mol_atlid - atlidIN%betatot_atlid => cospIN%betatot_atlid - atlidIN%tau_mol_atlid => cospIN%tau_mol_atlid - atlidIN%tautot_atlid => cospIN%tautot_atlid + if (cospIN % cospswathsIN(4) % N_inst_swaths .gt. 0) then + allocate(ATLID_SWATH_MASK(Npoints)) + ! Do swathing to figure out which cells to simulate on + call compute_orbitmasks(Npoints, & + cospIN % cospswathsIN(4) % N_inst_swaths, & + cospIN % cospswathsIN(4) % inst_localtimes, & + cospIN % cospswathsIN(4) % inst_localtime_widths, & + cospgridIN%lat, cospgridIN%lon, & + cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute + ATLID_SWATH_MASK) ! Output: logical mask array + + N_ATLID_SWATHED = COUNT(ATLID_SWATH_MASK) ! number of points to actually operate on + ! Allocate swathed arrays. + allocate(temp_beta_mol_atlid(N_ATLID_SWATHED,cospIN%Nlevels), & + temp_betatot_atlid(N_ATLID_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & + temp_tau_mol_atlid(N_ATLID_SWATHED,cospIN%Nlevels), & + temp_tautot_atlid(N_ATLID_SWATHED,cospIN%Ncolumns,cospIN%Nlevels)) + ! Encode step: Read only appropriate values into the new temp arrays. + j = 0 ! Initialize input + do i=1,Npoints + if (ATLID_SWATH_MASK(i)) then + j = j + 1 + temp_beta_mol_atlid(j,:) = cospIN%beta_mol_atlid(i,:) + temp_tau_mol_atlid(j,:) = cospIN%tau_mol_atlid(i,:) + temp_betatot_atlid(j,:,:) = cospIN%betatot_atlid(i,:,:) + temp_tautot_atlid(j,:,:) = cospIN%tautot_atlid(i,:,:) + end if + end do + atlidIN%Npoints => N_ATLID_SWATHED + atlidIN%Ncolumns => cospIN%Ncolumns + atlidIN%Nlevels => cospIN%Nlevels + atlidIN%beta_mol_atlid => temp_beta_mol_atlid + atlidIN%betatot_atlid => temp_betatot_atlid + atlidIN%tau_mol_atlid => temp_tau_mol_atlid + atlidIN%tautot_atlid => temp_tautot_atlid + else + atlidIN%Npoints => Npoints + atlidIN%Ncolumns => cospIN%Ncolumns + atlidIN%Nlevels => cospIN%Nlevels + atlidIN%beta_mol_atlid => cospIN%beta_mol_atlid + atlidIN%betatot_atlid => cospIN%betatot_atlid + atlidIN%tau_mol_atlid => cospIN%tau_mol_atlid + atlidIN%tautot_atlid => cospIN%tautot_atlid + end if endif if (Lparasol_subcolumn) then - parasolIN%Npoints => Npoints - parasolIN%Nlevels => cospIN%Nlevels - parasolIN%Ncolumns => cospIN%Ncolumns - parasolIN%Nrefl => cospIN%Nrefl - parasolIN%tautot_S_liq => cospIN%tautot_S_liq - parasolIN%tautot_S_ice => cospIN%tautot_S_ice + if (cospIN % cospswathsIN(5) % N_inst_swaths .gt. 0) then + allocate(PARASOL_SWATH_MASK(Npoints)) + ! Do swathing to figure out which cells to simulate on + call compute_orbitmasks(Npoints, & + cospIN % cospswathsIN(5) % N_inst_swaths, & + cospIN % cospswathsIN(5) % inst_localtimes, & + cospIN % cospswathsIN(5) % inst_localtime_widths, & + cospgridIN%lat, cospgridIN%lon, & + cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute + PARASOL_SWATH_MASK) ! Output: logical mask array + N_PARASOL_SWATHED = COUNT(PARASOL_SWATH_MASK) ! number of points to actually operate on + ! Allocate swathed arrays. + allocate(temp_tautot_S_liq(N_PARASOL_SWATHED,cospIN%Ncolumns), & + temp_tautot_S_ice(N_PARASOL_SWATHED,cospIN%Ncolumns)) + ! Encode step: Read only appropriate values into the new temp arrays. + j = 0 ! Initialize input + do i=1,Npoints + if (PARASOL_SWATH_MASK(i)) then + j = j + 1 + temp_tautot_S_liq(j,:) = cospIN%tautot_S_liq(i,:) + temp_tautot_S_ice(j,:) = cospIN%tautot_S_ice(i,:) + end if + end do + parasolIN%Npoints => N_PARASOL_SWATHED + parasolIN%Nlevels => cospIN%Nlevels + parasolIN%Ncolumns => cospIN%Ncolumns + parasolIN%Nrefl => cospIN%Nrefl + parasolIN%tautot_S_liq => temp_tautot_S_liq + parasolIN%tautot_S_ice => temp_tautot_S_ice + else + parasolIN%Npoints => Npoints + parasolIN%Nlevels => cospIN%Nlevels + parasolIN%Ncolumns => cospIN%Ncolumns + parasolIN%Nrefl => cospIN%Nrefl + parasolIN%tautot_S_liq => cospIN%tautot_S_liq + parasolIN%tautot_S_ice => cospIN%tautot_S_ice + end if endif if (Lcloudsat_subcolumn) then - cloudsatIN%Npoints => Npoints - cloudsatIN%Nlevels => cospIN%Nlevels - cloudsatIN%Ncolumns => cospIN%Ncolumns - cloudsatIN%z_vol => cospIN%z_vol_cloudsat - cloudsatIN%kr_vol => cospIN%kr_vol_cloudsat - cloudsatIN%g_vol => cospIN%g_vol_cloudsat - cloudsatIN%rcfg => cospIN%rcfg_cloudsat - cloudsatIN%hgt_matrix => cospgridIN%hgt_matrix + if (cospIN % cospswathsIN(6) % N_inst_swaths .gt. 0) then + allocate(CLOUDSAT_SWATH_MASK(Npoints)) + ! Do swathing to figure out which cells to simulate on + call compute_orbitmasks(Npoints, & + cospIN % cospswathsIN(6) % N_inst_swaths, & + cospIN % cospswathsIN(6) % inst_localtimes, & + cospIN % cospswathsIN(6) % inst_localtime_widths, & + cospgridIN%lat, cospgridIN%lon, & + cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute + CLOUDSAT_SWATH_MASK) ! Output: logical mask array + N_CLOUDSAT_SWATHED = COUNT(CLOUDSAT_SWATH_MASK) ! number of points to actually operate on + ! Allocate swathed arrays. + allocate(temp_z_vol_cloudsat(N_CLOUDSAT_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & + temp_kr_vol_cloudsat(N_CLOUDSAT_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & + temp_g_vol_cloudsat(N_CLOUDSAT_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & + temp_hgt_matrix(N_CLOUDSAT_SWATHED,cospIN%Nlevels)) + ! Encode step: Read only appropriate values into the new temp arrays. + j = 0 ! Initialize input + do i=1,Npoints + if (CLOUDSAT_SWATH_MASK(i)) then + j = j + 1 + temp_z_vol_cloudsat(j,:,:) = cospIN%z_vol_cloudsat(i,:,:) + temp_kr_vol_cloudsat(j,:,:) = cospIN%kr_vol_cloudsat(i,:,:) + temp_g_vol_cloudsat(j,:,:) = cospIN%g_vol_cloudsat(i,:,:) + temp_hgt_matrix(j,:) = cospgridIN%hgt_matrix(i,:) + end if + end do + cloudsatIN%Npoints => N_CLOUDSAT_SWATHED + cloudsatIN%Nlevels => cospIN%Nlevels + cloudsatIN%Ncolumns => cospIN%Ncolumns + cloudsatIN%z_vol => temp_z_vol_cloudsat + cloudsatIN%kr_vol => temp_kr_vol_cloudsat + cloudsatIN%g_vol => temp_g_vol_cloudsat + cloudsatIN%rcfg => cospIN%rcfg_cloudsat + cloudsatIN%hgt_matrix => temp_hgt_matrix + else + cloudsatIN%Npoints => Npoints + cloudsatIN%Nlevels => cospIN%Nlevels + cloudsatIN%Ncolumns => cospIN%Ncolumns + cloudsatIN%z_vol => cospIN%z_vol_cloudsat + cloudsatIN%kr_vol => cospIN%kr_vol_cloudsat + cloudsatIN%g_vol => cospIN%g_vol_cloudsat + cloudsatIN%rcfg => cospIN%rcfg_cloudsat + cloudsatIN%hgt_matrix => cospgridIN%hgt_matrix + end if endif if (Lmodis_subcolumn) then - modisIN%Ncolumns => cospIN%Ncolumns - modisIN%Nlevels => cospIN%Nlevels - modisIN%Npoints => Npoints - modisIN%liqFrac => cospIN%fracLiq - modisIN%tau => cospIN%tau_067 - modisIN%g => cospIN%asym - modisIN%w0 => cospIN%ss_alb - modisIN%Nsunlit = count(cospgridIN%sunlit > 0) - if (modisIN%Nsunlit .gt. 0) then - allocate(modisIN%sunlit(modisIN%Nsunlit),modisIN%pres(modisIN%Nsunlit,cospIN%Nlevels+1)) - modisIN%sunlit = pack((/ (i, i = 1, Npoints ) /),mask = cospgridIN%sunlit > 0) - modisIN%pres = cospgridIN%phalf(int(modisIN%sunlit(:)),:) - endif - if (count(cospgridIN%sunlit <= 0) .gt. 0) then - allocate(modisIN%notSunlit(count(cospgridIN%sunlit <= 0))) - modisIN%notSunlit = pack((/ (i, i = 1, Npoints ) /),mask = .not. cospgridIN%sunlit > 0) - endif + if (cospIN % cospswathsIN(7) % N_inst_swaths .gt. 0) then + allocate(MODIS_SWATH_MASK(Npoints)) + ! Do swathing to figure out which cells to simulate on + call compute_orbitmasks(Npoints, & + cospIN % cospswathsIN(7) % N_inst_swaths, & + cospIN % cospswathsIN(7) % inst_localtimes, & + cospIN % cospswathsIN(7) % inst_localtime_widths, & + cospgridIN%lat, cospgridIN%lon, & + cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute + MODIS_SWATH_MASK) ! Output: logical mask array + N_MODIS_SWATHED = COUNT(MODIS_SWATH_MASK) ! number of points to actually operate on + ! Allocate swathed arrays. + allocate(temp_modis_liqFrac(N_MODIS_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & + temp_modis_tau(N_MODIS_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & + temp_modis_g(N_MODIS_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & + temp_modis_w0(N_MODIS_SWATHED,cospIN%Ncolumns,cospIN%Nlevels)) + ! Encode step: Read only appropriate values into the new temp arrays. + j = 0 ! Initialize input + do i=1,Npoints + if (MODIS_SWATH_MASK(i)) then + j = j + 1 + temp_modis_liqFrac(j,:,:) = cospIN%fracLiq(i,:,:) + temp_modis_tau(j,:,:) = cospIN%tau_067(i,:,:) + temp_modis_g(j,:,:) = cospIN%asym(i,:,:) + temp_modis_w0(j,:,:) = cospIN%ss_alb(i,:,:) + end if + end do + modisIN%Npoints => N_MODIS_SWATHED + modisIN%Ncolumns => cospIN%Ncolumns + modisIN%Nlevels => cospIN%Nlevels + modisIN%liqFrac => temp_modis_liqFrac + modisIN%tau => temp_modis_tau + modisIN%g => temp_modis_g + modisIN%w0 => temp_modis_w0 + modisIN%Nsunlit = count(cospgridIN%sunlit > 0 .and. MODIS_SWATH_MASK) + if (modisIN%Nsunlit .gt. 0) then + allocate(modisIN%sunlit(modisIN%Nsunlit),modisIN%pres(modisIN%Nsunlit,cospIN%Nlevels+1)) + modisIN%sunlit = pack((/ (i, i = 1, N_MODIS_SWATHED ) /),mask = (cospgridIN%sunlit > 0 .and. (MODIS_SWATH_MASK))) + modisIN%pres = cospgridIN%phalf(int(modisIN%sunlit(:)),:) ! Indexes just the masked locations + ! I need to figure out the complementary masking here. + endif + else + modisIN%Ncolumns => cospIN%Ncolumns + modisIN%Nlevels => cospIN%Nlevels + modisIN%Npoints => Npoints + modisIN%liqFrac => cospIN%fracLiq + modisIN%tau => cospIN%tau_067 + modisIN%g => cospIN%asym + modisIN%w0 => cospIN%ss_alb + modisIN%Nsunlit = count(cospgridIN%sunlit > 0) + if (modisIN%Nsunlit .gt. 0) then + allocate(modisIN%sunlit(modisIN%Nsunlit),modisIN%pres(modisIN%Nsunlit,cospIN%Nlevels+1)) + modisIN%sunlit = pack((/ (i, i = 1, Npoints ) /),mask = cospgridIN%sunlit > 0) + modisIN%pres = cospgridIN%phalf(int(modisIN%sunlit(:)),:) + endif + if (count(cospgridIN%sunlit <= 0) .gt. 0) then + allocate(modisIN%notSunlit(count(cospgridIN%sunlit <= 0))) + modisIN%notSunlit = pack((/ (i, i = 1, Npoints ) /),mask = .not. cospgridIN%sunlit > 0) + endif + end if endif if (Lrttov_column) then @@ -800,43 +1193,100 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! ISCCP (icarus) subcolumn simulator if (Lisccp_subcolumn .or. Lmodis_subcolumn) then - ! Allocate space for local variables - allocate(isccpLEVMATCH(Npoints,isccpIN%Ncolumns), & - isccp_boxttop(Npoints,isccpIN%Ncolumns), & - isccp_boxptop(Npoints,isccpIN%Ncolumns), & - isccp_boxtau(Npoints,isccpIN%Ncolumns), isccp_meantbclr(Npoints)) - ! Call simulator - call icarus_subcolumn(isccpIN%npoints,isccpIN%ncolumns,isccpIN%nlevels, & - isccpIN%sunlit,isccpIN%dtau,isccpIN%dem,isccpIN%skt, & - isccpIN%emsfc_lw,isccpIN%qv,isccpIN%at,isccpIN%pfull, & - isccpIN%phalf,isccpIN%frac_out,isccpLEVMATCH, & - isccp_boxtau(:,:),isccp_boxptop(:,:), & - isccp_boxttop(:,:),isccp_meantbclr(:)) - ! Store output (if requested) - if (associated(cospOUT%isccp_boxtau)) then - cospOUT%isccp_boxtau(ij:ik,:) = isccp_boxtau - endif - if (associated(cospOUT%isccp_boxptop)) then - cospOUT%isccp_boxptop(ij:ik,:) = isccp_boxptop - endif - if (associated(cospOUT%isccp_meantbclr)) then - cospOUT%isccp_meantbclr(ij:ik) = isccp_meantbclr + if (cospIN % cospswathsIN(1) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + ! Allocate space for local variables + allocate(isccpLEVMATCH(N_ISCCP_SWATHED,isccpIN%Ncolumns), & + isccp_boxttop(N_ISCCP_SWATHED,isccpIN%Ncolumns), & + isccp_boxptop(N_ISCCP_SWATHED,isccpIN%Ncolumns), & + isccp_boxtau(N_ISCCP_SWATHED,isccpIN%Ncolumns), & + isccp_meantbclr(N_ISCCP_SWATHED)) + ! Call simulator + call icarus_subcolumn(isccpIN%npoints,isccpIN%ncolumns,isccpIN%nlevels, & + isccpIN%sunlit,isccpIN%dtau,isccpIN%dem,isccpIN%skt, & + isccpIN%emsfc_lw,isccpIN%qv,isccpIN%at,isccpIN%pfull, & + isccpIN%phalf,isccpIN%frac_out,isccpLEVMATCH, & + isccp_boxtau(:,:),isccp_boxptop(:,:), & + isccp_boxttop(:,:),isccp_meantbclr(:)) + ! Decode outputs from swaths when reading into cospOUT fields + cospOUT%isccp_boxtau(:,:) = R_UNDEF + cospOUT%isccp_boxptop(:,:) = R_UNDEF + cospOUT%isccp_meantbclr(:) = R_UNDEF + j = 0 + do i=ij,ik ! Index ranges on outputs + if (ISCCP_SWATH_MASK(i - ij + 1)) then ! Convert back to an index for the swath mask + j = j + 1 + if (associated(cospOUT%isccp_boxtau)) cospOUT%isccp_boxtau(i,:) = isccp_boxtau(j,:) + if (associated(cospOUT%isccp_boxptop)) cospOUT%isccp_boxptop(i,:) = isccp_boxptop(j,:) + if (associated(cospOUT%isccp_meantbclr)) cospOUT%isccp_meantbclr(i) = isccp_meantbclr(j) + end if + end do + ! print*,'isccp_boxtau: ',isccp_boxtau + ! print*,'cospOUT%isccp_boxtau: ',cospOUT%isccp_boxtau + deallocate(temp_isccp_skt,temp_isccp_qv,temp_isccp_at, & + temp_isccp_frac_out,temp_isccp_tau_067, & + temp_isccp_emiss_11,temp_isccp_phalf, & + temp_isccp_pfull) ! some of these pointers might be needed later! + else ! Proceed normally + ! Allocate space for local variables + allocate(isccpLEVMATCH(Npoints,isccpIN%Ncolumns), & + isccp_boxttop(Npoints,isccpIN%Ncolumns), & + isccp_boxptop(Npoints,isccpIN%Ncolumns), & + isccp_boxtau(Npoints,isccpIN%Ncolumns), isccp_meantbclr(Npoints)) + ! Call simulator + call icarus_subcolumn(isccpIN%npoints,isccpIN%ncolumns,isccpIN%nlevels, & + isccpIN%sunlit,isccpIN%dtau,isccpIN%dem,isccpIN%skt, & + isccpIN%emsfc_lw,isccpIN%qv,isccpIN%at,isccpIN%pfull, & + isccpIN%phalf,isccpIN%frac_out,isccpLEVMATCH, & + isccp_boxtau(:,:),isccp_boxptop(:,:), & + isccp_boxttop(:,:),isccp_meantbclr(:)) + ! Store output (if requested) + if (associated(cospOUT%isccp_boxtau)) then + cospOUT%isccp_boxtau(ij:ik,:) = isccp_boxtau + endif + if (associated(cospOUT%isccp_boxptop)) then + cospOUT%isccp_boxptop(ij:ik,:) = isccp_boxptop + endif + if (associated(cospOUT%isccp_meantbclr)) then + cospOUT%isccp_meantbclr(ij:ik) = isccp_meantbclr + endif endif - endif + endif ! MISR subcolumn simulator if (Lmisr_subcolumn) then - ! Allocate space for local variables - allocate(misr_boxztop(Npoints,misrIN%Ncolumns), & - misr_boxtau(Npoints,misrIN%Ncolumns), & - misr_dist_model_layertops(Npoints,numMISRHgtBins)) - ! Call simulator - call misr_subcolumn(misrIN%Npoints,misrIN%Ncolumns,misrIN%Nlevels,misrIN%dtau, & - misrIN%zfull,misrIN%at,misrIN%sunlit,misr_boxtau, & - misr_dist_model_layertops,misr_boxztop) - ! Store output (if requested) - if (associated(cospOUT%misr_dist_model_layertops)) then - cospOUT%misr_dist_model_layertops(ij:ik,:) = misr_dist_model_layertops + if (cospIN % cospswathsIN(2) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + ! Allocate space for local variables + allocate(misr_boxztop(N_MISR_SWATHED,misrIN%Ncolumns), & + misr_boxtau(N_MISR_SWATHED,misrIN%Ncolumns), & + misr_dist_model_layertops(N_MISR_SWATHED,numMISRHgtBins)) + ! Call simulator + call misr_subcolumn(misrIN%Npoints,misrIN%Ncolumns,misrIN%Nlevels,misrIN%dtau, & + misrIN%zfull,misrIN%at,misrIN%sunlit,misr_boxtau, & + misr_dist_model_layertops,misr_boxztop) + ! Decode outputs from swaths when reading into cospOUT fields + cospOUT%misr_dist_model_layertops(:,:) = R_UNDEF + j = 0 + do i=ij,ik ! Index ranges on outputs + if (MISR_SWATH_MASK(i - ij + 1)) then ! Convert back to an index for the swath mask + j = j + 1 + if (associated(cospOUT%misr_dist_model_layertops)) cospOUT%misr_dist_model_layertops(i,:) = misr_dist_model_layertops(j,:) + end if + end do + deallocate(temp_misr_sunlit,temp_misr_zfull,temp_misr_at,temp_misr_dtau) + deallocate(MISR_SWATH_MASK) + else + ! Allocate space for local variables + allocate(misr_boxztop(Npoints,misrIN%Ncolumns), & + misr_boxtau(Npoints,misrIN%Ncolumns), & + misr_dist_model_layertops(Npoints,numMISRHgtBins)) + ! Call simulator + call misr_subcolumn(misrIN%Npoints,misrIN%Ncolumns,misrIN%Nlevels,misrIN%dtau, & + misrIN%zfull,misrIN%at,misrIN%sunlit,misr_boxtau, & + misr_dist_model_layertops,misr_boxztop) + ! Store output (if requested) + if (associated(cospOUT%misr_dist_model_layertops)) then + cospOUT%misr_dist_model_layertops(ij:ik,:) = misr_dist_model_layertops + endif endif endif @@ -848,17 +1298,36 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) calipso_betaperp_tot(calipsoIN%Npoints,calipsoIN%Ncolumns,calipsoIN%Nlevels)) ! Call simulator call lidar_subcolumn(calipsoIN%npoints, calipsoIN%ncolumns, calipsoIN%nlevels, .false., & - calipsoIN%beta_mol, calipsoIN%tau_mol, calipsoIN%betatot, calipsoIN%tautot, & - calipso_beta_mol(:,:), calipso_beta_tot(:,:,:), calipsoIN%betatot_ice, & - calipsoIN%tautot_ice, calipsoIN%betatot_liq, calipsoIN%tautot_liq, & - calipso_betaperp_tot(:,:,:)) - ! Store output (if requested) - if (associated(cospOUT%calipso_beta_mol)) & - cospOUT%calipso_beta_mol(ij:ik,calipsoIN%Nlevels:1:-1) = calipso_beta_mol - if (associated(cospOUT%calipso_beta_tot)) & - cospOUT%calipso_beta_tot(ij:ik,:,calipsoIN%Nlevels:1:-1) = calipso_beta_tot - if (associated(cospOUT%calipso_betaperp_tot)) & - cospOUT%calipso_betaperp_tot(ij:ik,:,:) = calipso_betaperp_tot + calipsoIN%beta_mol, calipsoIN%tau_mol, calipsoIN%betatot, calipsoIN%tautot, & + calipso_beta_mol(:,:), calipso_beta_tot(:,:,:), calipsoIN%betatot_ice, & + calipsoIN%tautot_ice, calipsoIN%betatot_liq, calipsoIN%tautot_liq, & + calipso_betaperp_tot(:,:,:)) + if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + ! Decode outputs from swaths when reading into cospOUT fields + cospOUT%calipso_beta_mol(:,:) = R_UNDEF + cospOUT%calipso_beta_tot(:,:,:) = R_UNDEF + cospOUT%calipso_betaperp_tot(:,:,:) = R_UNDEF + j = 0 + do i=ij,ik ! Index ranges on outputs + if (CALIPSO_SWATH_MASK(i - ij + 1)) then ! Convert back to an index for the swath mask + j = j + 1 + if (associated(cospOUT%calipso_beta_mol)) cospOUT%calipso_beta_mol(i,:) = calipso_beta_mol(j,:) + if (associated(cospOUT%calipso_beta_tot)) cospOUT%calipso_beta_tot(i,:,:) = calipso_beta_tot(j,:,:) + if (associated(cospOUT%calipso_betaperp_tot)) cospOUT%calipso_betaperp_tot(i,:,:) = calipso_betaperp_tot(j,:,:) + end if + end do + deallocate(temp_beta_mol_calipso,temp_tau_mol_calipso,temp_betatot_calipso,temp_tautot_calipso, & + temp_betatot_liq_calipso,temp_tautot_liq_calipso,temp_betatot_ice_calipso,temp_tautot_ice_calipso) + deallocate(CALIPSO_SWATH_MASK) + else ! Proceed normally + ! Store output (if requested) + if (associated(cospOUT%calipso_beta_mol)) & + cospOUT%calipso_beta_mol(ij:ik,calipsoIN%Nlevels:1:-1) = calipso_beta_mol + if (associated(cospOUT%calipso_beta_tot)) & + cospOUT%calipso_beta_tot(ij:ik,:,calipsoIN%Nlevels:1:-1) = calipso_beta_tot + if (associated(cospOUT%calipso_betaperp_tot)) & + cospOUT%calipso_betaperp_tot(ij:ik,:,:) = calipso_betaperp_tot + endif endif ! GROUND LIDAR subcolumn simulator @@ -886,11 +1355,27 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) call lidar_subcolumn(atlidIN%npoints, atlidIN%ncolumns, atlidIN%nlevels,& .false., atlidIN%beta_mol_atlid, atlidIN%tau_mol_atlid, atlidIN%betatot_atlid,& atlidIN%tautot_atlid, atlid_beta_mol(:,:), atlid_beta_tot(:,:,:)) - ! Store output (if requested) - if (associated(cospOUT%atlid_beta_mol)) & - cospOUT%atlid_beta_mol(ij:ik,atlidIN%Nlevels:1:-1) = atlid_beta_mol - if (associated(cospOUT%atlid_beta_tot)) & - cospOUT%atlid_beta_tot(ij:ik,:,atlidIN%Nlevels:1:-1) = atlid_beta_tot + ! Decode outputs from swaths when reading into cospOUT fields + if (cospIN % cospswathsIN(4) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + cospOUT%atlid_beta_mol(:,:) = R_UNDEF + cospOUT%atlid_beta_tot(:,:,:) = R_UNDEF + j = 0 + do i=ij,ik ! Index ranges on outputs + if (ATLID_SWATH_MASK(i - ij + 1)) then ! Convert back to an index for the swath mask + j = j + 1 + if (associated(cospOUT%atlid_beta_mol)) cospOUT%atlid_beta_mol(i,atlidIN%Nlevels:1:-1) = atlid_beta_mol(j,:) + if (associated(cospOUT%atlid_beta_tot)) cospOUT%atlid_beta_tot(i,:,atlidIN%Nlevels:1:-1) = atlid_beta_tot(j,:,:) + end if + end do + deallocate(temp_beta_mol_atlid,temp_betatot_atlid,temp_tau_mol_atlid,temp_tautot_atlid) + deallocate(ATLID_SWATH_MASK) + else + ! Store output (if requested) + if (associated(cospOUT%atlid_beta_mol)) & + cospOUT%atlid_beta_mol(ij:ik,atlidIN%Nlevels:1:-1) = atlid_beta_mol + if (associated(cospOUT%atlid_beta_tot)) & + cospOUT%atlid_beta_tot(ij:ik,:,atlidIN%Nlevels:1:-1) = atlid_beta_tot + end if endif ! PARASOL subcolumn simulator @@ -904,9 +1389,22 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) parasolIN%tautot_S_ice(1:parasolIN%Npoints,icol), & parasolPix_refl(:,icol,1:PARASOL_NREFL)) ! Store output (if requested) - if (associated(cospOUT%parasolPix_refl)) then - cospOUT%parasolPix_refl(ij:ik,icol,1:PARASOL_NREFL) = & - parasolPix_refl(:,icol,1:PARASOL_NREFL) + if (cospIN % cospswathsIN(5) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + cospOUT%parasolPix_refl(:,:,:) = R_UNDEF + j = 0 + do i=ij,ik ! Index ranges on outputs + if (PARASOL_SWATH_MASK(i - ij + 1)) then ! Convert back to an index for the swath mask + j = j + 1 + if (associated(cospOUT%parasolPix_refl)) cospOUT%parasolPix_refl(i,icol,1:PARASOL_NREFL) = parasolPix_refl(j,icol,1:PARASOL_NREFL) + end if + end do + deallocate(temp_tautot_S_liq,temp_tautot_S_ice) + deallocate(PARASOL_SWATH_MASK) + else + if (associated(cospOUT%parasolPix_refl)) then + cospOUT%parasolPix_refl(ij:ik,icol,1:PARASOL_NREFL) = & + parasolPix_refl(:,icol,1:PARASOL_NREFL) + endif endif enddo endif @@ -924,8 +1422,21 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cloudsatIN%g_vol(:,1,:),cloudsatDBze(:,icol,:),cloudsatZe_non(:,icol,:)) enddo ! Store output (if requested) - if (associated(cospOUT%cloudsat_Ze_tot)) then - cospOUT%cloudsat_Ze_tot(ij:ik,:,:) = cloudsatDBZe(:,:,1:cloudsatIN%Nlevels) + if (cospIN % cospswathsIN(6) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + cospOUT%cloudsat_Ze_tot(:,:,:) = R_UNDEF + j = 0 + do i=ij,ik ! Index ranges on outputs + if (CLOUDSAT_SWATH_MASK(i - ij + 1)) then ! Convert back to an index for the swath mask + j = j + 1 + if (associated(cospOUT%cloudsat_Ze_tot)) cospOUT%cloudsat_Ze_tot(i,:,1:cloudsatIN%Nlevels) = cloudsatDBZe(j,:,1:cloudsatIN%Nlevels) + end if + end do + deallocate(temp_hgt_matrix,temp_z_vol_cloudsat,temp_kr_vol_cloudsat,temp_g_vol_cloudsat) + deallocate(CLOUDSAT_SWATH_MASK) + else + if (associated(cospOUT%cloudsat_Ze_tot)) then + cospOUT%cloudsat_Ze_tot(ij:ik,:,:) = cloudsatDBZe(:,:,1:cloudsatIN%Nlevels) + endif endif endif @@ -984,12 +1495,62 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) endif ! Call simulator - call icarus_column(isccpIN%npoints, isccpIN%ncolumns,isccp_boxtau(:,:), & - isccp_boxptop(:,:)/100._wp, isccpIN%sunlit,isccp_boxttop, & - cospOUT%isccp_fq(ij:ik,:,:), & - cospOUT%isccp_meanalbedocld(ij:ik), & - cospOUT%isccp_meanptop(ij:ik),cospOUT%isccp_meantaucld(ij:ik), & - cospOUT%isccp_totalcldarea(ij:ik),cospOUT%isccp_meantb(ij:ik)) + if (cospIN % cospswathsIN(1) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + ! Operate at the masked format. + allocate(temp_isccp_fq(N_ISCCP_SWATHED,numISCCPTauBins,numISCCPPresBins), & + temp_isccp_meanalbedocld(N_ISCCP_SWATHED), & + temp_isccp_meanptop(N_ISCCP_SWATHED), & + temp_isccp_meantaucld(N_ISCCP_SWATHED), & + temp_isccp_totalcldarea(N_ISCCP_SWATHED), & + temp_isccp_meantb(N_ISCCP_SWATHED)) + ! print*,'cospIN%npoints: ',cospIN%npoints + ! print*,'isccpIN%npoints: ',isccpIN%npoints + ! print*,'N_ISCCP_SWATHED: ',N_ISCCP_SWATHED + ! print*,'isccp_boxtau(: ,:): ',isccp_boxtau + ! print*,'isccp_boxptop(: ,:): ',isccp_boxptop + ! print*,'isccpIN%sunlit(: ,:): ',isccpIN%sunlit + ! print*,'isccp_boxttop(: ,:): ',isccp_boxttop + + call icarus_column(isccpIN%npoints, isccpIN%ncolumns,isccp_boxtau(:,:), & + isccp_boxptop(:,:)/100._wp,isccpIN%sunlit,isccp_boxttop(:,:), & + temp_isccp_fq, & + temp_isccp_meanalbedocld, & + temp_isccp_meanptop,temp_isccp_meantaucld, & + temp_isccp_totalcldarea,temp_isccp_meantb) + ! Decode back to the cospOUT shapes + cospOUT%isccp_fq(ij:ik,:,:) = R_UNDEF + cospOUT%isccp_meanalbedocld(ij:ik) = R_UNDEF + cospOUT%isccp_meanptop(ij:ik) = R_UNDEF + cospOUT%isccp_meantaucld(ij:ik) = R_UNDEF + cospOUT%isccp_totalcldarea(ij:ik) = R_UNDEF + cospOUT%isccp_meantb(ij:ik) = R_UNDEF + j = 0 + ! print*,'temp_isccp_totalcldarea: ',temp_isccp_totalcldarea + do i=ij,ik ! Index ranges on outputs + if (ISCCP_SWATH_MASK(i - ij + 1)) then ! Convert back to an index for the swath mask + j = j + 1 + if (associated(cospOUT%isccp_fq)) cospOUT%isccp_fq(i,:,:) = temp_isccp_fq(j,:,:) + if (associated(cospOUT%isccp_meanalbedocld)) cospOUT%isccp_meanalbedocld(i) = temp_isccp_meanalbedocld(j) + if (associated(cospOUT%isccp_meanptop)) cospOUT%isccp_meanptop(i) = temp_isccp_meanptop(j) + if (associated(cospOUT%isccp_meantaucld)) cospOUT%isccp_meantaucld(i) = temp_isccp_meantaucld(j) + if (associated(cospOUT%isccp_totalcldarea)) cospOUT%isccp_totalcldarea(i) = temp_isccp_totalcldarea(j) + if (associated(cospOUT%isccp_meantb)) cospOUT%isccp_meantb(i) = temp_isccp_meantb(j) + end if + end do + deallocate(ISCCP_SWATH_MASK,temp_isccp_fq,temp_isccp_meanalbedocld,temp_isccp_meanptop,temp_isccp_meantaucld,temp_isccp_totalcldarea,temp_isccp_meantb,temp_isccp_sunlit) + ! print*,'cospOUT%isccp_totalcldarea: ',cospOUT%isccp_totalcldarea + else + ! print*,'isccp_boxtau(124:153,:): ',isccp_boxtau(124:153,:) + ! print*,'isccp_boxptop(124:153,:): ',isccp_boxptop(124:153,:) + ! print*,'isccpIN%sunlit(124:153): ',isccpIN%sunlit(124:153) + ! print*,'isccp_boxttop(124:153,:): ',isccp_boxttop(124:153,:) + call icarus_column(isccpIN%npoints, isccpIN%ncolumns,isccp_boxtau(:,:), & + isccp_boxptop(:,:)/100._wp, isccpIN%sunlit,isccp_boxttop(:,:), & + cospOUT%isccp_fq(ij:ik,:,:), & + cospOUT%isccp_meanalbedocld(ij:ik), & + cospOUT%isccp_meanptop(ij:ik),cospOUT%isccp_meantaucld(ij:ik), & + cospOUT%isccp_totalcldarea(ij:ik),cospOUT%isccp_meantb(ij:ik)) + end if cospOUT%isccp_fq(ij:ik,:,:) = cospOUT%isccp_fq(ij:ik,:,7:1:-1) ! Check if there is any value slightly greater than 1 @@ -1985,6 +2546,69 @@ subroutine cosp_cleanUp() deallocate(vgrid_zl,vgrid_zu,vgrid_z,dz) end subroutine cosp_cleanUp + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE compute_orbitmasks + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine compute_orbitmasks(Npoints,Nlocaltimes,localtimes,localtime_widths, & + lat,lon,hour,minute,swath_mask_out) + + ! Inputs + integer,intent(in) :: & + Npoints, & + Nlocaltimes + + real(wp),dimension(Nlocaltimes),intent(in) :: & + localtimes, & + localtime_widths + + real(wp),dimension(Npoints),intent(in) :: & + lat, & + lon, & + hour, & + minute + + ! Output + logical,dimension(Npoints),intent(out) :: & + swath_mask_out ! Mask of reals over all gridcells + + ! Local variables + integer :: i ! iterators + + real(wp),parameter :: & + pi = 4.D0*DATAN(1.D0), & ! yum + radius = 6371.0 ! Earth's radius in km (mean volumetric) + + real(wp),dimension(Npoints,Nlocaltimes) :: & + sat_lon, & ! Central longitude of the instrument. + dlon, & ! distance to satellite longitude in degrees + dx ! distance to satellite longitude in km? + + logical,dimension(Npoints,Nlocaltimes) :: & + swath_mask_all ! Mask of logicals over all local times, gridcells + + ! Iterate over local times + swath_mask_all(:,:) = 0 + do i=1,Nlocaltimes + ! Calculate the central longitude for each gridcell and orbit + sat_lon(:,i) = 15.0 * (localtimes(i) - (hour + minute / 60)) + ! Calculate distance (in degrees) from each grid cell to the satellite central long + dlon(:,i) = mod((lon - sat_lon(:,i) + 180.0), 360.0) - 180.0 + ! calculate distance to satellite in km. Remember to convert to radians for cos/sine calls + dx(:,i) = dlon(:,i) * (pi/180.0) * COS(lat * pi / 180) * radius + ! Determine if a gridcell falls in the swath width + where (abs(dx(:,i))<(localtime_widths(i)*0.5)) + swath_mask_all(:,i) = .true. + end where + end do + + ! Mask is true where values should be calculated + swath_mask_out = ALL( swath_mask_all(:,:),2) ! Compute mask by collapsing the localtimes dimension ! ANY(swath_mask_all,dim=1) + + ! Mask is true where values should be masked to R_UNDEF + ! swath_mask_out = ALL( swath_mask_all(:,:) .eq. .false.,2) ! Compute mask by collapsing the localtimes dimension ! ANY(swath_mask_all,dim=1) + + end subroutine compute_orbitmasks + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_errorCheck !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 345cae9ed8..f19f5d0930 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -648,11 +648,11 @@ END SUBROUTINE DESTROY_RTTOV_CONFIG !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_rttov_simulate - Call subroutines in mod_cosp_rttov to run RTTOV !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - RECURSIVE SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,error, & ! Inputs - bt_total,bt_clear, & ! Brightness Temp Outputs - rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs - refl_total,refl_clear, & ! Reflectance Outputs - debug) + SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,error, & ! Inputs + bt_total,bt_clear, & ! Brightness Temp Outputs + rad_total,rad_clear,rad_cloudy, & ! Radiance Outputs + refl_total,refl_clear, & ! Reflectance Outputs + debug) type(rttov_in),intent(in) :: & rttovIN From 9adad1eac31e97b7f45db17e8837e7d00a5e490f Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 20 Feb 2024 15:59:04 -0700 Subject: [PATCH 109/159] Swathing working for chunked and unchunked input. --- driver/run/cosp2_input_rttov_nl.txt | 35 +- driver/src/cosp2_test.F90 | 100 +-- src/cosp.F90 | 1229 +++++++++++++++++---------- 3 files changed, 807 insertions(+), 557 deletions(-) diff --git a/driver/run/cosp2_input_rttov_nl.txt b/driver/run/cosp2_input_rttov_nl.txt index 2c1c65f518..2c90b744aa 100644 --- a/driver/run/cosp2_input_rttov_nl.txt +++ b/driver/run/cosp2_input_rttov_nl.txt @@ -97,24 +97,21 @@ !-------------- Swathing inputs !---------------------------------------------------------------------------------- N_SWATHS_ISCCP=2, - SWATH_LOCALTIMES_ISCCP=6,18, + SWATH_LOCALTIMES_ISCCP=5.25,18.0, SWATH_WIDTHS_ISCCP=20000,20000, - N_SWATHS_MISR=0, - SWATH_LOCALTIMES_MISR=1,10, - SWATH_WIDTHS_MISR=1000,1200, - N_SWATHS_MODIS=0, - SWATH_LOCALTIMES_MODIS=1,10, - SWATH_WIDTHS_MODIS=1000,1200, - N_SWATHS_CALIPSO=0, - SWATH_LOCALTIMES_CALIPSO=1,10, - SWATH_WIDTHS_CALIPSO=1000,1200, - N_SWATHS_PARASOL=0, - SWATH_LOCALTIMES_PARASOL=1,10, - SWATH_WIDTHS_PARASOL=1000,1200, - N_SWATHS_ClOUDSAT=0, - SWATH_LOCALTIMES_ClOUDSAT=1,10, - SWATH_WIDTHS_ClOUDSAT=1000,1200, - N_SWATHS_ATLID=0, - SWATH_LOCALTIMES_ATLID=1,10, - SWATH_WIDTHS_ATLID=1000,1200, + N_SWATHS_MISR=2, + SWATH_LOCALTIMES_MISR=6.5,18.25, + SWATH_WIDTHS_MISR=20000,20000, + N_SWATHS_MODIS=2, + SWATH_LOCALTIMES_MODIS=5.75,18.5, + SWATH_WIDTHS_MODIS=20000,20000, + N_SWATHS_CSCAL=2, + SWATH_LOCALTIMES_CSCAL=6.75,19.25, + SWATH_WIDTHS_CSCAL=20000,20000, + N_SWATHS_PARASOL=2, + SWATH_LOCALTIMES_PARASOL=6.75,19, + SWATH_WIDTHS_PARASOL=20000,20000, + N_SWATHS_ATLID=2, + SWATH_LOCALTIMES_ATLID=7.25,19.5, + SWATH_WIDTHS_ATLID=20000,20000, / diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index bf527ad206..afd369f098 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -169,24 +169,21 @@ program cosp2_test integer :: N_SWATHS_ISCCP = 0 ! Number of ISCCP swaths integer :: N_SWATHS_MISR = 0 ! Number of MISR swaths integer :: N_SWATHS_MODIS = 0 ! Number of MODIS swaths - integer :: N_SWATHS_CALIPSO = 0 ! Number of CALIPSO swaths integer :: N_SWATHS_PARASOL = 0 ! Number of PARASOL swaths - integer :: N_SWATHS_ClOUDSAT = 0 ! Number of CLOUDSAT swaths + integer :: N_SWATHS_CSCAL = 0 ! Number of CLOUDSAT+CALIPSO swaths integer :: N_SWATHS_ATLID = 0 ! Number of ATLID swaths real(wp),dimension(10),target :: & ! Arbitrary limit of 10 swaths seems reasonable. SWATH_LOCALTIMES_ISCCP, & ! Local time of ISCCP satellite overpasses (hrs GMT) SWATH_LOCALTIMES_MISR, & ! Local time of MISR satellite overpasses (hrs GMT) SWATH_LOCALTIMES_MODIS, & ! Local time of MODIS satellite overpasses (hrs GMT) - SWATH_LOCALTIMES_CALIPSO, & ! Local time of CALIPSO satellite overpasses (hrs GMT) SWATH_LOCALTIMES_PARASOL, & ! Local time of PARASOL satellite overpasses (hrs GMT) - SWATH_LOCALTIMES_ClOUDSAT, & ! Local time of CLOUDSAT satellite overpasses (hrs GMT) + SWATH_LOCALTIMES_CSCAL, & ! Local time of CLOUDSAT+CALIPSO satellite overpasses (hrs GMT) SWATH_LOCALTIMES_ATLID, & ! Local time of ATLID satellite overpasses (hrs GMT) SWATH_WIDTHS_ISCCP, & ! Width in km of ISCCP satellite overpasses SWATH_WIDTHS_MISR, & ! Width in km of MISR satellite overpasses SWATH_WIDTHS_MODIS, & ! Width in km of MODIS satellite overpasses - SWATH_WIDTHS_CALIPSO, & ! Width in km of CALIPSO satellite overpasses SWATH_WIDTHS_PARASOL, & ! Width in km of PARASOL satellite overpasses - SWATH_WIDTHS_ClOUDSAT, & ! Width in km of CLOUDSAT satellite overpasses + SWATH_WIDTHS_CSCAL, & ! Width in km of CLOUDSAT+CALIPSO satellite overpasses SWATH_WIDTHS_ATLID ! Width in km of ATLID satellite overpasses namelist/COSP_INPUT/overlap, isccp_topheight, isccp_topheight_direction, npoints, & @@ -196,10 +193,9 @@ program cosp2_test rttov_Ninstruments, rttov_instrument_namelists, rttov_verbose, & N_SWATHS_ISCCP, SWATH_LOCALTIMES_ISCCP, SWATH_WIDTHS_ISCCP, N_SWATHS_MISR, & SWATH_LOCALTIMES_MISR, SWATH_WIDTHS_MISR, N_SWATHS_MODIS, SWATH_LOCALTIMES_MODIS, & - SWATH_WIDTHS_MODIS, N_SWATHS_CALIPSO, SWATH_LOCALTIMES_CALIPSO, & - SWATH_WIDTHS_CALIPSO, N_SWATHS_PARASOL, SWATH_LOCALTIMES_PARASOL, & - SWATH_WIDTHS_PARASOL, N_SWATHS_ClOUDSAT, SWATH_LOCALTIMES_ClOUDSAT, & - SWATH_WIDTHS_ClOUDSAT, N_SWATHS_ATLID, SWATH_LOCALTIMES_ATLID, SWATH_WIDTHS_ATLID + SWATH_WIDTHS_MODIS, N_SWATHS_PARASOL, SWATH_LOCALTIMES_PARASOL, & + SWATH_WIDTHS_PARASOL, N_SWATHS_CSCAL, SWATH_LOCALTIMES_CSCAL, & + SWATH_WIDTHS_CSCAL, N_SWATHS_ATLID, SWATH_LOCALTIMES_ATLID, SWATH_WIDTHS_ATLID ! Output namelist logical :: Lcfaddbze94,Ldbze94,Latb532,LcfadLidarsr532,Lclcalipso,Lclhcalipso, & @@ -355,28 +351,25 @@ program cosp2_test rttov_instrument_namelists_final(:) = rttov_instrument_namelists(1:rttov_Ninstruments) ! Read orbital swathing inputs into structure: - ! Indexing order is ISCCP, MISR, CALIPSO, ATLID, PARASOL, CLOUDSAT, MODIS + ! Indexing order is ISCCP, MISR, CLOUDSAT-CALIPSO, ATLID, PARASOL, MODIS cospswathsIN(1) % N_inst_swaths = N_SWATHS_ISCCP cospswathsIN(1) % inst_localtimes => SWATH_LOCALTIMES_ISCCP(1:N_SWATHS_ISCCP) cospswathsIN(1) % inst_localtime_widths => SWATH_WIDTHS_ISCCP(1:N_SWATHS_ISCCP) cospswathsIN(2) % N_inst_swaths = N_SWATHS_MISR cospswathsIN(2) % inst_localtimes => SWATH_LOCALTIMES_MISR(1:N_SWATHS_MISR) cospswathsIN(2) % inst_localtime_widths => SWATH_WIDTHS_MISR(1:N_SWATHS_MISR) - cospswathsIN(3) % N_inst_swaths = N_SWATHS_CALIPSO - cospswathsIN(3) % inst_localtimes => SWATH_LOCALTIMES_CALIPSO(1:N_SWATHS_CALIPSO) - cospswathsIN(3) % inst_localtime_widths => SWATH_WIDTHS_CALIPSO(1:N_SWATHS_CALIPSO) + cospswathsIN(3) % N_inst_swaths = N_SWATHS_CSCAL + cospswathsIN(3) % inst_localtimes => SWATH_LOCALTIMES_CSCAL(1:N_SWATHS_CSCAL) + cospswathsIN(3) % inst_localtime_widths => SWATH_WIDTHS_CSCAL(1:N_SWATHS_CSCAL) cospswathsIN(4) % N_inst_swaths = N_SWATHS_ATLID cospswathsIN(4) % inst_localtimes => SWATH_LOCALTIMES_ATLID(1:N_SWATHS_ATLID) cospswathsIN(4) % inst_localtime_widths => SWATH_WIDTHS_ATLID(1:N_SWATHS_ATLID) cospswathsIN(5) % N_inst_swaths = N_SWATHS_PARASOL cospswathsIN(5) % inst_localtimes => SWATH_LOCALTIMES_PARASOL(1:N_SWATHS_PARASOL) cospswathsIN(5) % inst_localtime_widths => SWATH_WIDTHS_PARASOL(1:N_SWATHS_PARASOL) - cospswathsIN(6) % N_inst_swaths = N_SWATHS_CLOUDSAT - cospswathsIN(6) % inst_localtimes => SWATH_LOCALTIMES_CLOUDSAT(1:N_SWATHS_CLOUDSAT) - cospswathsIN(6) % inst_localtime_widths => SWATH_WIDTHS_CLOUDSAT(1:N_SWATHS_CLOUDSAT) - cospswathsIN(7) % N_inst_swaths = N_SWATHS_MODIS - cospswathsIN(7) % inst_localtimes => SWATH_LOCALTIMES_MODIS(1:N_SWATHS_MODIS) - cospswathsIN(7) % inst_localtime_widths => SWATH_WIDTHS_MODIS(1:N_SWATHS_MODIS) + cospswathsIN(6) % N_inst_swaths = N_SWATHS_MODIS + cospswathsIN(6) % inst_localtimes => SWATH_LOCALTIMES_MODIS(1:N_SWATHS_MODIS) + cospswathsIN(6) % inst_localtime_widths => SWATH_WIDTHS_MODIS(1:N_SWATHS_MODIS) !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Read in sample input data. @@ -531,7 +524,11 @@ program cosp2_test ! Break COSP up into pieces and loop over each COSP 'chunk'. ! nChunks = # Points to Process (nPoints) / # Points per COSP iteration (nPoints_it) !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - nChunks = nPoints/nPoints_it+1 + if (MOD(nPoints,nPoints_it) .eq. 0) then ! JKS - do not run an extra iteration if Npoints_it divides Npoints cleanly + nChunks = Npoints/Npoints_it + else + nChunks = nPoints/nPoints_it+1 + endif if (nPoints .eq. nPoints_it) nChunks = 1 do iChunk=1,nChunks !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -727,7 +724,6 @@ program cosp2_test call cpu_time(driver_time(7)) end do - print*,'Time to read in data: ',driver_time(2)-driver_time(1) print*,'Time to initialize: ',driver_time(3)-driver_time(2) print*,'Time to construct types: ',driver_time(4)-driver_time(3) @@ -1162,66 +1158,6 @@ subroutine subsample_and_optics(nPoints, nLevels, nColumns, nHydro, overlap, use endif end subroutine subsample_and_optics - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE compute_orbitmasks - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine compute_orbitmasks(Npoints,Nlocaltimes,localtimes,localtime_widths, & - lat,lon,hour,minute,swath_mask_out) - - ! Inputs - integer,intent(in) :: & - Npoints, & - Nlocaltimes - - real(wp),dimension(Nlocaltimes),intent(in) :: & - localtimes, & - localtime_widths - - real(wp),dimension(Npoints),intent(in) :: & - lat, & - lon, & - hour, & - minute - - ! Output - logical,dimension(Npoints),intent(out) :: & - swath_mask_out ! Mask of reals over all gridcells - - ! Local variables - integer :: i ! iterators - - real(wp),parameter :: & - pi = 4.D0*DATAN(1.D0), & ! yum - radius = 6371.0 ! Earth's radius in km (mean volumetric) - - real(wp),dimension(Npoints,Nlocaltimes) :: & - sat_lon, & ! Central longitude of the instrument. - dlon, & ! distance to satellite longitude in degrees - dx ! distance to satellite longitude in km? - - logical,dimension(Npoints,Nlocaltimes) :: & - swath_mask_all ! Mask of logicals over all local times, gridcells - - ! Iterate over local times - swath_mask_all(:,:) = 0 - do i=1,Nlocaltimes - ! Calculate the central longitude for each gridcell and orbit - sat_lon(:,i) = 15.0 * (localtimes(i) - (hour + minute / 60)) - ! Calculate distance (in degrees) from each grid cell to the satellite central long - dlon(:,i) = mod((lon - sat_lon(:,i) + 180.0), 360.0) - 180.0 - ! calculate distance to satellite in km. Remember to convert to radians for cos/sine calls - dx(:,i) = dlon(:,i) * (pi/180.0) * COS(lat * pi / 180) * radius - ! Determine if a gridcell falls in the swath width - where (abs(dx(:,i))<(localtime_widths(i)*0.5)) - swath_mask_all(:,i) = .true. - end where - end do - - ! Mask is true where values should be masked to R_UNDEF - swath_mask_out = ALL( swath_mask_all(:,:) .eq. .false.,2) ! Compute mask by collapsing the localtimes dimension ! ANY(swath_mask_all,dim=1) - - end subroutine compute_orbitmasks - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE construct_cospIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/cosp.F90 b/src/cosp.F90 index 14c053516b..5ded6be8d4 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -433,18 +433,24 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) logical,dimension(:),allocatable :: & ! Mask of reals over all local times ISCCP_SWATH_MASK, & MISR_SWATH_MASK, & - CALIPSO_SWATH_MASK, & - CLOUDSAT_SWATH_MASK, & + CSCAL_SWATH_MASK, & MODIS_SWATH_MASK, & PARASOL_SWATH_MASK, & - ATLID_SWATH_MASK - + ATLID_SWATH_MASK, & + MODIS_CSCAL_SWATH_MASK + integer,dimension(:),allocatable :: & ! Arrays containing the indices of the swath masks + ISCCP_MASK_INDICES, & + MISR_MASK_INDICES, & + CSCAL_MASK_INDICES, & + MODIS_MASK_INDICES, & + PARASOL_MASK_INDICES, & + ATLID_MASK_INDICES, & + MODIS_CSCAL_MASK_INDICES integer :: j integer,target :: & ! Number of gridcell points to computer on after swathing N_ISCCP_SWATHED, & N_MISR_SWATHED, & - N_CALIPSO_SWATHED, & - N_CLOUDSAT_SWATHED, & + N_CSCAL_SWATHED, & N_MODIS_SWATHED, & N_PARASOL_SWATHED, & N_ATLID_SWATHED @@ -457,7 +463,9 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) temp_isccp_meanptop, & temp_isccp_meantaucld, & temp_isccp_totalcldarea, & - temp_isccp_meantb + temp_isccp_meantb, & + temp_modis_localtimes, & + temp_modis_localtime_widths real(wp),dimension(:,:),target,allocatable :: & temp_isccp_qv, & temp_isccp_at, & @@ -471,46 +479,79 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! MISR swathing variables integer,dimension(:),target,allocatable :: & temp_misr_sunlit + real(wp),dimension(:),target,allocatable :: & + temp_misr_cldarea, & + temp_misr_meanztop real(wp),dimension(:,:),target,allocatable :: & temp_misr_zfull, & temp_misr_at real(wp),dimension(:,:,:),target,allocatable :: & - temp_misr_dtau + temp_misr_dtau, & + temp_misr_fq ! CALIPSO swathing variables + real(wp),dimension(:),target,allocatable :: & + temp_calipso_cldthinemis real(wp),dimension(:,:),target,allocatable :: & temp_beta_mol_calipso, & - temp_tau_mol_calipso + temp_tau_mol_calipso, & + temp_calipso_lidarcld, & + temp_calipso_cldlayer, & + temp_calipso_cldtype, & + temp_calipso_cldtypetemp, & + temp_calipso_cldtypemeanz,& + temp_calipso_cldtypemeanzse real(wp),dimension(:,:,:),target,allocatable :: & temp_betatot_calipso, & temp_tautot_calipso, & temp_betatot_liq_calipso, & temp_tautot_liq_calipso, & temp_betatot_ice_calipso, & - temp_tautot_ice_calipso + temp_tautot_ice_calipso, & + temp_calipso_cfad_sr, & + temp_calipso_lidarcldphase, & + temp_calipso_lidarcldtype, & + temp_calipso_cldlayerphase, & + temp_calipso_lidarcldtmp ! ATLID swathing variables real(wp),dimension(:,:),target,allocatable :: & temp_beta_mol_atlid, & - temp_tau_mol_atlid + temp_tau_mol_atlid, & + temp_atlid_lidarcld, & + temp_atlid_cldlayer real(wp),dimension(:,:,:),target,allocatable :: & temp_betatot_atlid, & - temp_tautot_atlid + temp_tautot_atlid, & + temp_atlid_cfad_sr ! PARASOL swathing variables real(wp),dimension(:,:),target,allocatable :: & temp_tautot_S_liq, & - temp_tautot_S_ice + temp_tautot_S_ice, & + temp_parasolGrid_refl ! CLOUDSAT swathing variables + real(wp),dimension(:),target,allocatable :: & + temp_cloudsat_pia real(wp),dimension(:,:),target,allocatable :: & - temp_hgt_matrix + temp_hgt_matrix, & + temp_cloudsat_precip_cover real(wp),dimension(:,:,:),target,allocatable :: & temp_z_vol_cloudsat, & temp_kr_vol_cloudsat, & - temp_g_vol_cloudsat + temp_g_vol_cloudsat, & + temp_cloudsat_cfad_ze ! MODIS swathing variables. real(wp),dimension(:,:,:),target,allocatable :: & temp_modis_liqFrac, & temp_modis_tau, & temp_modis_g, & temp_modis_w0 + real(wp),dimension(:,:),allocatable :: & + modis_boxptop, & + modis_boxttop, & + modis_boxtau + integer,dimension(:,:),allocatable :: & + modisLEVMATCH + real(wp),dimension(:),target,allocatable :: & + modis_meantbclr ! Initialize error reporting for output cosp_simulator(:)='' @@ -750,7 +791,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) print*,'cospIN % cospswathsIN(1) % N_inst_swaths: ',cospIN % cospswathsIN(1) % N_inst_swaths print*,'cospIN % cospswathsIN(1) % inst_localtime_widths: ',cospIN % cospswathsIN(1) % inst_localtime_widths print*,'cospIN % cospswathsIN(1) % inst_localtimes: ',cospIN % cospswathsIN(1) % inst_localtimes - ! Indexing order is ISCCP, MISR, CALIPSO, ATLID, PARASOL, CLOUDSAT, MODIS + ! Indexing order is ISCCP, MISR, CLOUDSAT-CALIPSO, ATLID, PARASOL, MODIS if (Lisccp_subcolumn .or. Lmodis_subcolumn) then if (cospIN % cospswathsIN(1) % N_inst_swaths .gt. 0) then @@ -762,36 +803,30 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospIN % cospswathsIN(1) % inst_localtime_widths, & cospgridIN%lat, cospgridIN%lon, & cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute - ISCCP_SWATH_MASK) ! Output: logical mask array - - N_ISCCP_SWATHED = COUNT(ISCCP_SWATH_MASK) ! number of points to actually operate on - - print*,'N_ISCCP_SWATHED: ',N_ISCCP_SWATHED + ISCCP_SWATH_MASK,N_ISCCP_SWATHED) ! Output: logical mask array + isccpIN%Npoints => N_ISCCP_SWATHED + ISCCP_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = ISCCP_SWATH_MASK) + print*,'isccpIN%Npoints: ',isccpIN%Npoints print*,'ISCCP_SWATH_MASK: ',ISCCP_SWATH_MASK ! Allocate swathed arrays. - allocate(temp_isccp_skt(N_ISCCP_SWATHED),temp_isccp_qv(N_ISCCP_SWATHED,cospIN%Nlevels),temp_isccp_at(N_ISCCP_SWATHED,cospIN%Nlevels), & - temp_isccp_frac_out(N_ISCCP_SWATHED,cospIN%Ncolumns,cospIN%Nlevels),temp_isccp_tau_067(N_ISCCP_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & - temp_isccp_emiss_11(N_ISCCP_SWATHED,cospIN%Ncolumns,cospIN%Nlevels),temp_isccp_phalf(N_ISCCP_SWATHED,cospIN%Nlevels+1), & - temp_isccp_pfull(N_ISCCP_SWATHED,cospIN%Nlevels),temp_isccp_sunlit(N_ISCCP_SWATHED)) - + allocate(temp_isccp_skt(isccpIN%Npoints),temp_isccp_qv(isccpIN%Npoints,cospIN%Nlevels),temp_isccp_at(isccpIN%Npoints,cospIN%Nlevels), & + temp_isccp_frac_out(isccpIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels),temp_isccp_tau_067(isccpIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_isccp_emiss_11(isccpIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels),temp_isccp_phalf(isccpIN%Npoints,cospIN%Nlevels+1), & + temp_isccp_pfull(isccpIN%Npoints,cospIN%Nlevels),temp_isccp_sunlit(isccpIN%Npoints)) ! Encode step: Read only appropriate values into the new temp arrays. - j = 0 ! Initialize input - do i=1,Npoints - if (ISCCP_SWATH_MASK(i)) then - j = j + 1 ! Increment first - temp_isccp_skt(j) = cospgridIN%skt(i) - temp_isccp_qv(j,:) = cospgridIN%qv(i,:) - temp_isccp_at(j,:) = cospgridIN%at(i,:) - temp_isccp_frac_out(j,:,:) = cospIN%frac_out(i,:,:) - temp_isccp_tau_067(j,:,:) = cospIN%tau_067(i,:,:) - temp_isccp_emiss_11(j,:,:) = cospIN%emiss_11(i,:,:) - temp_isccp_phalf(j,:) = cospgridIN%phalf(i,:) - temp_isccp_pfull(j,:) = cospgridIN%pfull(i,:) - temp_isccp_sunlit(j) = cospgridIN%sunlit(i) - end if - end do - - isccpIN%Npoints => N_ISCCP_SWATHED + temp_isccp_skt(:) = cospgridIN%skt(int(ISCCP_MASK_INDICES)) + temp_isccp_qv(:,:) = cospgridIN%qv(int(ISCCP_MASK_INDICES),:) + temp_isccp_at(:,:) = cospgridIN%at(int(ISCCP_MASK_INDICES),:) + temp_isccp_frac_out(:,:,:) = cospIN%frac_out(int(ISCCP_MASK_INDICES),:,:) + temp_isccp_tau_067(:,:,:) = cospIN%tau_067(int(ISCCP_MASK_INDICES),:,:) + temp_isccp_emiss_11(:,:,:) = cospIN%emiss_11(int(ISCCP_MASK_INDICES),:,:) + temp_isccp_phalf(:,:) = cospgridIN%phalf(int(ISCCP_MASK_INDICES),:) + temp_isccp_pfull(:,:) = cospgridIN%pfull(int(ISCCP_MASK_INDICES),:) + temp_isccp_sunlit(:) = cospgridIN%sunlit(int(ISCCP_MASK_INDICES)) + + ! print*,'int(ISCCP_MASK_INDICES): ',int(ISCCP_MASK_INDICES) + ! print*,'temp_isccp_sunlit: ',temp_isccp_sunlit + ! print*,'cospgridIN%sunlit: ',cospgridIN%sunlit isccpIN%Ncolumns => cospIN%Ncolumns isccpIN%Nlevels => cospIN%Nlevels isccpIN%emsfc_lw => cospIN%emsfc_lw @@ -823,6 +858,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (Lmisr_subcolumn) then if (cospIN % cospswathsIN(2) % N_inst_swaths .gt. 0) then + print*,'MISR SWATHING' allocate(MISR_SWATH_MASK(Npoints)) ! Do swathing to figure out which cells to simulate on call compute_orbitmasks(Npoints, & @@ -831,28 +867,22 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospIN % cospswathsIN(2) % inst_localtime_widths, & cospgridIN%lat, cospgridIN%lon, & cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute - MISR_SWATH_MASK) ! Output: logical mask array - - N_MISR_SWATHED = COUNT(MISR_SWATH_MASK) ! number of points to actually operate on - + MISR_SWATH_MASK,N_MISR_SWATHED) ! Output: logical mask array + misrIN%Npoints => N_MISR_SWATHED + MISR_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = MISR_SWATH_MASK) + print*,'misrIN%Npoints: ',misrIN%Npoints + print*,'MISR_SWATH_MASK: ',MISR_SWATH_MASK ! Allocate swathed arrays. - allocate(temp_misr_dtau(N_MISR_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & - temp_misr_sunlit(N_MISR_SWATHED), & - temp_misr_zfull(N_MISR_SWATHED,cospIN%Nlevels), & - temp_misr_at(N_MISR_SWATHED,cospIN%Nlevels)) - + allocate(temp_misr_dtau(misrIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_misr_sunlit(misrIN%Npoints), & + temp_misr_zfull(misrIN%Npoints,cospIN%Nlevels), & + temp_misr_at(misrIN%Npoints,cospIN%Nlevels)) ! Encode step: Read only appropriate values into the new temp arrays. - j = 0 ! Initialize input - do i=1,Npoints - if (MISR_SWATH_MASK(i)) then - j = j + 1 ! Increment first - temp_misr_dtau(j,:,:) = cospIN%tau_067(i,:,:) - temp_misr_at(j,:) = cospgridIN%at(i,:) - temp_misr_zfull(j,:) = cospgridIN%hgt_matrix(i,:) - temp_misr_sunlit(j) = cospgridIN%sunlit(i) - end if - end do - misrIN%Npoints => N_MISR_SWATHED + temp_misr_dtau(:,:,:) = cospIN%tau_067(int(MISR_MASK_INDICES),:,:) + temp_misr_at(:,:) = cospgridIN%at(int(MISR_MASK_INDICES),:) + temp_misr_zfull(:,:) = cospgridIN%hgt_matrix(int(MISR_MASK_INDICES),:) + temp_misr_sunlit(:) = cospgridIN%sunlit(int(MISR_MASK_INDICES)) + misrIN%Ncolumns => cospIN%Ncolumns misrIN%Nlevels => cospIN%Nlevels misrIN%dtau => temp_misr_dtau @@ -871,8 +901,9 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) endif if (Lcalipso_subcolumn) then - if (cospIN % cospswathsIN(1) % N_inst_swaths .gt. 0) then - allocate(CALIPSO_SWATH_MASK(Npoints)) + if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then + print*,'CALIPSO SWATHING' + allocate(CSCAL_SWATH_MASK(Npoints)) ! Do swathing to figure out which cells to simulate on call compute_orbitmasks(Npoints, & cospIN % cospswathsIN(3) % N_inst_swaths, & @@ -880,43 +911,39 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospIN % cospswathsIN(3) % inst_localtime_widths, & cospgridIN%lat, cospgridIN%lon, & cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute - CALIPSO_SWATH_MASK) ! Output: logical mask array - N_CALIPSO_SWATHED = COUNT(CALIPSO_SWATH_MASK) ! number of points to actually operate on + CSCAL_SWATH_MASK, N_CSCAL_SWATHED) ! Output: logical mask array + calipsoIN%Npoints => N_CSCAL_SWATHED + CSCAL_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = CSCAL_SWATH_MASK) + print*,'calipsoIN%Npoints: ',calipsoIN%Npoints + print*,'CSCAL_SWATH_MASK: ',CSCAL_SWATH_MASK ! Allocate swathed arrays. - allocate(temp_beta_mol_calipso(N_CALIPSO_SWATHED,cospIN%Nlevels), & - temp_tau_mol_calipso(N_CALIPSO_SWATHED,cospIN%Nlevels), & - temp_betatot_calipso(N_CALIPSO_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & - temp_tautot_calipso(N_CALIPSO_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & - temp_betatot_liq_calipso(N_CALIPSO_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & - temp_tautot_liq_calipso(N_CALIPSO_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & - temp_betatot_ice_calipso(N_CALIPSO_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & - temp_tautot_ice_calipso(N_CALIPSO_SWATHED,cospIN%Ncolumns,cospIN%Nlevels)) + allocate(temp_beta_mol_calipso(calipsoIN%Npoints,cospIN%Nlevels), & + temp_tau_mol_calipso(calipsoIN%Npoints,cospIN%Nlevels), & + temp_betatot_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_tautot_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_betatot_liq_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_tautot_liq_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_betatot_ice_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_tautot_ice_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels)) ! Encode step: Read only appropriate values into the new temp arrays. - j = 0 ! Initialize input - do i=1,Npoints - if (CALIPSO_SWATH_MASK(i)) then - j = j + 1 - temp_beta_mol_calipso(j,:) = cospIN%beta_mol_calipso(i,:) - temp_tau_mol_calipso(j,:) = cospIN%tau_mol_calipso(i,:) - temp_betatot_calipso(j,:,:) = cospIN%betatot_calipso(i,:,:) - temp_tautot_calipso(j,:,:) = cospIN%tautot_calipso(i,:,:) - temp_betatot_liq_calipso(j,:,:) = cospIN%betatot_liq_calipso(i,:,:) - temp_tautot_liq_calipso(j,:,:) = cospIN%tautot_liq_calipso(i,:,:) - temp_betatot_ice_calipso(j,:,:) = cospIN%betatot_ice_calipso(i,:,:) - temp_tautot_ice_calipso(j,:,:) = cospIN%tautot_ice_calipso(i,:,:) - end if - end do - calipsoIN%Npoints => N_CALIPSO_SWATHED + temp_beta_mol_calipso(:,:) = cospIN%beta_mol_calipso(int(CSCAL_MASK_INDICES),:) + temp_tau_mol_calipso(:,:) = cospIN%tau_mol_calipso(int(CSCAL_MASK_INDICES),:) + temp_betatot_calipso(:,:,:) = cospIN%betatot_calipso(int(CSCAL_MASK_INDICES),:,:) + temp_tautot_calipso(:,:,:) = cospIN%tautot_calipso(int(CSCAL_MASK_INDICES),:,:) + temp_betatot_liq_calipso(:,:,:) = cospIN%betatot_liq_calipso(int(CSCAL_MASK_INDICES),:,:) + temp_tautot_liq_calipso(:,:,:) = cospIN%tautot_liq_calipso(int(CSCAL_MASK_INDICES),:,:) + temp_betatot_ice_calipso(:,:,:) = cospIN%betatot_ice_calipso(int(CSCAL_MASK_INDICES),:,:) + temp_tautot_ice_calipso(:,:,:) = cospIN%tautot_ice_calipso(int(CSCAL_MASK_INDICES),:,:) calipsoIN%Ncolumns => cospIN%Ncolumns calipsoIN%Nlevels => cospIN%Nlevels - calipsoIN%beta_mol => cospIN%beta_mol_calipso - calipsoIN%betatot => cospIN%betatot_calipso - calipsoIN%betatot_liq => cospIN%betatot_liq_calipso - calipsoIN%betatot_ice => cospIN%betatot_ice_calipso - calipsoIN%tau_mol => cospIN%tau_mol_calipso - calipsoIN%tautot => cospIN%tautot_calipso - calipsoIN%tautot_liq => cospIN%tautot_liq_calipso - calipsoIN%tautot_ice => cospIN%tautot_ice_calipso + calipsoIN%beta_mol => temp_beta_mol_calipso + calipsoIN%betatot => temp_betatot_calipso + calipsoIN%betatot_liq => temp_betatot_liq_calipso + calipsoIN%betatot_ice => temp_betatot_ice_calipso + calipsoIN%tau_mol => temp_tau_mol_calipso + calipsoIN%tautot => temp_tautot_calipso + calipsoIN%tautot_liq => temp_tautot_liq_calipso + calipsoIN%tautot_ice => temp_tautot_ice_calipso else calipsoIN%Npoints => Npoints calipsoIN%Ncolumns => cospIN%Ncolumns @@ -944,6 +971,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (Latlid_subcolumn) then if (cospIN % cospswathsIN(4) % N_inst_swaths .gt. 0) then + print*,'ATLID SWATHING' allocate(ATLID_SWATH_MASK(Npoints)) ! Do swathing to figure out which cells to simulate on call compute_orbitmasks(Npoints, & @@ -952,26 +980,21 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospIN % cospswathsIN(4) % inst_localtime_widths, & cospgridIN%lat, cospgridIN%lon, & cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute - ATLID_SWATH_MASK) ! Output: logical mask array - - N_ATLID_SWATHED = COUNT(ATLID_SWATH_MASK) ! number of points to actually operate on + ATLID_SWATH_MASK, N_ATLID_SWATHED) ! Output: logical mask array + atlidIN%Npoints => N_ATLID_SWATHED + ATLID_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = ATLID_SWATH_MASK) + print*,'atlidIN%Npoints: ',atlidIN%Npoints + print*,'ATLID_SWATH_MASK: ',ATLID_SWATH_MASK ! Allocate swathed arrays. - allocate(temp_beta_mol_atlid(N_ATLID_SWATHED,cospIN%Nlevels), & - temp_betatot_atlid(N_ATLID_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & - temp_tau_mol_atlid(N_ATLID_SWATHED,cospIN%Nlevels), & - temp_tautot_atlid(N_ATLID_SWATHED,cospIN%Ncolumns,cospIN%Nlevels)) + allocate(temp_beta_mol_atlid(atlidIN%Npoints,cospIN%Nlevels), & + temp_betatot_atlid(atlidIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_tau_mol_atlid(atlidIN%Npoints,cospIN%Nlevels), & + temp_tautot_atlid(atlidIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels)) ! Encode step: Read only appropriate values into the new temp arrays. - j = 0 ! Initialize input - do i=1,Npoints - if (ATLID_SWATH_MASK(i)) then - j = j + 1 - temp_beta_mol_atlid(j,:) = cospIN%beta_mol_atlid(i,:) - temp_tau_mol_atlid(j,:) = cospIN%tau_mol_atlid(i,:) - temp_betatot_atlid(j,:,:) = cospIN%betatot_atlid(i,:,:) - temp_tautot_atlid(j,:,:) = cospIN%tautot_atlid(i,:,:) - end if - end do - atlidIN%Npoints => N_ATLID_SWATHED + temp_beta_mol_atlid(:,:) = cospIN%beta_mol_atlid(int(ATLID_MASK_INDICES),:) + temp_tau_mol_atlid(:,:) = cospIN%tau_mol_atlid(int(ATLID_MASK_INDICES),:) + temp_betatot_atlid(:,:,:) = cospIN%betatot_atlid(int(ATLID_MASK_INDICES),:,:) + temp_tautot_atlid(:,:,:) = cospIN%tautot_atlid(int(ATLID_MASK_INDICES),:,:) atlidIN%Ncolumns => cospIN%Ncolumns atlidIN%Nlevels => cospIN%Nlevels atlidIN%beta_mol_atlid => temp_beta_mol_atlid @@ -991,6 +1014,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (Lparasol_subcolumn) then if (cospIN % cospswathsIN(5) % N_inst_swaths .gt. 0) then + print*,'PARASOL SWATHING' allocate(PARASOL_SWATH_MASK(Npoints)) ! Do swathing to figure out which cells to simulate on call compute_orbitmasks(Npoints, & @@ -999,21 +1023,17 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospIN % cospswathsIN(5) % inst_localtime_widths, & cospgridIN%lat, cospgridIN%lon, & cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute - PARASOL_SWATH_MASK) ! Output: logical mask array - N_PARASOL_SWATHED = COUNT(PARASOL_SWATH_MASK) ! number of points to actually operate on - ! Allocate swathed arrays. - allocate(temp_tautot_S_liq(N_PARASOL_SWATHED,cospIN%Ncolumns), & - temp_tautot_S_ice(N_PARASOL_SWATHED,cospIN%Ncolumns)) - ! Encode step: Read only appropriate values into the new temp arrays. - j = 0 ! Initialize input - do i=1,Npoints - if (PARASOL_SWATH_MASK(i)) then - j = j + 1 - temp_tautot_S_liq(j,:) = cospIN%tautot_S_liq(i,:) - temp_tautot_S_ice(j,:) = cospIN%tautot_S_ice(i,:) - end if - end do + PARASOL_SWATH_MASK, N_PARASOL_SWATHED) ! Output: logical mask array parasolIN%Npoints => N_PARASOL_SWATHED + PARASOL_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = PARASOL_SWATH_MASK) + print*,'parasolIN%Npoints: ',parasolIN%Npoints + print*,'PARASOL_SWATH_MASK: ',PARASOL_SWATH_MASK + ! Allocate swathed arrays. + allocate(temp_tautot_S_liq(parasolIN%Npoints,cospIN%Ncolumns), & + temp_tautot_S_ice(parasolIN%Npoints,cospIN%Ncolumns)) + ! Encode step: Read only appropriate values into the new temp arrays. + temp_tautot_S_liq(:,:) = cospIN%tautot_S_liq(int(PARASOL_MASK_INDICES),:) + temp_tautot_S_ice(:,:) = cospIN%tautot_S_ice(int(PARASOL_MASK_INDICES),:) parasolIN%Nlevels => cospIN%Nlevels parasolIN%Ncolumns => cospIN%Ncolumns parasolIN%Nrefl => cospIN%Nrefl @@ -1030,41 +1050,44 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) endif if (Lcloudsat_subcolumn) then - if (cospIN % cospswathsIN(6) % N_inst_swaths .gt. 0) then - allocate(CLOUDSAT_SWATH_MASK(Npoints)) - ! Do swathing to figure out which cells to simulate on - call compute_orbitmasks(Npoints, & - cospIN % cospswathsIN(6) % N_inst_swaths, & - cospIN % cospswathsIN(6) % inst_localtimes, & - cospIN % cospswathsIN(6) % inst_localtime_widths, & - cospgridIN%lat, cospgridIN%lon, & - cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute - CLOUDSAT_SWATH_MASK) ! Output: logical mask array - N_CLOUDSAT_SWATHED = COUNT(CLOUDSAT_SWATH_MASK) ! number of points to actually operate on + if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then + print*,'CLOUDSAT SWATHING' + if (.not. allocated(CSCAL_SWATH_MASK)) then + allocate(CSCAL_SWATH_MASK(Npoints)) + ! Do swathing to figure out which cells to simulate on + call compute_orbitmasks(Npoints, & + cospIN % cospswathsIN(3) % N_inst_swaths, & + cospIN % cospswathsIN(3) % inst_localtimes, & + cospIN % cospswathsIN(3) % inst_localtime_widths, & + cospgridIN%lat, cospgridIN%lon, & + cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute + CSCAL_SWATH_MASK, N_CSCAL_SWATHED) ! Output: logical mask array + cloudsatIN%Npoints => N_CSCAL_SWATHED + if (.not. allocated(CSCAL_MASK_INDICES)) allocate(CSCAL_MASK_INDICES(cloudsatIN%Npoints)) + CSCAL_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = CSCAL_SWATH_MASK) + else + cloudsatIN%Npoints => N_CSCAL_SWATHED + end if + print*,'cloudsatIN%Npoints: ',cloudsatIN%Npoints + print*,'CSCAL_SWATH_MASK: ',CSCAL_SWATH_MASK ! Allocate swathed arrays. - allocate(temp_z_vol_cloudsat(N_CLOUDSAT_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & - temp_kr_vol_cloudsat(N_CLOUDSAT_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & - temp_g_vol_cloudsat(N_CLOUDSAT_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & - temp_hgt_matrix(N_CLOUDSAT_SWATHED,cospIN%Nlevels)) + allocate(temp_z_vol_cloudsat(cloudsatIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_kr_vol_cloudsat(cloudsatIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_g_vol_cloudsat(cloudsatIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_hgt_matrix(cloudsatIN%Npoints,cospIN%Nlevels)) ! Encode step: Read only appropriate values into the new temp arrays. - j = 0 ! Initialize input - do i=1,Npoints - if (CLOUDSAT_SWATH_MASK(i)) then - j = j + 1 - temp_z_vol_cloudsat(j,:,:) = cospIN%z_vol_cloudsat(i,:,:) - temp_kr_vol_cloudsat(j,:,:) = cospIN%kr_vol_cloudsat(i,:,:) - temp_g_vol_cloudsat(j,:,:) = cospIN%g_vol_cloudsat(i,:,:) - temp_hgt_matrix(j,:) = cospgridIN%hgt_matrix(i,:) - end if - end do - cloudsatIN%Npoints => N_CLOUDSAT_SWATHED + temp_z_vol_cloudsat = cospIN%z_vol_cloudsat(int(CSCAL_MASK_INDICES),:,:) + temp_kr_vol_cloudsat = cospIN%kr_vol_cloudsat(int(CSCAL_MASK_INDICES),:,:) + temp_g_vol_cloudsat = cospIN%g_vol_cloudsat(int(CSCAL_MASK_INDICES),:,:) + temp_hgt_matrix = cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES),:) + ! Reassign swathed values. cloudsatIN%Nlevels => cospIN%Nlevels cloudsatIN%Ncolumns => cospIN%Ncolumns cloudsatIN%z_vol => temp_z_vol_cloudsat cloudsatIN%kr_vol => temp_kr_vol_cloudsat cloudsatIN%g_vol => temp_g_vol_cloudsat cloudsatIN%rcfg => cospIN%rcfg_cloudsat - cloudsatIN%hgt_matrix => temp_hgt_matrix + cloudsatIN%hgt_matrix => temp_hgt_matrix else cloudsatIN%Npoints => Npoints cloudsatIN%Nlevels => cospIN%Nlevels @@ -1078,47 +1101,48 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) endif if (Lmodis_subcolumn) then - if (cospIN % cospswathsIN(7) % N_inst_swaths .gt. 0) then + if (cospIN % cospswathsIN(6) % N_inst_swaths .gt. 0) then + print*,'MODIS SWATHING' allocate(MODIS_SWATH_MASK(Npoints)) - ! Do swathing to figure out which cells to simulate on + ! ! Do swathing to figure out which cells to simulate on call compute_orbitmasks(Npoints, & - cospIN % cospswathsIN(7) % N_inst_swaths, & - cospIN % cospswathsIN(7) % inst_localtimes, & - cospIN % cospswathsIN(7) % inst_localtime_widths, & + cospIN % cospswathsIN(6) % N_inst_swaths, & + cospIN % cospswathsIN(6) % inst_localtimes, & + cospIN % cospswathsIN(6) % inst_localtime_widths, & cospgridIN%lat, cospgridIN%lon, & cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute - MODIS_SWATH_MASK) ! Output: logical mask array - N_MODIS_SWATHED = COUNT(MODIS_SWATH_MASK) ! number of points to actually operate on - ! Allocate swathed arrays. - allocate(temp_modis_liqFrac(N_MODIS_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & - temp_modis_tau(N_MODIS_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & - temp_modis_g(N_MODIS_SWATHED,cospIN%Ncolumns,cospIN%Nlevels), & - temp_modis_w0(N_MODIS_SWATHED,cospIN%Ncolumns,cospIN%Nlevels)) - ! Encode step: Read only appropriate values into the new temp arrays. - j = 0 ! Initialize input - do i=1,Npoints - if (MODIS_SWATH_MASK(i)) then - j = j + 1 - temp_modis_liqFrac(j,:,:) = cospIN%fracLiq(i,:,:) - temp_modis_tau(j,:,:) = cospIN%tau_067(i,:,:) - temp_modis_g(j,:,:) = cospIN%asym(i,:,:) - temp_modis_w0(j,:,:) = cospIN%ss_alb(i,:,:) - end if - end do - modisIN%Npoints => N_MODIS_SWATHED + MODIS_SWATH_MASK, N_MODIS_SWATHED) ! Output: logical mask array + + ! Operate a little differently with MODIS because there is already some swathing at play. + ! modisIN is over all variables rather than just swathed variables modisIN%Ncolumns => cospIN%Ncolumns modisIN%Nlevels => cospIN%Nlevels - modisIN%liqFrac => temp_modis_liqFrac - modisIN%tau => temp_modis_tau - modisIN%g => temp_modis_g - modisIN%w0 => temp_modis_w0 - modisIN%Nsunlit = count(cospgridIN%sunlit > 0 .and. MODIS_SWATH_MASK) + modisIN%Npoints => Npoints + modisIN%liqFrac => cospIN%fracLiq + modisIN%tau => cospIN%tau_067 + modisIN%g => cospIN%asym + modisIN%w0 => cospIN%ss_alb + + allocate(modisIN%pres(modisIN%Npoints,cospIN%Nlevels+1)) ! Moving this outside of the sunlit statements for consistency with the other variables + modisIN%pres = cospgridIN%phalf + modisIN%Nsunlit = count((cospgridIN%sunlit > 0) .and. MODIS_SWATH_MASK) ! Sunlit mask and indices array will just include swathing as well if (modisIN%Nsunlit .gt. 0) then - allocate(modisIN%sunlit(modisIN%Nsunlit),modisIN%pres(modisIN%Nsunlit,cospIN%Nlevels+1)) - modisIN%sunlit = pack((/ (i, i = 1, N_MODIS_SWATHED ) /),mask = (cospgridIN%sunlit > 0 .and. (MODIS_SWATH_MASK))) - modisIN%pres = cospgridIN%phalf(int(modisIN%sunlit(:)),:) ! Indexes just the masked locations - ! I need to figure out the complementary masking here. - endif + allocate(modisIN%sunlit(modisIN%Nsunlit)) + modisIN%sunlit = pack((/ (i, i = 1, modisIN%Npoints ) /),mask = ((cospgridIN%sunlit > 0) .and. MODIS_SWATH_MASK)) ! Indices of columns to operate on in modisIN + print*,'modisIN%sunlit: ',modisIN%sunlit + endif + if (modisIN%Npoints - modisIN%Nsunlit .gt. 0) then ! If more than zero tiles are not sunlit and swathed, create array to mask out these gridcells in cospOUT + allocate(modisIN%notSunlit(modisIN%Npoints - modisIN%Nsunlit)) + modisIN%notSunlit = pack((/ (i, i = 1, Npoints ) /),mask = (.not. ((cospgridIN%sunlit > 0) .and. MODIS_SWATH_MASK))) ! Create an array with the indices of the non-sunlit tiles + endif + ! Create a CSCAL-MODIS joint mask for the combined product. + if (allocated(CSCAL_SWATH_MASK)) then + allocate(MODIS_CSCAL_SWATH_MASK(Npoints)) + MODIS_CSCAL_SWATH_MASK = (.not. (MODIS_SWATH_MASK .and. CSCAL_SWATH_MASK)) ! Gridcells not seen by both MODIS and CSCAL should be set to zero + MODIS_CSCAL_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = MODIS_CSCAL_SWATH_MASK) + ! else + ! MODIS_CSCAL_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = .not. MODIS_SWATH_MASK) + end if else modisIN%Ncolumns => cospIN%Ncolumns modisIN%Nlevels => cospIN%Nlevels @@ -1127,15 +1151,21 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) modisIN%tau => cospIN%tau_067 modisIN%g => cospIN%asym modisIN%w0 => cospIN%ss_alb + allocate(modisIN%pres(modisIN%Npoints,cospIN%Nlevels+1)) ! Moving this outside of the sunlit statements for consistency with the other variables + modisIN%pres = cospgridIN%phalf modisIN%Nsunlit = count(cospgridIN%sunlit > 0) + ! if (modisIN%Nsunlit .gt. 0) then + ! allocate(modisIN%sunlit(modisIN%Nsunlit),modisIN%pres(modisIN%Nsunlit,cospIN%Nlevels+1)) + ! modisIN%sunlit = pack((/ (i, i = 1, Npoints ) /),mask = cospgridIN%sunlit > 0) + ! modisIN%pres = cospgridIN%phalf(int(modisIN%sunlit(:)),:) ! JKS no reason to have this structure differently, right? Memory? + ! endif if (modisIN%Nsunlit .gt. 0) then - allocate(modisIN%sunlit(modisIN%Nsunlit),modisIN%pres(modisIN%Nsunlit,cospIN%Nlevels+1)) + allocate(modisIN%sunlit(modisIN%Nsunlit)) modisIN%sunlit = pack((/ (i, i = 1, Npoints ) /),mask = cospgridIN%sunlit > 0) - modisIN%pres = cospgridIN%phalf(int(modisIN%sunlit(:)),:) - endif - if (count(cospgridIN%sunlit <= 0) .gt. 0) then + endif + if (count(cospgridIN%sunlit <= 0) .gt. 0) then ! If more than zero tiles are not sunlit a.k.a. if there are dark tiles allocate(modisIN%notSunlit(count(cospgridIN%sunlit <= 0))) - modisIN%notSunlit = pack((/ (i, i = 1, Npoints ) /),mask = .not. cospgridIN%sunlit > 0) + modisIN%notSunlit = pack((/ (i, i = 1, Npoints ) /),mask = .not. cospgridIN%sunlit > 0) ! Create an array with the indices of the non-sunlit tiles endif end if endif @@ -1193,14 +1223,16 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! ISCCP (icarus) subcolumn simulator if (Lisccp_subcolumn .or. Lmodis_subcolumn) then - if (cospIN % cospswathsIN(1) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays - ! Allocate space for local variables - allocate(isccpLEVMATCH(N_ISCCP_SWATHED,isccpIN%Ncolumns), & - isccp_boxttop(N_ISCCP_SWATHED,isccpIN%Ncolumns), & - isccp_boxptop(N_ISCCP_SWATHED,isccpIN%Ncolumns), & - isccp_boxtau(N_ISCCP_SWATHED,isccpIN%Ncolumns), & - isccp_meantbclr(N_ISCCP_SWATHED)) + print*,'ISCCP Subcol' + ! Allocate space for local variables + allocate(isccpLEVMATCH(isccpIN%Npoints,isccpIN%Ncolumns), & + isccp_boxttop(isccpIN%Npoints,isccpIN%Ncolumns), & + isccp_boxptop(isccpIN%Npoints,isccpIN%Ncolumns), & + isccp_boxtau(isccpIN%Npoints,isccpIN%Ncolumns), & + isccp_meantbclr(isccpIN%Npoints)) + if (cospIN % cospswathsIN(1) % N_inst_swaths .gt. 0) then ! MODIS and ISCCP ! Call simulator + ! print*,'ISCCP Subcol-1' call icarus_subcolumn(isccpIN%npoints,isccpIN%ncolumns,isccpIN%nlevels, & isccpIN%sunlit,isccpIN%dtau,isccpIN%dem,isccpIN%skt, & isccpIN%emsfc_lw,isccpIN%qv,isccpIN%at,isccpIN%pfull, & @@ -1208,31 +1240,21 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) isccp_boxtau(:,:),isccp_boxptop(:,:), & isccp_boxttop(:,:),isccp_meantbclr(:)) ! Decode outputs from swaths when reading into cospOUT fields - cospOUT%isccp_boxtau(:,:) = R_UNDEF - cospOUT%isccp_boxptop(:,:) = R_UNDEF - cospOUT%isccp_meantbclr(:) = R_UNDEF - j = 0 - do i=ij,ik ! Index ranges on outputs - if (ISCCP_SWATH_MASK(i - ij + 1)) then ! Convert back to an index for the swath mask - j = j + 1 - if (associated(cospOUT%isccp_boxtau)) cospOUT%isccp_boxtau(i,:) = isccp_boxtau(j,:) - if (associated(cospOUT%isccp_boxptop)) cospOUT%isccp_boxptop(i,:) = isccp_boxptop(j,:) - if (associated(cospOUT%isccp_meantbclr)) cospOUT%isccp_meantbclr(i) = isccp_meantbclr(j) - end if - end do - ! print*,'isccp_boxtau: ',isccp_boxtau - ! print*,'cospOUT%isccp_boxtau: ',cospOUT%isccp_boxtau + cospOUT%isccp_boxtau(ij:ik,:) = R_UNDEF + cospOUT%isccp_boxptop(ij:ik,:) = R_UNDEF + cospOUT%isccp_meantbclr(ij:ik) = R_UNDEF + ! print*,'ISCCP Subcol-2' + if (associated(cospOUT%isccp_boxtau)) cospOUT%isccp_boxtau(ij+int(ISCCP_MASK_INDICES)-1,:) = isccp_boxtau(:,:) + if (associated(cospOUT%isccp_boxptop)) cospOUT%isccp_boxptop(ij+int(ISCCP_MASK_INDICES)-1,:) = isccp_boxptop(:,:) ! This is used by MODIS as well. + if (associated(cospOUT%isccp_meantbclr)) cospOUT%isccp_meantbclr(ij+int(ISCCP_MASK_INDICES)-1) = isccp_meantbclr(:) + ! print*,'ISCCP Subcol-3' deallocate(temp_isccp_skt,temp_isccp_qv,temp_isccp_at, & temp_isccp_frac_out,temp_isccp_tau_067, & temp_isccp_emiss_11,temp_isccp_phalf, & temp_isccp_pfull) ! some of these pointers might be needed later! + ! print*,'ISCCP Subcol-4' else ! Proceed normally - ! Allocate space for local variables - allocate(isccpLEVMATCH(Npoints,isccpIN%Ncolumns), & - isccp_boxttop(Npoints,isccpIN%Ncolumns), & - isccp_boxptop(Npoints,isccpIN%Ncolumns), & - isccp_boxtau(Npoints,isccpIN%Ncolumns), isccp_meantbclr(Npoints)) - ! Call simulator + ! Call simulator call icarus_subcolumn(isccpIN%npoints,isccpIN%ncolumns,isccpIN%nlevels, & isccpIN%sunlit,isccpIN%dtau,isccpIN%dem,isccpIN%skt, & isccpIN%emsfc_lw,isccpIN%qv,isccpIN%at,isccpIN%pfull, & @@ -1254,31 +1276,25 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! MISR subcolumn simulator if (Lmisr_subcolumn) then + print*,'MISR Subcol-0' + ! Allocate space for local variables. + allocate(misr_boxztop(misrIN%Npoints,misrIN%Ncolumns), & + misr_boxtau(misrIN%Npoints,misrIN%Ncolumns), & + misr_dist_model_layertops(misrIN%Npoints,numMISRHgtBins)) if (cospIN % cospswathsIN(2) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays - ! Allocate space for local variables - allocate(misr_boxztop(N_MISR_SWATHED,misrIN%Ncolumns), & - misr_boxtau(N_MISR_SWATHED,misrIN%Ncolumns), & - misr_dist_model_layertops(N_MISR_SWATHED,numMISRHgtBins)) + ! Allocate space for local variables. + ! print*,'MISR Subcol-1' ! Call simulator - call misr_subcolumn(misrIN%Npoints,misrIN%Ncolumns,misrIN%Nlevels,misrIN%dtau, & + call misr_subcolumn(misrIN%Npoints,misrIN%Ncolumns,misrIN%Nlevels,misrIN%dtau, & misrIN%zfull,misrIN%at,misrIN%sunlit,misr_boxtau, & misr_dist_model_layertops,misr_boxztop) ! Decode outputs from swaths when reading into cospOUT fields - cospOUT%misr_dist_model_layertops(:,:) = R_UNDEF - j = 0 - do i=ij,ik ! Index ranges on outputs - if (MISR_SWATH_MASK(i - ij + 1)) then ! Convert back to an index for the swath mask - j = j + 1 - if (associated(cospOUT%misr_dist_model_layertops)) cospOUT%misr_dist_model_layertops(i,:) = misr_dist_model_layertops(j,:) - end if - end do - deallocate(temp_misr_sunlit,temp_misr_zfull,temp_misr_at,temp_misr_dtau) - deallocate(MISR_SWATH_MASK) + ! print*,'MISR Subcol-3' + cospOUT%misr_dist_model_layertops(ij:ik,:) = R_UNDEF + if (associated(cospOUT%misr_dist_model_layertops)) cospOUT%misr_dist_model_layertops(ij+int(MISR_MASK_INDICES)-1,:) = misr_dist_model_layertops(:,:) + ! print*,'MISR Subcol-4' + deallocate(temp_misr_zfull,temp_misr_at,temp_misr_dtau) else - ! Allocate space for local variables - allocate(misr_boxztop(Npoints,misrIN%Ncolumns), & - misr_boxtau(Npoints,misrIN%Ncolumns), & - misr_dist_model_layertops(Npoints,numMISRHgtBins)) ! Call simulator call misr_subcolumn(misrIN%Npoints,misrIN%Ncolumns,misrIN%Nlevels,misrIN%dtau, & misrIN%zfull,misrIN%at,misrIN%sunlit,misr_boxtau, & @@ -1292,11 +1308,13 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Calipso subcolumn simulator if (Lcalipso_subcolumn) then + print*,'CALIPSO Subcol-1' ! Allocate space for local variables allocate(calipso_beta_mol(calipsoIN%Npoints,calipsoIN%Nlevels), & calipso_beta_tot(calipsoIN%Npoints,calipsoIN%Ncolumns,calipsoIN%Nlevels),& calipso_betaperp_tot(calipsoIN%Npoints,calipsoIN%Ncolumns,calipsoIN%Nlevels)) ! Call simulator + print*,'CALIPSO Subcol-2' call lidar_subcolumn(calipsoIN%npoints, calipsoIN%ncolumns, calipsoIN%nlevels, .false., & calipsoIN%beta_mol, calipsoIN%tau_mol, calipsoIN%betatot, calipsoIN%tautot, & calipso_beta_mol(:,:), calipso_beta_tot(:,:,:), calipsoIN%betatot_ice, & @@ -1304,22 +1322,17 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) calipso_betaperp_tot(:,:,:)) if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays ! Decode outputs from swaths when reading into cospOUT fields - cospOUT%calipso_beta_mol(:,:) = R_UNDEF - cospOUT%calipso_beta_tot(:,:,:) = R_UNDEF - cospOUT%calipso_betaperp_tot(:,:,:) = R_UNDEF - j = 0 - do i=ij,ik ! Index ranges on outputs - if (CALIPSO_SWATH_MASK(i - ij + 1)) then ! Convert back to an index for the swath mask - j = j + 1 - if (associated(cospOUT%calipso_beta_mol)) cospOUT%calipso_beta_mol(i,:) = calipso_beta_mol(j,:) - if (associated(cospOUT%calipso_beta_tot)) cospOUT%calipso_beta_tot(i,:,:) = calipso_beta_tot(j,:,:) - if (associated(cospOUT%calipso_betaperp_tot)) cospOUT%calipso_betaperp_tot(i,:,:) = calipso_betaperp_tot(j,:,:) - end if - end do + print*,'CALIPSO Subcol-3' + cospOUT%calipso_beta_mol(ij:ik,:) = R_UNDEF + cospOUT%calipso_beta_tot(ij:ik,:,:) = R_UNDEF + cospOUT%calipso_betaperp_tot(ij:ik,:,:) = R_UNDEF + if (associated(cospOUT%calipso_beta_mol)) cospOUT%calipso_beta_mol(ij+int(CSCAL_MASK_INDICES)-1,calipsoIN%Nlevels:1:-1) = calipso_beta_mol(:,:) + if (associated(cospOUT%calipso_beta_tot)) cospOUT%calipso_beta_tot(ij+int(CSCAL_MASK_INDICES)-1,:,calipsoIN%Nlevels:1:-1) = calipso_beta_tot(:,:,:) + if (associated(cospOUT%calipso_betaperp_tot)) cospOUT%calipso_betaperp_tot(ij+int(CSCAL_MASK_INDICES)-1,:,:) = calipso_betaperp_tot(:,:,:) + print*,'CALIPSO Subcol-4' deallocate(temp_beta_mol_calipso,temp_tau_mol_calipso,temp_betatot_calipso,temp_tautot_calipso, & temp_betatot_liq_calipso,temp_tautot_liq_calipso,temp_betatot_ice_calipso,temp_tautot_ice_calipso) - deallocate(CALIPSO_SWATH_MASK) - else ! Proceed normally + else ! Proceed normally ! Store output (if requested) if (associated(cospOUT%calipso_beta_mol)) & cospOUT%calipso_beta_mol(ij:ik,calipsoIN%Nlevels:1:-1) = calipso_beta_mol @@ -1348,6 +1361,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! ATLID subcolumn simulator if (Latlid_subcolumn) then + print*,'ATLID Subcol-0' ! Allocate space for local variables allocate(atlid_beta_mol(atlidIN%Npoints,atlidIN%Nlevels), & atlid_beta_tot(atlidIN%Npoints,atlidIN%Ncolumns,atlidIN%Nlevels)) @@ -1357,18 +1371,13 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) atlidIN%tautot_atlid, atlid_beta_mol(:,:), atlid_beta_tot(:,:,:)) ! Decode outputs from swaths when reading into cospOUT fields if (cospIN % cospswathsIN(4) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays - cospOUT%atlid_beta_mol(:,:) = R_UNDEF - cospOUT%atlid_beta_tot(:,:,:) = R_UNDEF - j = 0 - do i=ij,ik ! Index ranges on outputs - if (ATLID_SWATH_MASK(i - ij + 1)) then ! Convert back to an index for the swath mask - j = j + 1 - if (associated(cospOUT%atlid_beta_mol)) cospOUT%atlid_beta_mol(i,atlidIN%Nlevels:1:-1) = atlid_beta_mol(j,:) - if (associated(cospOUT%atlid_beta_tot)) cospOUT%atlid_beta_tot(i,:,atlidIN%Nlevels:1:-1) = atlid_beta_tot(j,:,:) - end if - end do + print*,'ATLID Subcol-1' + cospOUT%atlid_beta_mol(ij:ik,:) = R_UNDEF + cospOUT%atlid_beta_tot(ij:ik,:,:) = R_UNDEF + if (associated(cospOUT%atlid_beta_mol)) cospOUT%atlid_beta_mol(ij+int(ATLID_MASK_INDICES)-1,atlidIN%Nlevels:1:-1) = atlid_beta_mol(:,:) + if (associated(cospOUT%atlid_beta_tot)) cospOUT%atlid_beta_tot(ij+int(ATLID_MASK_INDICES)-1,:,atlidIN%Nlevels:1:-1) = atlid_beta_tot(:,:,:) + print*,'ATLID Subcol-2' deallocate(temp_beta_mol_atlid,temp_betatot_atlid,temp_tau_mol_atlid,temp_tautot_atlid) - deallocate(ATLID_SWATH_MASK) else ! Store output (if requested) if (associated(cospOUT%atlid_beta_mol)) & @@ -1380,6 +1389,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! PARASOL subcolumn simulator if (Lparasol_subcolumn) then + print*,'PARASOL Subcol-0' ! Allocate space for local variables allocate(parasolPix_refl(parasolIN%Npoints,parasolIN%Ncolumns,PARASOL_NREFL)) ! Call simulator @@ -1390,16 +1400,8 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) parasolPix_refl(:,icol,1:PARASOL_NREFL)) ! Store output (if requested) if (cospIN % cospswathsIN(5) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays - cospOUT%parasolPix_refl(:,:,:) = R_UNDEF - j = 0 - do i=ij,ik ! Index ranges on outputs - if (PARASOL_SWATH_MASK(i - ij + 1)) then ! Convert back to an index for the swath mask - j = j + 1 - if (associated(cospOUT%parasolPix_refl)) cospOUT%parasolPix_refl(i,icol,1:PARASOL_NREFL) = parasolPix_refl(j,icol,1:PARASOL_NREFL) - end if - end do - deallocate(temp_tautot_S_liq,temp_tautot_S_ice) - deallocate(PARASOL_SWATH_MASK) + cospOUT%parasolPix_refl(ij:ik,icol,1:PARASOL_NREFL) = R_UNDEF + if (associated(cospOUT%parasolPix_refl)) cospOUT%parasolPix_refl(ij+int(PARASOL_MASK_INDICES)-1,icol,1:PARASOL_NREFL) = parasolPix_refl(:,icol,1:PARASOL_NREFL) else if (associated(cospOUT%parasolPix_refl)) then cospOUT%parasolPix_refl(ij:ik,icol,1:PARASOL_NREFL) = & @@ -1407,13 +1409,17 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) endif endif enddo + if (allocated(temp_tautot_S_liq)) deallocate(temp_tautot_S_liq) + if (allocated(temp_tautot_S_ice)) deallocate(temp_tautot_S_ice) endif ! Cloudsat (quickbeam) subcolumn simulator if (Lcloudsat_subcolumn) then ! Allocate space for local variables + print*,'CLOUDSAT Subcol-0' allocate(cloudsatDBZe(cloudsatIN%Npoints,cloudsatIN%Ncolumns,cloudsatIN%Nlevels), & cloudsatZe_non(cloudsatIN%Npoints,cloudsatIN%Ncolumns,cloudsatIN%Nlevels)) + print*,'CLOUDSAT Subcol-0.5' do icol=1,cloudsatIN%ncolumns call quickbeam_subcolumn(cloudsatIN%rcfg,cloudsatIN%Npoints,cloudsatIN%Nlevels,& cloudsatIN%hgt_matrix/1000._wp, & @@ -1421,44 +1427,66 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cloudsatIN%kr_vol(:,icol,:), & cloudsatIN%g_vol(:,1,:),cloudsatDBze(:,icol,:),cloudsatZe_non(:,icol,:)) enddo + print*,'CLOUDSAT Subcol-1' ! Store output (if requested) - if (cospIN % cospswathsIN(6) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays - cospOUT%cloudsat_Ze_tot(:,:,:) = R_UNDEF - j = 0 - do i=ij,ik ! Index ranges on outputs - if (CLOUDSAT_SWATH_MASK(i - ij + 1)) then ! Convert back to an index for the swath mask - j = j + 1 - if (associated(cospOUT%cloudsat_Ze_tot)) cospOUT%cloudsat_Ze_tot(i,:,1:cloudsatIN%Nlevels) = cloudsatDBZe(j,:,1:cloudsatIN%Nlevels) - end if - end do + if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + print*,'CLOUDSAT Subcol-2' + cospOUT%cloudsat_Ze_tot(ij:ik,:,:) = R_UNDEF + if (associated(cospOUT%cloudsat_Ze_tot)) cospOUT%cloudsat_Ze_tot(ij+int(CSCAL_MASK_INDICES)-1,:,1:cloudsatIN%Nlevels) = cloudsatDBZe(:,:,1:cloudsatIN%Nlevels) + print*,'CLOUDSAT Subcol-4' deallocate(temp_hgt_matrix,temp_z_vol_cloudsat,temp_kr_vol_cloudsat,temp_g_vol_cloudsat) - deallocate(CLOUDSAT_SWATH_MASK) else if (associated(cospOUT%cloudsat_Ze_tot)) then cospOUT%cloudsat_Ze_tot(ij:ik,:,:) = cloudsatDBZe(:,:,1:cloudsatIN%Nlevels) endif endif endif - if (Lmodis_subcolumn) then - if(modisiN%nSunlit > 0) then + if (modisiN%nSunlit > 0) then ! Allocate space for local variables + print*,'MODIS Subcol-0' allocate(modisRetrievedTau(modisIN%nSunlit,modisIN%nColumns), & modisRetrievedSize(modisIN%nSunlit,modisIN%nColumns), & modisRetrievedPhase(modisIN%nSunlit,modisIN%nColumns), & modisRetrievedCloudTopPressure(modisIN%nSunlit,modisIN%nColumns)) - ! Call simulator - do i = 1, modisIN%nSunlit - call modis_subcolumn(modisIN%Ncolumns,modisIN%Nlevels,modisIN%pres(i,:), & + print*,'MODIS Subcol-1' + if (allocated(ISCCP_SWATH_MASK)) then ! If ISCCP is swathed must run ICARUS separately for MODIS + allocate(modisLEVMATCH(modisIN%Npoints,modisIN%Ncolumns), & + modis_boxptop(modisIN%Npoints,modisIN%Ncolumns), & + modis_boxttop(modisIN%Npoints,modisIN%Ncolumns), & + modis_boxtau(modisIN%Npoints,modisIN%Ncolumns), & + modis_meantbclr(modisIN%Npoints)) + if (.not. allocated(MODIS_SWATH_MASK)) then + allocate(MODIS_SWATH_MASK(Npoints)) + MODIS_SWATH_MASK(:) = .true. + end if + call icarus_subcolumn(modisIN%npoints,modisIN%ncolumns,modisIN%nlevels, & + int(MERGE(1,0,MASK=(cospgridIN%sunlit > 0) .and. MODIS_SWATH_MASK)), & + modisIN%tau,cospIN%emiss_11,cospgridIN%skt, & + cospIN%emsfc_lw,cospgridIN%qv,cospgridIN%at,cospgridIN%pfull, & + modisIN%pres,cospIN%frac_out,modisLEVMATCH, & + modis_boxtau(:,:),modis_boxptop(:,:), & + modis_boxttop(:,:),modis_meantbclr(:)) + deallocate(modis_boxtau,modis_boxttop,modis_meantbclr,modisLEVMATCH) + else ! If ISCCP runs fully, just use the cospOUT field indexed appropriately + allocate(modis_boxptop(modisIN%Npoints,modisIN%Ncolumns)) + modis_boxptop = cospOUT%isccp_boxptop(ij:ik,:) + end if + ! Call simulator one column at a time on sunlit columns + do i = 1, modisIN%nSunlit ! Just run on the sunlit columns, even though the modisIN DDT includes everything orbit swathed + call modis_subcolumn(modisIN%Ncolumns,modisIN%Nlevels, & + modisIN%pres(int(modisIN%sunlit(i)),:), & modisIN%tau(int(modisIN%sunlit(i)),:,:), & modisIN%liqFrac(int(modisIN%sunlit(i)),:,:), & modisIN%g(int(modisIN%sunlit(i)),:,:), & modisIN%w0(int(modisIN%sunlit(i)),:,:), & - isccp_boxptop(int(modisIN%sunlit(i)),:), & + modis_boxptop(int(modisIN%sunlit(i)),:), & modisRetrievedPhase(i,:), & modisRetrievedCloudTopPressure(i,:), & - modisRetrievedTau(i,:),modisRetrievedSize(i,:)) + modisRetrievedTau(i,:),modisRetrievedSize(i,:)) end do + deallocate(modis_boxptop) + print*,'MODIS Subcol-2' endif endif @@ -1497,19 +1525,12 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Call simulator if (cospIN % cospswathsIN(1) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays ! Operate at the masked format. - allocate(temp_isccp_fq(N_ISCCP_SWATHED,numISCCPTauBins,numISCCPPresBins), & - temp_isccp_meanalbedocld(N_ISCCP_SWATHED), & - temp_isccp_meanptop(N_ISCCP_SWATHED), & - temp_isccp_meantaucld(N_ISCCP_SWATHED), & - temp_isccp_totalcldarea(N_ISCCP_SWATHED), & - temp_isccp_meantb(N_ISCCP_SWATHED)) - ! print*,'cospIN%npoints: ',cospIN%npoints - ! print*,'isccpIN%npoints: ',isccpIN%npoints - ! print*,'N_ISCCP_SWATHED: ',N_ISCCP_SWATHED - ! print*,'isccp_boxtau(: ,:): ',isccp_boxtau - ! print*,'isccp_boxptop(: ,:): ',isccp_boxptop - ! print*,'isccpIN%sunlit(: ,:): ',isccpIN%sunlit - ! print*,'isccp_boxttop(: ,:): ',isccp_boxttop + allocate(temp_isccp_fq(isccpIN%Npoints,numISCCPTauBins,numISCCPPresBins), & + temp_isccp_meanalbedocld(isccpIN%Npoints), & + temp_isccp_meanptop(isccpIN%Npoints), & + temp_isccp_meantaucld(isccpIN%Npoints), & + temp_isccp_totalcldarea(isccpIN%Npoints), & + temp_isccp_meantb(isccpIN%Npoints)) call icarus_column(isccpIN%npoints, isccpIN%ncolumns,isccp_boxtau(:,:), & isccp_boxptop(:,:)/100._wp,isccpIN%sunlit,isccp_boxttop(:,:), & @@ -1524,26 +1545,14 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospOUT%isccp_meantaucld(ij:ik) = R_UNDEF cospOUT%isccp_totalcldarea(ij:ik) = R_UNDEF cospOUT%isccp_meantb(ij:ik) = R_UNDEF - j = 0 - ! print*,'temp_isccp_totalcldarea: ',temp_isccp_totalcldarea - do i=ij,ik ! Index ranges on outputs - if (ISCCP_SWATH_MASK(i - ij + 1)) then ! Convert back to an index for the swath mask - j = j + 1 - if (associated(cospOUT%isccp_fq)) cospOUT%isccp_fq(i,:,:) = temp_isccp_fq(j,:,:) - if (associated(cospOUT%isccp_meanalbedocld)) cospOUT%isccp_meanalbedocld(i) = temp_isccp_meanalbedocld(j) - if (associated(cospOUT%isccp_meanptop)) cospOUT%isccp_meanptop(i) = temp_isccp_meanptop(j) - if (associated(cospOUT%isccp_meantaucld)) cospOUT%isccp_meantaucld(i) = temp_isccp_meantaucld(j) - if (associated(cospOUT%isccp_totalcldarea)) cospOUT%isccp_totalcldarea(i) = temp_isccp_totalcldarea(j) - if (associated(cospOUT%isccp_meantb)) cospOUT%isccp_meantb(i) = temp_isccp_meantb(j) - end if - end do - deallocate(ISCCP_SWATH_MASK,temp_isccp_fq,temp_isccp_meanalbedocld,temp_isccp_meanptop,temp_isccp_meantaucld,temp_isccp_totalcldarea,temp_isccp_meantb,temp_isccp_sunlit) - ! print*,'cospOUT%isccp_totalcldarea: ',cospOUT%isccp_totalcldarea + if (associated(cospOUT%isccp_fq)) cospOUT%isccp_fq(ij+int(ISCCP_MASK_INDICES)-1,:,:) = temp_isccp_fq(:,:,:) + if (associated(cospOUT%isccp_meanalbedocld)) cospOUT%isccp_meanalbedocld(ij+int(ISCCP_MASK_INDICES)-1) = temp_isccp_meanalbedocld(:) + if (associated(cospOUT%isccp_meanptop)) cospOUT%isccp_meanptop(ij+int(ISCCP_MASK_INDICES)-1) = temp_isccp_meanptop(:) + if (associated(cospOUT%isccp_meantaucld)) cospOUT%isccp_meantaucld(ij+int(ISCCP_MASK_INDICES)-1) = temp_isccp_meantaucld(:) + if (associated(cospOUT%isccp_totalcldarea)) cospOUT%isccp_totalcldarea(ij+int(ISCCP_MASK_INDICES)-1) = temp_isccp_totalcldarea(:) + if (associated(cospOUT%isccp_meantb)) cospOUT%isccp_meantb(ij+int(ISCCP_MASK_INDICES)-1) = temp_isccp_meantb(:) + deallocate(ISCCP_SWATH_MASK,ISCCP_MASK_INDICES,temp_isccp_fq,temp_isccp_meanalbedocld,temp_isccp_meanptop,temp_isccp_meantaucld,temp_isccp_totalcldarea,temp_isccp_meantb) else - ! print*,'isccp_boxtau(124:153,:): ',isccp_boxtau(124:153,:) - ! print*,'isccp_boxptop(124:153,:): ',isccp_boxptop(124:153,:) - ! print*,'isccpIN%sunlit(124:153): ',isccpIN%sunlit(124:153) - ! print*,'isccp_boxttop(124:153,:): ',isccp_boxttop(124:153,:) call icarus_column(isccpIN%npoints, isccpIN%ncolumns,isccp_boxtau(:,:), & isccp_boxptop(:,:)/100._wp, isccpIN%sunlit,isccp_boxttop(:,:), & cospOUT%isccp_fq(ij:ik,:,:), & @@ -1565,6 +1574,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (allocated(isccp_boxtau)) deallocate(isccp_boxtau) if (allocated(isccp_meantbclr)) deallocate(isccp_meantbclr) if (allocated(isccpLEVMATCH)) deallocate(isccpLEVMATCH) + if (allocated(temp_isccp_sunlit)) deallocate(temp_isccp_sunlit) if (allocated(out1D_1)) then deallocate(out1D_1) nullify(cospOUT%isccp_meanalbedocld) @@ -1589,6 +1599,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) deallocate(out1D_6) nullify(cospOUT%isccp_fq) endif + ! Clear up memory for ISCCP swath variables endif ! MISR @@ -1605,13 +1616,34 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (.not. associated(cospOUT%misr_fq)) then allocate(out1D_3(Npoints*numMISRTauBins*numMISRHgtBins)) cospOUT%misr_fq(ij:ik,1:numMISRTauBins,1:numMISRHgtBins) => out1D_3 - endif + endif ! Call simulator - call misr_column(misrIN%Npoints,misrIN%Ncolumns,misr_boxztop,misrIN%sunlit,& - misr_boxtau,cospOUT%misr_cldarea(ij:ik), & - cospOUT%misr_meanztop(ij:ik),cospOUT%misr_fq(ij:ik,:,:)) - + if (cospIN % cospswathsIN(2) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + ! print*,'MISR' + ! Operate at the masked format. + allocate(temp_misr_cldarea(misrIN%Npoints), & + temp_misr_meanztop(misrIN%Npoints), & + temp_misr_fq(misrIN%Npoints,numMISRTauBins,numMISRHgtBins)) + ! print*,'MISR-1' + call misr_column(misrIN%Npoints,misrIN%Ncolumns,misr_boxztop,misrIN%sunlit,& + misr_boxtau,temp_misr_cldarea(:), & + temp_misr_meanztop(:),temp_misr_fq(:,:,:)) + ! print*,'MISR-2' + ! Decode back to the cospOUT shapes + cospOUT%misr_cldarea(ij:ik) = R_UNDEF + cospOUT%misr_meanztop(ij:ik) = R_UNDEF + cospOUT%misr_fq(ij:ik,:,:) = R_UNDEF + if (associated(cospOUT%misr_cldarea)) cospOUT%misr_cldarea(ij+int(MISR_MASK_INDICES)-1) = temp_misr_cldarea(:) + if (associated(cospOUT%misr_meanztop)) cospOUT%misr_meanztop(ij+int(MISR_MASK_INDICES)-1) = temp_misr_meanztop(:) + if (associated(cospOUT%misr_fq)) cospOUT%misr_fq(ij+int(MISR_MASK_INDICES)-1,:,:) = temp_misr_fq(:,:,:) + ! print*,'MISR-3' + deallocate(MISR_SWATH_MASK,MISR_MASK_INDICES,temp_misr_sunlit,temp_misr_cldarea,temp_misr_meanztop,temp_misr_fq) + else + call misr_column(misrIN%Npoints,misrIN%Ncolumns,misr_boxztop,misrIN%sunlit,& + misr_boxtau,cospOUT%misr_cldarea(ij:ik), & + cospOUT%misr_meanztop(ij:ik),cospOUT%misr_fq(ij:ik,:,:)) + endif ! Clear up memory if (allocated(misr_boxtau)) deallocate(misr_boxtau) if (allocated(misr_boxztop)) deallocate(misr_boxztop) @@ -1683,21 +1715,82 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) endif ! Call simulator - ok_lidar_cfad=.true. - call lidar_column(calipsoIN%Npoints, calipsoIN%Ncolumns, calipsoIN%Nlevels, & - Nlvgrid, SR_BINS, LIDAR_NTYPE, 'calipso',calipso_beta_tot(:,:,:), calipso_beta_mol(:,:),& - cospgridIN%phalf(:,2:calipsoIN%Nlevels+1),cospgridIN%hgt_matrix, & - cospgridIN%hgt_matrix_half, vgrid_z(:), ok_lidar_cfad, LIDAR_NCAT, & - cospOUT%calipso_cfad_sr(ij:ik,:,:), cospOUT%calipso_lidarcld(ij:ik,:), & - cospOUT%calipso_cldlayer(ij:ik,:), & - cospgridIN%at(:,:), calipso_betaperp_tot(:,:,:), cospgridIN%surfelev, & - cospOUT%calipso_lidarcldphase(ij:ik,:,:), & - cospOUT%calipso_lidarcldtype(ij:ik,:,:), cospOUT%calipso_cldtype(ij:ik,:), & - cospOUT%calipso_cldtypetemp(ij:ik,:), cospOUT%calipso_cldtypemeanz(ij:ik,:), & - cospOUT%calipso_cldtypemeanzse(ij:ik,:), cospOUT%calipso_cldthinemis(ij:ik), & - cospOUT%calipso_cldlayerphase(ij:ik,:,:), cospOUT%calipso_lidarcldtmp(ij:ik,:,:)) - - if (associated(cospOUT%calipso_srbval)) cospOUT%calipso_srbval = calipso_histBsct + if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + ! Operate at the masked format. + print*,'CALIPSO' + allocate(temp_calipso_cfad_sr(calipsoIN%Npoints,SR_BINS,Nlvgrid), & + temp_calipso_lidarcld(calipsoIN%Npoints,Nlvgrid), & + temp_calipso_cldlayer(calipsoIN%Npoints,LIDAR_NCAT), & + temp_calipso_lidarcldphase(calipsoIN%Npoints,Nlvgrid,6), & + temp_calipso_lidarcldtype(calipsoIN%Npoints,Nlvgrid,LIDAR_NTYPE+1), & + temp_calipso_cldtype(calipsoIN%Npoints,LIDAR_NTYPE), & + temp_calipso_cldtypetemp(calipsoIN%Npoints,LIDAR_NTYPE), & + temp_calipso_cldtypemeanz(calipsoIN%Npoints,2), & + temp_calipso_cldtypemeanzse(calipsoIN%Npoints,3), & + temp_calipso_cldthinemis(calipsoIN%Npoints), & + temp_calipso_cldlayerphase(calipsoIN%Npoints,LIDAR_NCAT,6), & + temp_calipso_lidarcldtmp(calipsoIN%Npoints,LIDAR_NTEMP,5)) + ok_lidar_cfad=.true. + print*,'CALIPSO-1' + call lidar_column(calipsoIN%Npoints, calipsoIN%Ncolumns, calipsoIN%Nlevels, & + Nlvgrid, SR_BINS, LIDAR_NTYPE, 'calipso',calipso_beta_tot(:,:,:), calipso_beta_mol(:,:),& + cospgridIN%phalf(int(CSCAL_MASK_INDICES),2:calipsoIN%Nlevels+1),cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES),:), & ! JKS issues here, add ij - 1? + cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES),:), vgrid_z(:), ok_lidar_cfad, LIDAR_NCAT, & ! JKS issues here + temp_calipso_cfad_sr(:,:,:), temp_calipso_lidarcld(:,:), & + temp_calipso_cldlayer(:,:), & + cospgridIN%at(int(CSCAL_MASK_INDICES),:), calipso_betaperp_tot(:,:,:), cospgridIN%surfelev(int(CSCAL_MASK_INDICES)), & ! JKS issues here + temp_calipso_lidarcldphase(:,:,:), & + temp_calipso_lidarcldtype(:,:,:), temp_calipso_cldtype(:,:), & + temp_calipso_cldtypetemp(:,:), temp_calipso_cldtypemeanz(:,:), & + temp_calipso_cldtypemeanzse(:,:), temp_calipso_cldthinemis(:), & + temp_calipso_cldlayerphase(:,:,:), temp_calipso_lidarcldtmp(:,:,:)) + ! Decode back to the cospOUT shapes + print*,'CALIPSO-2' + cospOUT%calipso_cfad_sr(ij:ik,:,:) = R_UNDEF + cospOUT%calipso_lidarcld(ij:ik,:) = R_UNDEF + cospOUT%calipso_cldlayer(ij:ik,:) = R_UNDEF + cospOUT%calipso_lidarcldphase(ij:ik,:,:) = R_UNDEF + cospOUT%calipso_lidarcldtype(ij:ik,:,:) = R_UNDEF + cospOUT%calipso_cldtype(ij:ik,:) = R_UNDEF + cospOUT%calipso_cldtypetemp(ij:ik,:) = R_UNDEF + cospOUT%calipso_cldtypemeanz(ij:ik,:) = R_UNDEF + cospOUT%calipso_cldtypemeanzse(ij:ik,:) = R_UNDEF + cospOUT%calipso_cldthinemis(ij:ik) = R_UNDEF + cospOUT%calipso_cldlayerphase(ij:ik,:,:) = R_UNDEF + cospOUT%calipso_lidarcldtmp(ij:ik,:,:) = R_UNDEF + if (associated(cospOUT%calipso_cfad_sr)) cospOUT%calipso_cfad_sr(ij+int(CSCAL_MASK_INDICES)-1,:,:) = temp_calipso_cfad_sr(:,:,:) ! JKS indexing correct? + if (associated(cospOUT%calipso_lidarcld)) cospOUT%calipso_lidarcld(ij+int(CSCAL_MASK_INDICES)-1,:) = temp_calipso_lidarcld(:,:) + if (associated(cospOUT%calipso_cldlayer)) cospOUT%calipso_cldlayer(ij+int(CSCAL_MASK_INDICES)-1,:) = temp_calipso_cldlayer(:,:) + if (associated(cospOUT%calipso_lidarcldphase)) cospOUT%calipso_lidarcldphase(ij+int(CSCAL_MASK_INDICES)-1,:,:) = temp_calipso_lidarcldphase(:,:,:) + if (associated(cospOUT%calipso_lidarcldtype)) cospOUT%calipso_lidarcldtype(ij+int(CSCAL_MASK_INDICES)-1,:,:) = temp_calipso_lidarcldtype(:,:,:) + if (associated(cospOUT%calipso_cldtype)) cospOUT%calipso_cldtype(ij+int(CSCAL_MASK_INDICES)-1,:) = temp_calipso_cldtype(:,:) + if (associated(cospOUT%calipso_cldtypetemp)) cospOUT%calipso_cldtypetemp(ij+int(CSCAL_MASK_INDICES)-1,:) = temp_calipso_cldtypetemp(:,:) + if (associated(cospOUT%calipso_cldtypemeanz)) cospOUT%calipso_cldtypemeanz(ij+int(CSCAL_MASK_INDICES)-1,:) = temp_calipso_cldtypemeanz(:,:) + if (associated(cospOUT%calipso_cldtypemeanzse)) cospOUT%calipso_cldtypemeanzse(ij+int(CSCAL_MASK_INDICES)-1,:) = temp_calipso_cldtypemeanzse(:,:) + if (associated(cospOUT%calipso_cldthinemis)) cospOUT%calipso_cldthinemis(ij+int(CSCAL_MASK_INDICES)-1) = temp_calipso_cldthinemis(:) + if (associated(cospOUT%calipso_cldlayerphase)) cospOUT%calipso_cldlayerphase(ij+int(CSCAL_MASK_INDICES)-1,:,:) = temp_calipso_cldlayerphase(:,:,:) + if (associated(cospOUT%calipso_lidarcldtmp)) cospOUT%calipso_lidarcldtmp(ij+int(CSCAL_MASK_INDICES)-1,:,:) = temp_calipso_lidarcldtmp(:,:,:) + print*,'CALIPSO-3' + deallocate(CSCAL_SWATH_MASK,temp_calipso_cfad_sr,temp_calipso_lidarcld,temp_calipso_cldlayer,temp_calipso_lidarcldphase, & + temp_calipso_lidarcldtype,temp_calipso_cldtype,temp_calipso_cldtypetemp,temp_calipso_cldtypemeanz, & + temp_calipso_cldtypemeanzse,temp_calipso_cldthinemis,temp_calipso_cldlayerphase,temp_calipso_lidarcldtmp) + else + ok_lidar_cfad=.true. + call lidar_column(calipsoIN%Npoints, calipsoIN%Ncolumns, calipsoIN%Nlevels, & + Nlvgrid, SR_BINS, LIDAR_NTYPE, 'calipso',calipso_beta_tot(:,:,:), calipso_beta_mol(:,:),& + cospgridIN%phalf(:,2:calipsoIN%Nlevels+1),cospgridIN%hgt_matrix, & + cospgridIN%hgt_matrix_half, vgrid_z(:), ok_lidar_cfad, LIDAR_NCAT, & + cospOUT%calipso_cfad_sr(ij:ik,:,:), cospOUT%calipso_lidarcld(ij:ik,:), & + cospOUT%calipso_cldlayer(ij:ik,:), & + cospgridIN%at(:,:), calipso_betaperp_tot(:,:,:), cospgridIN%surfelev, & + cospOUT%calipso_lidarcldphase(ij:ik,:,:), & + cospOUT%calipso_lidarcldtype(ij:ik,:,:), cospOUT%calipso_cldtype(ij:ik,:), & + cospOUT%calipso_cldtypetemp(ij:ik,:), cospOUT%calipso_cldtypemeanz(ij:ik,:), & + cospOUT%calipso_cldtypemeanzse(ij:ik,:), cospOUT%calipso_cldthinemis(ij:ik), & + cospOUT%calipso_cldlayerphase(ij:ik,:,:), cospOUT%calipso_lidarcldtmp(ij:ik,:,:)) + endif + + if (associated(cospOUT%calipso_srbval)) cospOUT%calipso_srbval = calipso_histBsct ! Free up memory (if necessary) if (allocated(out1D_1)) then @@ -1809,16 +1902,38 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) allocate(out1D_3(Npoints*LIDAR_NCAT)) cospOUT%atlid_cldlayer(ij:ik,1:LIDAR_NCAT) => out1D_3 endif - ! Call simulator ok_lidar_cfad_atlid=.true. - call lidar_column(atlidIN%Npoints, atlidIN%Ncolumns, atlidIN%Nlevels, & - Nlvgrid, SR_BINS, LIDAR_NTYPE, 'atlid',atlid_beta_tot(:,:,:), & - atlid_beta_mol(:,:), cospgridIN%phalf(:,2:atlidIN%Nlevels+1), & - cospgridIN%hgt_matrix, cospgridIN%hgt_matrix_half, vgrid_z(:), & - ok_lidar_cfad_atlid, LIDAR_NCAT, cospOUT%atlid_cfad_sr(ij:ik,:,:), & - cospOUT%atlid_lidarcld(ij:ik,:), cospOUT%atlid_cldlayer(ij:ik,:)) - + if (cospIN % cospswathsIN(4) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + print*,'ATLID' + allocate(temp_atlid_cfad_sr(atlidIN%Npoints,SR_BINS,Nlvgrid), & + temp_atlid_lidarcld(atlidIN%Npoints,Nlvgrid), & + temp_atlid_cldlayer(atlidIN%Npoints,LIDAR_NCAT)) + print*,'ATLID-1' + call lidar_column(atlidIN%Npoints, atlidIN%Ncolumns, atlidIN%Nlevels, & + Nlvgrid, SR_BINS, LIDAR_NTYPE, 'atlid',atlid_beta_tot(:,:,:), & + atlid_beta_mol(:,:), cospgridIN%phalf(int(ATLID_MASK_INDICES),2:atlidIN%Nlevels+1), & + cospgridIN%hgt_matrix(int(ATLID_MASK_INDICES),:), cospgridIN%hgt_matrix_half(int(ATLID_MASK_INDICES),:), vgrid_z(:), & + ok_lidar_cfad_atlid, LIDAR_NCAT, temp_atlid_cfad_sr(:,:,:), & + temp_atlid_lidarcld(:,:), temp_atlid_cldlayer(:,:)) + ! Decode back to the cospOUT shapes + print*,'ATLID-2' + cospOUT%atlid_cfad_sr(ij:ik,:,:) = R_UNDEF ! JKS move within associated statement for all of these? + cospOUT%atlid_lidarcld(ij:ik,:) = R_UNDEF + cospOUT%atlid_cldlayer(ij:ik,:) = R_UNDEF + if (associated(cospOUT%atlid_cfad_sr)) cospOUT%atlid_cfad_sr(ij+int(ATLID_MASK_INDICES)-1,:,:) = temp_atlid_cfad_sr(:,:,:) + if (associated(cospOUT%atlid_lidarcld)) cospOUT%atlid_lidarcld(ij+int(ATLID_MASK_INDICES)-1,:) = temp_atlid_lidarcld(:,:) + if (associated(cospOUT%atlid_cldlayer)) cospOUT%atlid_cldlayer(ij+int(ATLID_MASK_INDICES)-1,:) = temp_atlid_cldlayer(:,:) + print*,'ATLID-3' + deallocate(ATLID_SWATH_MASK,ATLID_MASK_INDICES,temp_atlid_cfad_sr,temp_atlid_lidarcld,temp_atlid_cldlayer) + else + call lidar_column(atlidIN%Npoints, atlidIN%Ncolumns, atlidIN%Nlevels, & + Nlvgrid, SR_BINS, LIDAR_NTYPE, 'atlid',atlid_beta_tot(:,:,:), & + atlid_beta_mol(:,:), cospgridIN%phalf(:,2:atlidIN%Nlevels+1), & + cospgridIN%hgt_matrix, cospgridIN%hgt_matrix_half, vgrid_z(:), & + ok_lidar_cfad_atlid, LIDAR_NCAT, cospOUT%atlid_cfad_sr(ij:ik,:,:), & + cospOUT%atlid_lidarcld(ij:ik,:), cospOUT%atlid_cldlayer(ij:ik,:)) + endif if (associated(cospOUT%atlid_srbval)) cospOUT%atlid_srbval = atlid_histBsct ! Free up memory (if necessary) @@ -1839,10 +1954,28 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! PARASOL if (Lparasol_column) then - call parasol_column(parasolIN%Npoints,PARASOL_NREFL,parasolIN%Ncolumns, & - cospgridIN%land(:),parasolPix_refl(:,:,:), & - cospOUT%parasolGrid_refl(ij:ik,:)) - if (allocated(parasolPix_refl)) deallocate(parasolPix_refl) + if (cospIN % cospswathsIN(5) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + print*,'PARASOL' + allocate(temp_parasolGrid_refl(parasolIN%Npoints,PARASOL_NREFL)) + print*,'PARASOL-1' + call parasol_column(parasolIN%Npoints,PARASOL_NREFL,parasolIN%Ncolumns, & + cospgridIN%land(int(PARASOL_MASK_INDICES)),parasolPix_refl(:,:,:), & + temp_parasolGrid_refl(:,:)) + ! Decode back to the cospOUT shapes + print*,'PARASOL-2' + ! print*,'temp_parasolGrid_refl: ',temp_parasolGrid_refl + cospOUT%parasolGrid_refl(ij:ik,:) = R_UNDEF + if (associated(cospOUT%parasolGrid_refl)) cospOUT%parasolGrid_refl(ij+int(PARASOL_MASK_INDICES)-1,:) = temp_parasolGrid_refl(:,:) + deallocate(PARASOL_SWATH_MASK,temp_parasolGrid_refl) + else + call parasol_column(parasolIN%Npoints,PARASOL_NREFL,parasolIN%Ncolumns, & + cospgridIN%land(:),parasolPix_refl(:,:,:), & + cospOUT%parasolGrid_refl(ij:ik,:)) + ! print*,'cospOUT%parasolGrid_refl: ',cospOUT%parasolGrid_refl ! Values not zeroed here. + endif + if (allocated(parasolPix_refl)) deallocate(parasolPix_refl) + if (allocated(PARASOL_SWATH_MASK)) deallocate(PARASOL_SWATH_MASK) + if (allocated(PARASOL_MASK_INDICES)) deallocate(PARASOL_MASK_INDICES) endif ! CLOUDSAT @@ -1863,12 +1996,37 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) endif ! Call simulator - call quickbeam_column(cloudsatIN%Npoints, cloudsatIN%Ncolumns, cloudsatIN%Nlevels,& - Nlvgrid, cloudsat_DBZE_BINS, 'cloudsat', cloudsatDBZe, cloudsatZe_non, & - cospgridIN%land(:), cospgridIN%surfelev(:), cospgridIN%at(:,cospIN%Nlevels), & - cospIN%fracPrecipIce, cospgridIN%hgt_matrix, cospgridIN%hgt_matrix_half, & - cospOUT%cloudsat_cfad_ze(ij:ik,:,:), cospOUT%cloudsat_precip_cover, & - cospOUT%cloudsat_pia) + if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + print*,'CLOUDSAT' + allocate(temp_cloudsat_cfad_ze(cloudsatIN%Npoints,cloudsat_DBZE_BINS,Nlvgrid), & + temp_cloudsat_precip_cover(cloudsatIN%Npoints,cloudsat_DBZE_BINS), & + temp_cloudsat_pia(cloudsatIN%Npoints)) + print*,'CLOUDSAT-1' + call quickbeam_column(cloudsatIN%Npoints, cloudsatIN%Ncolumns, cloudsatIN%Nlevels,& + Nlvgrid, cloudsat_DBZE_BINS, 'cloudsat', cloudsatDBZe, cloudsatZe_non, & + cospgridIN%land(int(CSCAL_MASK_INDICES)), cospgridIN%surfelev(int(CSCAL_MASK_INDICES)), cospgridIN%at(int(CSCAL_MASK_INDICES),cospIN%Nlevels), & ! JKS + cospIN%fracPrecipIce(int(CSCAL_MASK_INDICES),:), cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES),:), cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES),:), & ! JKS + temp_cloudsat_cfad_ze(:,:,:), temp_cloudsat_precip_cover(:,:), & + temp_cloudsat_pia(:)) + print*,'CLOUDSAT-2' + ! Decode back to the cospOUT shapes + cospOUT%cloudsat_cfad_ze(ij:ik,:,:) = R_UNDEF + cospOUT%cloudsat_precip_cover(ij:ik,:) = R_UNDEF + cospOUT%cloudsat_pia(ij:ik) = R_UNDEF + if (associated(cospOUT%cloudsat_cfad_ze)) cospOUT%cloudsat_cfad_ze(ij+int(CSCAL_MASK_INDICES)-1,:,:) = temp_cloudsat_cfad_ze(:,:,:) + if (associated(cospOUT%cloudsat_precip_cover)) cospOUT%cloudsat_precip_cover(ij+int(CSCAL_MASK_INDICES)-1,:) = temp_cloudsat_precip_cover(:,:) + if (associated(cospOUT%cloudsat_pia)) cospOUT%cloudsat_pia(ij+int(CSCAL_MASK_INDICES)-1) = temp_cloudsat_pia(:) + deallocate(temp_cloudsat_cfad_ze,temp_cloudsat_precip_cover,temp_cloudsat_pia) + if (allocated(CSCAL_SWATH_MASK)) deallocate(CSCAL_SWATH_MASK) + print*,'CLOUDSAT-4' + else + call quickbeam_column(cloudsatIN%Npoints, cloudsatIN%Ncolumns, cloudsatIN%Nlevels,& + Nlvgrid, cloudsat_DBZE_BINS, 'cloudsat', cloudsatDBZe, cloudsatZe_non, & + cospgridIN%land(:), cospgridIN%surfelev(:), cospgridIN%at(:,cospIN%Nlevels), & + cospIN%fracPrecipIce, cospgridIN%hgt_matrix, cospgridIN%hgt_matrix_half, & + cospOUT%cloudsat_cfad_ze(ij:ik,:,:), cospOUT%cloudsat_precip_cover(ij:ik,:), & + cospOUT%cloudsat_pia(ij:ik)) + endif ! Free up memory (if necessary) if (allocated(out1D_1)) then deallocate(out1D_1) @@ -1886,7 +2044,9 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! MODIS if (Lmodis_column) then + print*,'MODIS' if(modisIN%nSunlit > 0) then + print*,'MODIS-1' ! Allocate space for local variables allocate(modisCftotal(modisIN%nSunlit), modisCfLiquid(modisIN%nSunlit), & modisCfIce(modisIN%nSunlit),modisCfHigh(modisIN%nSunlit), & @@ -1904,6 +2064,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) modisJointHistogram(modisIN%nSunlit,numMODISTauBins,numMODISPresBins),& modisJointHistogramIce(modisIN%nSunlit,numModisTauBins,numMODISReffIceBins),& modisJointHistogramLiq(modisIN%nSunlit,numModisTauBins,numMODISReffLiqBins)) + print*,'MODIS-2' ! Call simulator call modis_column(modisIN%nSunlit, modisIN%Ncolumns,modisRetrievedPhase, & modisRetrievedCloudTopPressure,modisRetrievedTau, & @@ -1915,6 +2076,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) modisMeanCloudTopPressure, modisMeanLiquidWaterPath, & modisMeanIceWaterPath, modisJointHistogram, & modisJointHistogramIce,modisJointHistogramLiq) + print*,'MODIS-3' ! Store data (if requested) if (associated(cospOUT%modis_Cloud_Fraction_Total_Mean)) then cospOUT%modis_Cloud_Fraction_Total_Mean(ij+int(modisIN%sunlit(:))-1) = & @@ -1992,13 +2154,16 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospOUT%modis_Optical_Thickness_vs_Cloud_Top_Pressure(ij:ik,:,numMODISPresBins:1:-1) endif if (associated(cospOUT%modis_Optical_Thickness_vs_ReffIce)) then + cospOUT%modis_Optical_Thickness_vs_ReffIce(ij:ik,1:numMODISTauBins,:) = R_UNDEF cospOUT%modis_Optical_Thickness_vs_ReffIce(ij+int(modisIN%sunlit(:))-1, 1:numMODISTauBins,:) = & modisJointHistogramIce(:,:,:) endif if (associated(cospOUT%modis_Optical_Thickness_vs_ReffLiq)) then + cospOUT%modis_Optical_Thickness_vs_ReffLiq(ij:ik,:,:) = R_UNDEF cospOUT%modis_Optical_Thickness_vs_ReffLiq(ij+int(modisIN%sunlit(:))-1, 1:numMODISTauBins,:) = & modisJointHistogramLiq(:,:,:) endif + print*,'MODIS-4' if(modisIN%nSunlit < modisIN%Npoints) then ! Where it's night and we haven't done the retrievals the values are undefined @@ -2038,8 +2203,13 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospOUT%modis_Ice_Water_Path_Mean(ij+int(modisIN%notSunlit(:))-1) = R_UNDEF if (associated(cospOUT%modis_Optical_Thickness_vs_Cloud_Top_Pressure)) & cospOUT%modis_Optical_Thickness_vs_Cloud_Top_Pressure(ij+int(modisIN%notSunlit(:))-1, :, :) = R_UNDEF + if (associated(cospOUT%modis_Optical_Thickness_vs_ReffIce)) & + cospOUT%modis_Optical_Thickness_vs_ReffIce(ij+int(modisIN%notSunlit(:))-1, :, :) = R_UNDEF + if (associated(cospOUT%modis_Optical_Thickness_vs_ReffLiq)) & + cospOUT%modis_Optical_Thickness_vs_ReffLiq(ij+int(modisIN%notSunlit(:))-1, :, :) = R_UNDEF end if else + print*,'MODIS-5' ! It's nightime everywhere - everything is undefined if (associated(cospOUT%modis_Cloud_Fraction_Total_Mean)) & cospOUT%modis_Cloud_Fraction_Total_Mean(ij:ik) = R_UNDEF @@ -2077,6 +2247,10 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospOUT%modis_Ice_Water_Path_Mean(ij:ik) = R_UNDEF if (associated(cospOUT%modis_Optical_Thickness_vs_Cloud_Top_Pressure)) & cospOUT%modis_Optical_Thickness_vs_Cloud_Top_Pressure(ij:ik, :, :) = R_UNDEF + if (associated(cospOUT%modis_Optical_Thickness_vs_ReffIce)) & + cospOUT%modis_Optical_Thickness_vs_ReffIce(ij:ik, :, :) = R_UNDEF + if (associated(cospOUT%modis_Optical_Thickness_vs_ReffLiq)) & + cospOUT%modis_Optical_Thickness_vs_ReffLiq(ij:ik, :, :) = R_UNDEF endif ! Free up memory (if necessary) if (allocated(modisRetrievedTau)) deallocate(modisRetrievedTau) @@ -2108,6 +2282,8 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (allocated(isccp_boxtau)) deallocate(isccp_boxtau) if (allocated(isccp_meantbclr)) deallocate(isccp_meantbclr) if (allocated(isccpLEVMATCH)) deallocate(isccpLEVMATCH) + if (allocated(MODIS_SWATH_MASK)) deallocate(MODIS_SWATH_MASK) + if (allocated(MODIS_MASK_INDICES)) deallocate(MODIS_MASK_INDICES) endif ! RTTOV multi-instrument @@ -2205,75 +2381,122 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! CLOUDSAT/CALIPSO products if (Lradar_lidar_tcc .or. Llidar_only_freq_cloud .or. Lcloudsat_tcc .or. Lcloudsat_tcc2) then - + print*,'CLOUDSAT/CALIPSO joint' if (use_vgrid) then allocate(lidar_only_freq_cloud(cloudsatIN%Npoints,Nlvgrid), & radar_lidar_tcc(cloudsatIN%Npoints), cloudsat_tcc(cloudsatIN%Npoints), & cloudsat_tcc2(cloudsatIN%Npoints)) allocate(betamol_in(cloudsatIN%Npoints,1,cloudsatIN%Nlevels), & - betamoli(cloudsatIN%Npoints,1,Nlvgrid), & + betamolI(cloudsatIN%Npoints,1,Nlvgrid), & pnormI(cloudsatIN%Npoints,cloudsatIN%Ncolumns,Nlvgrid), & Ze_totI(cloudsatIN%Npoints,cloudsatIN%Ncolumns,Nlvgrid)) ! Regrid in the vertical (*NOTE* This routine requires SFC-2-TOA ordering, so flip ! inputs and outputs to maintain TOA-2-SFC ordering convention in COSP2.) - betamol_in(:,1,:) = calipso_beta_mol(:,cloudsatIN%Nlevels:1:-1) - call cosp_change_vertical_grid(cloudsatIN%Npoints,1,cloudsatIN%Nlevels, & - cospgridIN%hgt_matrix(:,cloudsatIN%Nlevels:1:-1), & - cospgridIN%hgt_matrix_half(:,cloudsatIN%Nlevels:1:-1),betamol_in, & - Nlvgrid,vgrid_zl(Nlvgrid:1:-1),vgrid_zu(Nlvgrid:1:-1), & - betamolI(:,1,Nlvgrid:1:-1)) - - call cosp_change_vertical_grid(cloudsatIN%Npoints,cloudsatIN%Ncolumns, & - cloudsatIN%Nlevels,cospgridIN%hgt_matrix(:,cloudsatIN%Nlevels:1:-1), & - cospgridIN%hgt_matrix_half(:,cloudsatIN%Nlevels:1:-1), & - calipso_beta_tot(:,:,cloudsatIN%Nlevels:1:-1),Nlvgrid, & - vgrid_zl(Nlvgrid:1:-1),vgrid_zu(Nlvgrid:1:-1),pnormI(:,:,Nlvgrid:1:-1)) - - call cosp_change_vertical_grid(cloudsatIN%Npoints,cloudsatIN%Ncolumns, & - cloudsatIN%Nlevels,cospgridIN%hgt_matrix(:,cloudsatIN%Nlevels:1:-1), & - cospgridIN%hgt_matrix_half(:,cloudsatIN%Nlevels:1:-1), & - cloudsatDBZe(:,:,cloudsatIN%Nlevels:1:-1),Nlvgrid,vgrid_zl(Nlvgrid:1:-1), & - vgrid_zu(Nlvgrid:1:-1),Ze_totI(:,:,Nlvgrid:1:-1),log_units=.true.) - + print*,'CLOUDSAT/CALIPSO joint-1' + ! print*,'allocated(CSCAL_MASK_INDICES): ',allocated(CSCAL_MASK_INDICES) + ! print*,'allocated(calipso_beta_mol): ',allocated(calipso_beta_mol) + ! print*,'allocated(cloudsatDBZe): ',allocated(cloudsatDBZe) + ! Use CLOUDSAT masking array here (it should be the same as calipso) + if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + betamol_in(:,1,:) = calipso_beta_mol(:,cloudsatIN%Nlevels:1:-1) + call cosp_change_vertical_grid(cloudsatIN%Npoints,1,cloudsatIN%Nlevels, & + cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & + cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1),betamol_in, & + Nlvgrid,vgrid_zl(Nlvgrid:1:-1),vgrid_zu(Nlvgrid:1:-1), & + betamolI(:,1,Nlvgrid:1:-1)) + call cosp_change_vertical_grid(cloudsatIN%Npoints,cloudsatIN%Ncolumns, & + cloudsatIN%Nlevels,cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & + cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & + calipso_beta_tot(:,:,cloudsatIN%Nlevels:1:-1),Nlvgrid, & + vgrid_zl(Nlvgrid:1:-1),vgrid_zu(Nlvgrid:1:-1),pnormI(:,:,Nlvgrid:1:-1)) + call cosp_change_vertical_grid(cloudsatIN%Npoints,cloudsatIN%Ncolumns, & + cloudsatIN%Nlevels,cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & + cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & + cloudsatDBZe(:,:,cloudsatIN%Nlevels:1:-1),Nlvgrid,vgrid_zl(Nlvgrid:1:-1), & + vgrid_zu(Nlvgrid:1:-1),Ze_totI(:,:,Nlvgrid:1:-1),log_units=.true.) + print*,'CLOUDSAT/CALIPSO joint-2' + else + betamol_in(:,1,:) = calipso_beta_mol(:,cloudsatIN%Nlevels:1:-1) + call cosp_change_vertical_grid(cloudsatIN%Npoints,1,cloudsatIN%Nlevels, & + cospgridIN%hgt_matrix(:,cloudsatIN%Nlevels:1:-1), & + cospgridIN%hgt_matrix_half(:,cloudsatIN%Nlevels:1:-1),betamol_in, & + Nlvgrid,vgrid_zl(Nlvgrid:1:-1),vgrid_zu(Nlvgrid:1:-1), & + betamolI(:,1,Nlvgrid:1:-1)) + + call cosp_change_vertical_grid(cloudsatIN%Npoints,cloudsatIN%Ncolumns, & + cloudsatIN%Nlevels,cospgridIN%hgt_matrix(:,cloudsatIN%Nlevels:1:-1), & + cospgridIN%hgt_matrix_half(:,cloudsatIN%Nlevels:1:-1), & + calipso_beta_tot(:,:,cloudsatIN%Nlevels:1:-1),Nlvgrid, & + vgrid_zl(Nlvgrid:1:-1),vgrid_zu(Nlvgrid:1:-1),pnormI(:,:,Nlvgrid:1:-1)) + + call cosp_change_vertical_grid(cloudsatIN%Npoints,cloudsatIN%Ncolumns, & + cloudsatIN%Nlevels,cospgridIN%hgt_matrix(:,cloudsatIN%Nlevels:1:-1), & + cospgridIN%hgt_matrix_half(:,cloudsatIN%Nlevels:1:-1), & + cloudsatDBZe(:,:,cloudsatIN%Nlevels:1:-1),Nlvgrid,vgrid_zl(Nlvgrid:1:-1), & + vgrid_zu(Nlvgrid:1:-1),Ze_totI(:,:,Nlvgrid:1:-1),log_units=.true.) + print*,'CLOUDSAT/CALIPSO joint-2b' + end if call cosp_lidar_only_cloud(cloudsatIN%Npoints, cloudsatIN%Ncolumns, Nlvgrid, & - pnormI, betamolI, Ze_totI, lidar_only_freq_cloud, radar_lidar_tcc, & - cloudsat_tcc, cloudsat_tcc2) - + pnormI, betamolI, Ze_totI, lidar_only_freq_cloud, radar_lidar_tcc, & + cloudsat_tcc, cloudsat_tcc2) deallocate(betamol_in,betamolI,pnormI,ze_totI) else allocate(lidar_only_freq_cloud(cloudsatIN%Npoints,cloudsatIN%Nlevels), & radar_lidar_tcc(cloudsatIN%Npoints), cloudsat_tcc(cloudsatIN%Npoints), & cloudsat_tcc2(cloudsatIN%Npoints)) + print*,'CLOUDSAT/CALIPSO joint-3' call cosp_lidar_only_cloud(cloudsatIN%Npoints,cloudsatIN%Ncolumns, & cospIN%Nlevels,calipso_beta_tot(:,:,cloudsatIN%Nlevels:1:-1), & calipso_beta_mol(:,cloudsatIN%Nlevels:1:-1), & cloudsatDBZe(:,:,cloudsatIN%Nlevels:1:-1),lidar_only_freq_cloud, & radar_lidar_tcc, cloudsat_tcc, cloudsat_tcc2) + print*,'CLOUDSAT/CALIPSO joint-4' endif ! Store, when necessary - if (associated(cospOUT%lidar_only_freq_cloud)) then - cospOUT%lidar_only_freq_cloud(ij:ik,:) = lidar_only_freq_cloud - endif - if (associated(cospOUT%radar_lidar_tcc)) then - cospOUT%radar_lidar_tcc(ij:ik) = radar_lidar_tcc - endif - if (associated(cospOUT%cloudsat_tcc)) then - cospOUT%cloudsat_tcc(ij:ik) = cloudsat_tcc - endif - if (associated(cospOUT%cloudsat_tcc2)) then - cospOUT%cloudsat_tcc2(ij:ik) = cloudsat_tcc2 + if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + if (associated(cospOUT%lidar_only_freq_cloud)) then + cospOUT%lidar_only_freq_cloud(ij:ik,:) = R_UNDEF + cospOUT%lidar_only_freq_cloud(ij+int(CSCAL_MASK_INDICES(:))-1,:) = lidar_only_freq_cloud(:,:) + endif + if (associated(cospOUT%radar_lidar_tcc)) then + cospOUT%radar_lidar_tcc(ij:ik) = R_UNDEF + cospOUT%radar_lidar_tcc(ij+int(CSCAL_MASK_INDICES(:))-1) = radar_lidar_tcc(:) + endif + if (associated(cospOUT%cloudsat_tcc)) then + cospOUT%cloudsat_tcc(ij:ik) = R_UNDEF + cospOUT%cloudsat_tcc(ij+int(CSCAL_MASK_INDICES(:))-1) = cloudsat_tcc(:) + endif + if (associated(cospOUT%cloudsat_tcc2)) then + cospOUT%cloudsat_tcc2(ij:ik) = R_UNDEF + cospOUT%cloudsat_tcc2(ij+int(CSCAL_MASK_INDICES(:))-1) = cloudsat_tcc2(:) + endif + else + if (associated(cospOUT%lidar_only_freq_cloud)) then + cospOUT%lidar_only_freq_cloud(ij:ik,:) = lidar_only_freq_cloud + endif + if (associated(cospOUT%radar_lidar_tcc)) then + cospOUT%radar_lidar_tcc(ij:ik) = radar_lidar_tcc + endif + if (associated(cospOUT%cloudsat_tcc)) then + cospOUT%cloudsat_tcc(ij:ik) = cloudsat_tcc + endif + if (associated(cospOUT%cloudsat_tcc2)) then + cospOUT%cloudsat_tcc2(ij:ik) = cloudsat_tcc2 + endif endif endif ! CloudSat/MODIS joint products (CFODDs and Occurrence Frequency of Warm Clouds) if (Lcloudsat_modis_wr) then + print*,'CLOUDSAT/MODIS joint' allocate( cfodd_ntotal(cloudsatIN%Npoints, CFODD_NDBZE, CFODD_NICOD, CFODD_NCLASS) ) allocate( wr_occfreq_ntotal(cloudsatIN%Npoints, WR_NREGIME) ) if ( use_vgrid ) then !! interporation for fixed vertical grid: + print*,'CLOUDSAT/MODIS joint-1' allocate( zlev(cloudsatIN%Npoints,Nlvgrid), & t_in(cloudsatIN%Npoints,1,cloudsatIN%Nlevels), & tempI(cloudsatIN%Npoints,1,Nlvgrid), & @@ -2282,67 +2505,154 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) do k = 1, Nlvgrid zlev(:,k) = vgrid_zu(k) enddo - t_in(:,1,:) = cospgridIN%at(:,:) - call cosp_change_vertical_grid ( & - cloudsatIN%Npoints, 1, cloudsatIN%Nlevels, & - cospgridIN%hgt_matrix(:,cloudsatIN%Nlevels:1:-1), & - cospgridIN%hgt_matrix_half(:,cloudsatIN%Nlevels:1:-1), & - t_in(:,:,cloudsatIN%Nlevels:1:-1), Nlvgrid, & - vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), & - tempI(:,:,Nlvgrid:1:-1) ) - call cosp_change_vertical_grid ( & - cloudsatIN%Npoints, cloudsatIN%Ncolumns, cloudsatIN%Nlevels, & - cospgridIN%hgt_matrix(:,cloudsatIN%Nlevels:1:-1), & - cospgridIN%hgt_matrix_half(:,cloudsatIN%Nlevels:1:-1), & - cloudsatDBZe(:,:,cloudsatIN%Nlevels:1:-1), Nlvgrid, & - vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), & - Ze_totI(:,:,Nlvgrid:1:-1), log_units=.true. ) - call cosp_change_vertical_grid ( & - cloudsatIN%Npoints, cloudsatIN%Ncolumns, cloudsatIN%Nlevels, & - cospgridIN%hgt_matrix(:,cloudsatIN%Nlevels:1:-1), & - cospgridIN%hgt_matrix_half(:,cloudsatIN%Nlevels:1:-1), & - cospIN%frac_out(:,:,cloudsatIN%Nlevels:1:-1), Nlvgrid, & - vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), & - frac_outI(:,:,Nlvgrid:1:-1) ) - call cosp_diag_warmrain( & - cloudsatIN%Npoints, cloudsatIN%Ncolumns, Nlvgrid, & !! in - tempI, zlev, & !! in - cospOUT%modis_Liquid_Water_Path_Mean, & !! in - cospOUT%modis_Optical_Thickness_Water_Mean, & !! in - cospOUT%modis_Cloud_Particle_Size_Water_Mean, & !! in - cospOUT%modis_Cloud_Fraction_Water_Mean, & !! in - cospOUT%modis_Ice_Water_Path_Mean, & !! in - cospOUT%modis_Optical_Thickness_Ice_Mean, & !! in - cospOUT%modis_Cloud_Particle_Size_Ice_Mean, & !! in - cospOUT%modis_Cloud_Fraction_Ice_Mean, & !! in - frac_outI, & !! in - Ze_totI, & !! in - cfodd_ntotal, wr_occfreq_ntotal ) !! inout + print*,'CLOUDSAT/MODIS joint-2' + ! Use CLOUDSAT masking array here (it should be the same as calipso) + if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + t_in(:,1,:) = cospgridIN%at(int(CSCAL_MASK_INDICES(:)),:) + call cosp_change_vertical_grid ( & + cloudsatIN%Npoints, 1, cloudsatIN%Nlevels, & + cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & + cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & + t_in(:,:,cloudsatIN%Nlevels:1:-1), Nlvgrid, & + vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), & + tempI(:,:,Nlvgrid:1:-1) ) + call cosp_change_vertical_grid ( & + cloudsatIN%Npoints, cloudsatIN%Ncolumns, cloudsatIN%Nlevels, & + cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & + cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & + cloudsatDBZe(:,:,cloudsatIN%Nlevels:1:-1), Nlvgrid, & + vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), & + Ze_totI(:,:,Nlvgrid:1:-1), log_units=.true. ) + call cosp_change_vertical_grid ( & + cloudsatIN%Npoints, cloudsatIN%Ncolumns, cloudsatIN%Nlevels, & + cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & + cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & + cospIN%frac_out(int(CSCAL_MASK_INDICES(:)),:,cloudsatIN%Nlevels:1:-1), Nlvgrid, & + vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), & + frac_outI(:,:,Nlvgrid:1:-1) ) + print*,'CLOUDSAT/MODIS joint-3' + call cosp_diag_warmrain( & + cloudsatIN%Npoints, cloudsatIN%Ncolumns, Nlvgrid, & !! in + tempI, zlev, & !! in + cospOUT%modis_Liquid_Water_Path_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Optical_Thickness_Water_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Cloud_Particle_Size_Water_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Cloud_Fraction_Water_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Ice_Water_Path_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Optical_Thickness_Ice_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Cloud_Particle_Size_Ice_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Cloud_Fraction_Ice_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + frac_outI, & !! in + Ze_totI, & !! in + cfodd_ntotal, wr_occfreq_ntotal ) !! inout + else + t_in(:,1,:) = cospgridIN%at(:,:) + call cosp_change_vertical_grid ( & + cloudsatIN%Npoints, 1, cloudsatIN%Nlevels, & + cospgridIN%hgt_matrix(:,cloudsatIN%Nlevels:1:-1), & + cospgridIN%hgt_matrix_half(:,cloudsatIN%Nlevels:1:-1), & + t_in(:,:,cloudsatIN%Nlevels:1:-1), Nlvgrid, & + vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), & + tempI(:,:,Nlvgrid:1:-1) ) + call cosp_change_vertical_grid ( & + cloudsatIN%Npoints, cloudsatIN%Ncolumns, cloudsatIN%Nlevels, & + cospgridIN%hgt_matrix(:,cloudsatIN%Nlevels:1:-1), & + cospgridIN%hgt_matrix_half(:,cloudsatIN%Nlevels:1:-1), & + cloudsatDBZe(:,:,cloudsatIN%Nlevels:1:-1), Nlvgrid, & + vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), & + Ze_totI(:,:,Nlvgrid:1:-1), log_units=.true. ) + call cosp_change_vertical_grid ( & + cloudsatIN%Npoints, cloudsatIN%Ncolumns, cloudsatIN%Nlevels, & + cospgridIN%hgt_matrix(:,cloudsatIN%Nlevels:1:-1), & + cospgridIN%hgt_matrix_half(:,cloudsatIN%Nlevels:1:-1), & + cospIN%frac_out(:,:,cloudsatIN%Nlevels:1:-1), Nlvgrid, & + vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), & + frac_outI(:,:,Nlvgrid:1:-1) ) + print*,'CLOUDSAT/MODIS joint-3b' + call cosp_diag_warmrain( & + cloudsatIN%Npoints, cloudsatIN%Ncolumns, Nlvgrid, & !! in + tempI, zlev, & !! in + cospOUT%modis_Liquid_Water_Path_Mean(ij:ik), & !! in ! JKS fix bug here. + cospOUT%modis_Optical_Thickness_Water_Mean(ij:ik), & !! in + cospOUT%modis_Cloud_Particle_Size_Water_Mean(ij:ik), & !! in + cospOUT%modis_Cloud_Fraction_Water_Mean(ij:ik), & !! in + cospOUT%modis_Ice_Water_Path_Mean(ij:ik), & !! in + cospOUT%modis_Optical_Thickness_Ice_Mean(ij:ik), & !! in + cospOUT%modis_Cloud_Particle_Size_Ice_Mean(ij:ik), & !! in + cospOUT%modis_Cloud_Fraction_Ice_Mean(ij:ik), & !! in + frac_outI, & !! in + Ze_totI, & !! in + cfodd_ntotal, wr_occfreq_ntotal ) !! inout + endif + print*,'CLOUDSAT/MODIS joint-4' deallocate( zlev, t_in, tempI, frac_outI, Ze_totI ) else ! do not use vgrid interporation ---------------------------------------! !! original model grid - call cosp_diag_warmrain( & - cloudsatIN%Npoints, cloudsatIN%Ncolumns, cospIN%Nlevels, & !! in - cospgridIN%at, cospgridIN%hgt_matrix, & !! in - cospOUT%modis_Liquid_Water_Path_Mean, & !! in - cospOUT%modis_Optical_Thickness_Water_Mean, & !! in - cospOUT%modis_Cloud_Particle_Size_Water_Mean, & !! in - cospOUT%modis_Cloud_Fraction_Water_Mean, & !! in - cospOUT%modis_Ice_Water_Path_Mean, & !! in - cospOUT%modis_Optical_Thickness_Ice_Mean, & !! in - cospOUT%modis_Cloud_Particle_Size_Ice_Mean, & !! in - cospOUT%modis_Cloud_Fraction_Ice_Mean, & !! in - cospIN%frac_out, & !! in - cloudsatDBZe, & !! in - cfodd_ntotal, wr_occfreq_ntotal ) !! inout + print*,'CLOUDSAT/MODIS joint-5' + if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + call cosp_diag_warmrain( & + cloudsatIN%Npoints, cloudsatIN%Ncolumns, cospIN%Nlevels, & !! in + cospgridIN%at(int(CSCAL_MASK_INDICES(:)),:), cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES(:)),:), & !! in + cospOUT%modis_Liquid_Water_Path_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Optical_Thickness_Water_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Cloud_Particle_Size_Water_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Cloud_Fraction_Water_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Ice_Water_Path_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Optical_Thickness_Ice_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Cloud_Particle_Size_Ice_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Cloud_Fraction_Ice_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospIN%frac_out(int(CSCAL_MASK_INDICES(:)),:,:), & !! in + cloudsatDBZe, & !! in + cfodd_ntotal, wr_occfreq_ntotal ) !! inout + else + call cosp_diag_warmrain( & + cloudsatIN%Npoints, cloudsatIN%Ncolumns, cospIN%Nlevels, & !! in + cospgridIN%at, cospgridIN%hgt_matrix, & !! in + cospOUT%modis_Liquid_Water_Path_Mean(ij:ik), & !! in + cospOUT%modis_Optical_Thickness_Water_Mean(ij:ik), & !! in + cospOUT%modis_Cloud_Particle_Size_Water_Mean(ij:ik), & !! in + cospOUT%modis_Cloud_Fraction_Water_Mean(ij:ik), & !! in + cospOUT%modis_Ice_Water_Path_Mean(ij:ik), & !! in + cospOUT%modis_Optical_Thickness_Ice_Mean(ij:ik), & !! in + cospOUT%modis_Cloud_Particle_Size_Ice_Mean(ij:ik), & !! in + cospOUT%modis_Cloud_Fraction_Ice_Mean(ij:ik), & !! in + cospIN%frac_out, & !! in + cloudsatDBZe, & !! in + cfodd_ntotal, wr_occfreq_ntotal ) !! inout + endif + print*,'CLOUDSAT/MODIS joint-6' endif !! use_vgrid or not ! Store, when necessary - if ( associated(cospOUT%cfodd_ntotal) ) then - cospOUT%cfodd_ntotal(ij:ik,:,:,:) = cfodd_ntotal - endif - if ( associated(cospOUT%wr_occfreq_ntotal) ) then - cospOUT%wr_occfreq_ntotal(ij:ik,:) = wr_occfreq_ntotal + cospOUT%lidar_only_freq_cloud(ij+int(CSCAL_MASK_INDICES(:))-1,:) = lidar_only_freq_cloud(:,:) + + if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays for CSCAL + if (cospIN % cospswathsIN(6) % N_inst_swaths .gt. 0) then ! If MODIS is also swathed then use the joint mask MODIS_CSCAL_MASK_INDICES for setting R_UNDEF + if ( associated(cospOUT%cfodd_ntotal) ) then + cospOUT%cfodd_ntotal(ij+int(CSCAL_MASK_INDICES(:))-1,:,:,:) = cfodd_ntotal + cospOUT%cfodd_ntotal(ij+int(MODIS_CSCAL_MASK_INDICES(:))-1,:,:,:) = R_UNDEF + endif + if ( associated(cospOUT%wr_occfreq_ntotal) ) then + cospOUT%wr_occfreq_ntotal(ij+int(CSCAL_MASK_INDICES(:))-1,:) = wr_occfreq_ntotal + cospOUT%wr_occfreq_ntotal(ij+int(MODIS_CSCAL_MASK_INDICES(:))-1,:) = R_UNDEF + endif + else ! Otherwise just mask simpling + if ( associated(cospOUT%cfodd_ntotal) ) then + cospOUT%cfodd_ntotal(ij:ik,:,:,:) = R_UNDEF + cospOUT%cfodd_ntotal(ij+int(CSCAL_MASK_INDICES(:))-1,:,:,:) = cfodd_ntotal + endif + if ( associated(cospOUT%wr_occfreq_ntotal) ) then + cospOUT%wr_occfreq_ntotal(ij:ik,:) = R_UNDEF + cospOUT%wr_occfreq_ntotal(ij+int(CSCAL_MASK_INDICES(:))-1,:) = wr_occfreq_ntotal + endif + endif + else + if ( associated(cospOUT%cfodd_ntotal) ) then + cospOUT%cfodd_ntotal(ij:ik,:,:,:) = cfodd_ntotal + endif + if ( associated(cospOUT%wr_occfreq_ntotal) ) then + cospOUT%wr_occfreq_ntotal(ij:ik,:) = wr_occfreq_ntotal + endif endif endif @@ -2364,6 +2674,8 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) nullify(calipsoIN%Npoints,calipsoIN%Ncolumns,calipsoIN%Nlevels,calipsoIN%beta_mol,& calipsoIN%betatot,calipsoIN%betatot_liq,calipsoIN%betatot_ice, & calipsoIN%tau_mol,calipsoIN%tautot,calipsoIN%tautot_liq,calipsoIN%tautot_ice) + if (allocated(CSCAL_MASK_INDICES)) deallocate(CSCAL_MASK_INDICES) + if (allocated(CSCAL_SWATH_MASK)) deallocate(CSCAL_SWATH_MASK) endif if (LgrLidar532_subcolumn) then @@ -2393,6 +2705,8 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (allocated(modisIN%sunlit)) deallocate(modisIN%sunlit) if (allocated(modisIN%notSunlit)) deallocate(modisIN%notSunlit) if (allocated(modisIN%pres)) deallocate(modisIN%pres) + if (allocated(MODIS_CSCAL_MASK_INDICES)) deallocate(MODIS_CSCAL_MASK_INDICES) + if (allocated(MODIS_CSCAL_SWATH_MASK)) deallocate(MODIS_CSCAL_SWATH_MASK) endif if (Lrttov_column) then @@ -2550,7 +2864,7 @@ end subroutine cosp_cleanUp ! SUBROUTINE compute_orbitmasks !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine compute_orbitmasks(Npoints,Nlocaltimes,localtimes,localtime_widths, & - lat,lon,hour,minute,swath_mask_out) + lat,lon,hour,minute,swath_mask_out,Nswathed_out) ! Inputs integer,intent(in) :: & @@ -2570,9 +2884,11 @@ subroutine compute_orbitmasks(Npoints,Nlocaltimes,localtimes,localtime_widths, ! Output logical,dimension(Npoints),intent(out) :: & swath_mask_out ! Mask of reals over all gridcells + integer,intent(out) :: & + Nswathed_out ! Local variables - integer :: i ! iterators + integer :: i ! iterator real(wp),parameter :: & pi = 4.D0*DATAN(1.D0), & ! yum @@ -2604,6 +2920,7 @@ subroutine compute_orbitmasks(Npoints,Nlocaltimes,localtimes,localtime_widths, ! Mask is true where values should be calculated swath_mask_out = ALL( swath_mask_all(:,:),2) ! Compute mask by collapsing the localtimes dimension ! ANY(swath_mask_all,dim=1) + Nswathed_out = count(swath_mask_out) ! Mask is true where values should be masked to R_UNDEF ! swath_mask_out = ALL( swath_mask_all(:,:) .eq. .false.,2) ! Compute mask by collapsing the localtimes dimension ! ANY(swath_mask_all,dim=1) From 109dd99608a49f5c325697a1c149feab23ac330d Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 21 Feb 2024 16:26:34 -0700 Subject: [PATCH 110/159] Swathing skips when chunks are empty. Plus code cleaned up. --- src/cosp.F90 | 1510 ++++++++++++++++++++++++++------------------------ 1 file changed, 788 insertions(+), 722 deletions(-) diff --git a/src/cosp.F90 b/src/cosp.F90 index 5ded6be8d4..524958925f 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -442,7 +442,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ISCCP_MASK_INDICES, & MISR_MASK_INDICES, & CSCAL_MASK_INDICES, & - MODIS_MASK_INDICES, & PARASOL_MASK_INDICES, & ATLID_MASK_INDICES, & MODIS_CSCAL_MASK_INDICES @@ -463,9 +462,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) temp_isccp_meanptop, & temp_isccp_meantaucld, & temp_isccp_totalcldarea, & - temp_isccp_meantb, & - temp_modis_localtimes, & - temp_modis_localtime_widths + temp_isccp_meantb real(wp),dimension(:,:),target,allocatable :: & temp_isccp_qv, & temp_isccp_at, & @@ -480,7 +477,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) integer,dimension(:),target,allocatable :: & temp_misr_sunlit real(wp),dimension(:),target,allocatable :: & - temp_misr_cldarea, & + temp_misr_cldarea, & temp_misr_meanztop real(wp),dimension(:,:),target,allocatable :: & temp_misr_zfull, & @@ -539,11 +536,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) temp_g_vol_cloudsat, & temp_cloudsat_cfad_ze ! MODIS swathing variables. - real(wp),dimension(:,:,:),target,allocatable :: & - temp_modis_liqFrac, & - temp_modis_tau, & - temp_modis_g, & - temp_modis_w0 real(wp),dimension(:,:),allocatable :: & modis_boxptop, & modis_boxttop, & @@ -787,12 +779,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! 3) Populate instrument simulator inputs !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! JKS need to encode swathing inputs here. - print*,'cospIN % cospswathsIN(1) % N_inst_swaths: ',cospIN % cospswathsIN(1) % N_inst_swaths - print*,'cospIN % cospswathsIN(1) % inst_localtime_widths: ',cospIN % cospswathsIN(1) % inst_localtime_widths - print*,'cospIN % cospswathsIN(1) % inst_localtimes: ',cospIN % cospswathsIN(1) % inst_localtimes - ! Indexing order is ISCCP, MISR, CLOUDSAT-CALIPSO, ATLID, PARASOL, MODIS - + ! Indexing order for "cospIN % cospswathsIN" is ISCCP, MISR, CLOUDSAT-CALIPSO, ATLID, PARASOL, MODIS if (Lisccp_subcolumn .or. Lmodis_subcolumn) then if (cospIN % cospswathsIN(1) % N_inst_swaths .gt. 0) then allocate(ISCCP_SWATH_MASK(Npoints)) @@ -806,39 +793,38 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ISCCP_SWATH_MASK,N_ISCCP_SWATHED) ! Output: logical mask array isccpIN%Npoints => N_ISCCP_SWATHED ISCCP_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = ISCCP_SWATH_MASK) - print*,'isccpIN%Npoints: ',isccpIN%Npoints - print*,'ISCCP_SWATH_MASK: ',ISCCP_SWATH_MASK - ! Allocate swathed arrays. - allocate(temp_isccp_skt(isccpIN%Npoints),temp_isccp_qv(isccpIN%Npoints,cospIN%Nlevels),temp_isccp_at(isccpIN%Npoints,cospIN%Nlevels), & - temp_isccp_frac_out(isccpIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels),temp_isccp_tau_067(isccpIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & - temp_isccp_emiss_11(isccpIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels),temp_isccp_phalf(isccpIN%Npoints,cospIN%Nlevels+1), & - temp_isccp_pfull(isccpIN%Npoints,cospIN%Nlevels),temp_isccp_sunlit(isccpIN%Npoints)) - ! Encode step: Read only appropriate values into the new temp arrays. - temp_isccp_skt(:) = cospgridIN%skt(int(ISCCP_MASK_INDICES)) - temp_isccp_qv(:,:) = cospgridIN%qv(int(ISCCP_MASK_INDICES),:) - temp_isccp_at(:,:) = cospgridIN%at(int(ISCCP_MASK_INDICES),:) - temp_isccp_frac_out(:,:,:) = cospIN%frac_out(int(ISCCP_MASK_INDICES),:,:) - temp_isccp_tau_067(:,:,:) = cospIN%tau_067(int(ISCCP_MASK_INDICES),:,:) - temp_isccp_emiss_11(:,:,:) = cospIN%emiss_11(int(ISCCP_MASK_INDICES),:,:) - temp_isccp_phalf(:,:) = cospgridIN%phalf(int(ISCCP_MASK_INDICES),:) - temp_isccp_pfull(:,:) = cospgridIN%pfull(int(ISCCP_MASK_INDICES),:) - temp_isccp_sunlit(:) = cospgridIN%sunlit(int(ISCCP_MASK_INDICES)) - - ! print*,'int(ISCCP_MASK_INDICES): ',int(ISCCP_MASK_INDICES) - ! print*,'temp_isccp_sunlit: ',temp_isccp_sunlit - ! print*,'cospgridIN%sunlit: ',cospgridIN%sunlit - isccpIN%Ncolumns => cospIN%Ncolumns - isccpIN%Nlevels => cospIN%Nlevels - isccpIN%emsfc_lw => cospIN%emsfc_lw - isccpIN%skt => temp_isccp_skt - isccpIN%qv => temp_isccp_qv - isccpIN%at => temp_isccp_at - isccpIN%frac_out => temp_isccp_frac_out - isccpIN%dtau => temp_isccp_tau_067 - isccpIN%dem => temp_isccp_emiss_11 - isccpIN%phalf => temp_isccp_phalf - isccpIN%pfull => temp_isccp_pfull - isccpIN%sunlit => temp_isccp_sunlit + if (verbose) print*,'isccpIN%Npoints: ',isccpIN%Npoints + if (verbose) print*,'ISCCP_SWATH_MASK: ',ISCCP_SWATH_MASK + if (isccpIN%Npoints .gt. 0) then + ! Allocate swathed arrays. + allocate(temp_isccp_skt(isccpIN%Npoints),temp_isccp_qv(isccpIN%Npoints,cospIN%Nlevels),temp_isccp_at(isccpIN%Npoints,cospIN%Nlevels), & + temp_isccp_frac_out(isccpIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels),temp_isccp_tau_067(isccpIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_isccp_emiss_11(isccpIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels),temp_isccp_phalf(isccpIN%Npoints,cospIN%Nlevels+1), & + temp_isccp_pfull(isccpIN%Npoints,cospIN%Nlevels),temp_isccp_sunlit(isccpIN%Npoints)) + ! Encode step: Read only appropriate values into the new temp arrays. + temp_isccp_skt(:) = cospgridIN%skt(int(ISCCP_MASK_INDICES)) + temp_isccp_qv(:,:) = cospgridIN%qv(int(ISCCP_MASK_INDICES),:) + temp_isccp_at(:,:) = cospgridIN%at(int(ISCCP_MASK_INDICES),:) + temp_isccp_frac_out(:,:,:) = cospIN%frac_out(int(ISCCP_MASK_INDICES),:,:) + temp_isccp_tau_067(:,:,:) = cospIN%tau_067(int(ISCCP_MASK_INDICES),:,:) + temp_isccp_emiss_11(:,:,:) = cospIN%emiss_11(int(ISCCP_MASK_INDICES),:,:) + temp_isccp_phalf(:,:) = cospgridIN%phalf(int(ISCCP_MASK_INDICES),:) + temp_isccp_pfull(:,:) = cospgridIN%pfull(int(ISCCP_MASK_INDICES),:) + temp_isccp_sunlit(:) = cospgridIN%sunlit(int(ISCCP_MASK_INDICES)) + + isccpIN%Ncolumns => cospIN%Ncolumns + isccpIN%Nlevels => cospIN%Nlevels + isccpIN%emsfc_lw => cospIN%emsfc_lw + isccpIN%skt => temp_isccp_skt + isccpIN%qv => temp_isccp_qv + isccpIN%at => temp_isccp_at + isccpIN%frac_out => temp_isccp_frac_out + isccpIN%dtau => temp_isccp_tau_067 + isccpIN%dem => temp_isccp_emiss_11 + isccpIN%phalf => temp_isccp_phalf + isccpIN%pfull => temp_isccp_pfull + isccpIN%sunlit => temp_isccp_sunlit + end if else isccpIN%Npoints => Npoints isccpIN%Ncolumns => cospIN%Ncolumns @@ -858,7 +844,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (Lmisr_subcolumn) then if (cospIN % cospswathsIN(2) % N_inst_swaths .gt. 0) then - print*,'MISR SWATHING' allocate(MISR_SWATH_MASK(Npoints)) ! Do swathing to figure out which cells to simulate on call compute_orbitmasks(Npoints, & @@ -870,25 +855,27 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) MISR_SWATH_MASK,N_MISR_SWATHED) ! Output: logical mask array misrIN%Npoints => N_MISR_SWATHED MISR_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = MISR_SWATH_MASK) - print*,'misrIN%Npoints: ',misrIN%Npoints - print*,'MISR_SWATH_MASK: ',MISR_SWATH_MASK - ! Allocate swathed arrays. - allocate(temp_misr_dtau(misrIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & - temp_misr_sunlit(misrIN%Npoints), & - temp_misr_zfull(misrIN%Npoints,cospIN%Nlevels), & - temp_misr_at(misrIN%Npoints,cospIN%Nlevels)) - ! Encode step: Read only appropriate values into the new temp arrays. - temp_misr_dtau(:,:,:) = cospIN%tau_067(int(MISR_MASK_INDICES),:,:) - temp_misr_at(:,:) = cospgridIN%at(int(MISR_MASK_INDICES),:) - temp_misr_zfull(:,:) = cospgridIN%hgt_matrix(int(MISR_MASK_INDICES),:) - temp_misr_sunlit(:) = cospgridIN%sunlit(int(MISR_MASK_INDICES)) - - misrIN%Ncolumns => cospIN%Ncolumns - misrIN%Nlevels => cospIN%Nlevels - misrIN%dtau => temp_misr_dtau - misrIN%sunlit => temp_misr_sunlit - misrIN%zfull => temp_misr_zfull - misrIN%at => temp_misr_at + if (verbose) print*,'misrIN%Npoints: ',misrIN%Npoints + if (verbose) print*,'MISR_SWATH_MASK: ',MISR_SWATH_MASK + if (misrIN%Npoints .gt. 0) then + ! Allocate swathed arrays. + allocate(temp_misr_dtau(misrIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_misr_sunlit(misrIN%Npoints), & + temp_misr_zfull(misrIN%Npoints,cospIN%Nlevels), & + temp_misr_at(misrIN%Npoints,cospIN%Nlevels)) + ! Encode step: Read only appropriate values into the new temp arrays. + temp_misr_dtau(:,:,:) = cospIN%tau_067(int(MISR_MASK_INDICES),:,:) + temp_misr_at(:,:) = cospgridIN%at(int(MISR_MASK_INDICES),:) + temp_misr_zfull(:,:) = cospgridIN%hgt_matrix(int(MISR_MASK_INDICES),:) + temp_misr_sunlit(:) = cospgridIN%sunlit(int(MISR_MASK_INDICES)) + + misrIN%Ncolumns => cospIN%Ncolumns + misrIN%Nlevels => cospIN%Nlevels + misrIN%dtau => temp_misr_dtau + misrIN%sunlit => temp_misr_sunlit + misrIN%zfull => temp_misr_zfull + misrIN%at => temp_misr_at + end if else misrIN%Npoints => Npoints misrIN%Ncolumns => cospIN%Ncolumns @@ -902,7 +889,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (Lcalipso_subcolumn) then if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then - print*,'CALIPSO SWATHING' allocate(CSCAL_SWATH_MASK(Npoints)) ! Do swathing to figure out which cells to simulate on call compute_orbitmasks(Npoints, & @@ -914,36 +900,38 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) CSCAL_SWATH_MASK, N_CSCAL_SWATHED) ! Output: logical mask array calipsoIN%Npoints => N_CSCAL_SWATHED CSCAL_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = CSCAL_SWATH_MASK) - print*,'calipsoIN%Npoints: ',calipsoIN%Npoints - print*,'CSCAL_SWATH_MASK: ',CSCAL_SWATH_MASK - ! Allocate swathed arrays. - allocate(temp_beta_mol_calipso(calipsoIN%Npoints,cospIN%Nlevels), & - temp_tau_mol_calipso(calipsoIN%Npoints,cospIN%Nlevels), & - temp_betatot_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & - temp_tautot_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & - temp_betatot_liq_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & - temp_tautot_liq_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & - temp_betatot_ice_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & - temp_tautot_ice_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels)) - ! Encode step: Read only appropriate values into the new temp arrays. - temp_beta_mol_calipso(:,:) = cospIN%beta_mol_calipso(int(CSCAL_MASK_INDICES),:) - temp_tau_mol_calipso(:,:) = cospIN%tau_mol_calipso(int(CSCAL_MASK_INDICES),:) - temp_betatot_calipso(:,:,:) = cospIN%betatot_calipso(int(CSCAL_MASK_INDICES),:,:) - temp_tautot_calipso(:,:,:) = cospIN%tautot_calipso(int(CSCAL_MASK_INDICES),:,:) - temp_betatot_liq_calipso(:,:,:) = cospIN%betatot_liq_calipso(int(CSCAL_MASK_INDICES),:,:) - temp_tautot_liq_calipso(:,:,:) = cospIN%tautot_liq_calipso(int(CSCAL_MASK_INDICES),:,:) - temp_betatot_ice_calipso(:,:,:) = cospIN%betatot_ice_calipso(int(CSCAL_MASK_INDICES),:,:) - temp_tautot_ice_calipso(:,:,:) = cospIN%tautot_ice_calipso(int(CSCAL_MASK_INDICES),:,:) - calipsoIN%Ncolumns => cospIN%Ncolumns - calipsoIN%Nlevels => cospIN%Nlevels - calipsoIN%beta_mol => temp_beta_mol_calipso - calipsoIN%betatot => temp_betatot_calipso - calipsoIN%betatot_liq => temp_betatot_liq_calipso - calipsoIN%betatot_ice => temp_betatot_ice_calipso - calipsoIN%tau_mol => temp_tau_mol_calipso - calipsoIN%tautot => temp_tautot_calipso - calipsoIN%tautot_liq => temp_tautot_liq_calipso - calipsoIN%tautot_ice => temp_tautot_ice_calipso + if (verbose) print*,'calipsoIN%Npoints: ',calipsoIN%Npoints + if (verbose) print*,'CSCAL_SWATH_MASK: ',CSCAL_SWATH_MASK + if (calipsoIN%Npoints .gt. 0) then + ! Allocate swathed arrays. + allocate(temp_beta_mol_calipso(calipsoIN%Npoints,cospIN%Nlevels), & + temp_tau_mol_calipso(calipsoIN%Npoints,cospIN%Nlevels), & + temp_betatot_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_tautot_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_betatot_liq_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_tautot_liq_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_betatot_ice_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_tautot_ice_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels)) + ! Encode step: Read only appropriate values into the new temp arrays. + temp_beta_mol_calipso(:,:) = cospIN%beta_mol_calipso(int(CSCAL_MASK_INDICES),:) + temp_tau_mol_calipso(:,:) = cospIN%tau_mol_calipso(int(CSCAL_MASK_INDICES),:) + temp_betatot_calipso(:,:,:) = cospIN%betatot_calipso(int(CSCAL_MASK_INDICES),:,:) + temp_tautot_calipso(:,:,:) = cospIN%tautot_calipso(int(CSCAL_MASK_INDICES),:,:) + temp_betatot_liq_calipso(:,:,:) = cospIN%betatot_liq_calipso(int(CSCAL_MASK_INDICES),:,:) + temp_tautot_liq_calipso(:,:,:) = cospIN%tautot_liq_calipso(int(CSCAL_MASK_INDICES),:,:) + temp_betatot_ice_calipso(:,:,:) = cospIN%betatot_ice_calipso(int(CSCAL_MASK_INDICES),:,:) + temp_tautot_ice_calipso(:,:,:) = cospIN%tautot_ice_calipso(int(CSCAL_MASK_INDICES),:,:) + calipsoIN%Ncolumns => cospIN%Ncolumns + calipsoIN%Nlevels => cospIN%Nlevels + calipsoIN%beta_mol => temp_beta_mol_calipso + calipsoIN%betatot => temp_betatot_calipso + calipsoIN%betatot_liq => temp_betatot_liq_calipso + calipsoIN%betatot_ice => temp_betatot_ice_calipso + calipsoIN%tau_mol => temp_tau_mol_calipso + calipsoIN%tautot => temp_tautot_calipso + calipsoIN%tautot_liq => temp_tautot_liq_calipso + calipsoIN%tautot_ice => temp_tautot_ice_calipso + endif else calipsoIN%Npoints => Npoints calipsoIN%Ncolumns => cospIN%Ncolumns @@ -971,7 +959,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (Latlid_subcolumn) then if (cospIN % cospswathsIN(4) % N_inst_swaths .gt. 0) then - print*,'ATLID SWATHING' allocate(ATLID_SWATH_MASK(Npoints)) ! Do swathing to figure out which cells to simulate on call compute_orbitmasks(Npoints, & @@ -983,24 +970,26 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ATLID_SWATH_MASK, N_ATLID_SWATHED) ! Output: logical mask array atlidIN%Npoints => N_ATLID_SWATHED ATLID_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = ATLID_SWATH_MASK) - print*,'atlidIN%Npoints: ',atlidIN%Npoints - print*,'ATLID_SWATH_MASK: ',ATLID_SWATH_MASK - ! Allocate swathed arrays. - allocate(temp_beta_mol_atlid(atlidIN%Npoints,cospIN%Nlevels), & - temp_betatot_atlid(atlidIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & - temp_tau_mol_atlid(atlidIN%Npoints,cospIN%Nlevels), & - temp_tautot_atlid(atlidIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels)) - ! Encode step: Read only appropriate values into the new temp arrays. - temp_beta_mol_atlid(:,:) = cospIN%beta_mol_atlid(int(ATLID_MASK_INDICES),:) - temp_tau_mol_atlid(:,:) = cospIN%tau_mol_atlid(int(ATLID_MASK_INDICES),:) - temp_betatot_atlid(:,:,:) = cospIN%betatot_atlid(int(ATLID_MASK_INDICES),:,:) - temp_tautot_atlid(:,:,:) = cospIN%tautot_atlid(int(ATLID_MASK_INDICES),:,:) - atlidIN%Ncolumns => cospIN%Ncolumns - atlidIN%Nlevels => cospIN%Nlevels - atlidIN%beta_mol_atlid => temp_beta_mol_atlid - atlidIN%betatot_atlid => temp_betatot_atlid - atlidIN%tau_mol_atlid => temp_tau_mol_atlid - atlidIN%tautot_atlid => temp_tautot_atlid + if (verbose) print*,'atlidIN%Npoints: ',atlidIN%Npoints + if (verbose) print*,'ATLID_SWATH_MASK: ',ATLID_SWATH_MASK + if (atlidIN%Npoints .gt. 0) then + ! Allocate swathed arrays. + allocate(temp_beta_mol_atlid(atlidIN%Npoints,cospIN%Nlevels), & + temp_betatot_atlid(atlidIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_tau_mol_atlid(atlidIN%Npoints,cospIN%Nlevels), & + temp_tautot_atlid(atlidIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels)) + ! Encode step: Read only appropriate values into the new temp arrays. + temp_beta_mol_atlid(:,:) = cospIN%beta_mol_atlid(int(ATLID_MASK_INDICES),:) + temp_tau_mol_atlid(:,:) = cospIN%tau_mol_atlid(int(ATLID_MASK_INDICES),:) + temp_betatot_atlid(:,:,:) = cospIN%betatot_atlid(int(ATLID_MASK_INDICES),:,:) + temp_tautot_atlid(:,:,:) = cospIN%tautot_atlid(int(ATLID_MASK_INDICES),:,:) + atlidIN%Ncolumns => cospIN%Ncolumns + atlidIN%Nlevels => cospIN%Nlevels + atlidIN%beta_mol_atlid => temp_beta_mol_atlid + atlidIN%betatot_atlid => temp_betatot_atlid + atlidIN%tau_mol_atlid => temp_tau_mol_atlid + atlidIN%tautot_atlid => temp_tautot_atlid + endif else atlidIN%Npoints => Npoints atlidIN%Ncolumns => cospIN%Ncolumns @@ -1009,12 +998,11 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) atlidIN%betatot_atlid => cospIN%betatot_atlid atlidIN%tau_mol_atlid => cospIN%tau_mol_atlid atlidIN%tautot_atlid => cospIN%tautot_atlid - end if + endif endif if (Lparasol_subcolumn) then if (cospIN % cospswathsIN(5) % N_inst_swaths .gt. 0) then - print*,'PARASOL SWATHING' allocate(PARASOL_SWATH_MASK(Npoints)) ! Do swathing to figure out which cells to simulate on call compute_orbitmasks(Npoints, & @@ -1026,19 +1014,21 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) PARASOL_SWATH_MASK, N_PARASOL_SWATHED) ! Output: logical mask array parasolIN%Npoints => N_PARASOL_SWATHED PARASOL_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = PARASOL_SWATH_MASK) - print*,'parasolIN%Npoints: ',parasolIN%Npoints - print*,'PARASOL_SWATH_MASK: ',PARASOL_SWATH_MASK - ! Allocate swathed arrays. - allocate(temp_tautot_S_liq(parasolIN%Npoints,cospIN%Ncolumns), & - temp_tautot_S_ice(parasolIN%Npoints,cospIN%Ncolumns)) - ! Encode step: Read only appropriate values into the new temp arrays. - temp_tautot_S_liq(:,:) = cospIN%tautot_S_liq(int(PARASOL_MASK_INDICES),:) - temp_tautot_S_ice(:,:) = cospIN%tautot_S_ice(int(PARASOL_MASK_INDICES),:) - parasolIN%Nlevels => cospIN%Nlevels - parasolIN%Ncolumns => cospIN%Ncolumns - parasolIN%Nrefl => cospIN%Nrefl - parasolIN%tautot_S_liq => temp_tautot_S_liq - parasolIN%tautot_S_ice => temp_tautot_S_ice + if (verbose) print*,'parasolIN%Npoints: ',parasolIN%Npoints + if (verbose) print*,'PARASOL_SWATH_MASK: ',PARASOL_SWATH_MASK + if (parasolIN%Npoints .gt. 0) then + ! Allocate swathed arrays. + allocate(temp_tautot_S_liq(parasolIN%Npoints,cospIN%Ncolumns), & + temp_tautot_S_ice(parasolIN%Npoints,cospIN%Ncolumns)) + ! Encode step: Read only appropriate values into the new temp arrays. + temp_tautot_S_liq(:,:) = cospIN%tautot_S_liq(int(PARASOL_MASK_INDICES),:) + temp_tautot_S_ice(:,:) = cospIN%tautot_S_ice(int(PARASOL_MASK_INDICES),:) + parasolIN%Nlevels => cospIN%Nlevels + parasolIN%Ncolumns => cospIN%Ncolumns + parasolIN%Nrefl => cospIN%Nrefl + parasolIN%tautot_S_liq => temp_tautot_S_liq + parasolIN%tautot_S_ice => temp_tautot_S_ice + endif else parasolIN%Npoints => Npoints parasolIN%Nlevels => cospIN%Nlevels @@ -1046,12 +1036,11 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) parasolIN%Nrefl => cospIN%Nrefl parasolIN%tautot_S_liq => cospIN%tautot_S_liq parasolIN%tautot_S_ice => cospIN%tautot_S_ice - end if + endif endif if (Lcloudsat_subcolumn) then if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then - print*,'CLOUDSAT SWATHING' if (.not. allocated(CSCAL_SWATH_MASK)) then allocate(CSCAL_SWATH_MASK(Npoints)) ! Do swathing to figure out which cells to simulate on @@ -1068,26 +1057,28 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) else cloudsatIN%Npoints => N_CSCAL_SWATHED end if - print*,'cloudsatIN%Npoints: ',cloudsatIN%Npoints - print*,'CSCAL_SWATH_MASK: ',CSCAL_SWATH_MASK - ! Allocate swathed arrays. - allocate(temp_z_vol_cloudsat(cloudsatIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & - temp_kr_vol_cloudsat(cloudsatIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & - temp_g_vol_cloudsat(cloudsatIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & - temp_hgt_matrix(cloudsatIN%Npoints,cospIN%Nlevels)) - ! Encode step: Read only appropriate values into the new temp arrays. - temp_z_vol_cloudsat = cospIN%z_vol_cloudsat(int(CSCAL_MASK_INDICES),:,:) - temp_kr_vol_cloudsat = cospIN%kr_vol_cloudsat(int(CSCAL_MASK_INDICES),:,:) - temp_g_vol_cloudsat = cospIN%g_vol_cloudsat(int(CSCAL_MASK_INDICES),:,:) - temp_hgt_matrix = cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES),:) - ! Reassign swathed values. - cloudsatIN%Nlevels => cospIN%Nlevels - cloudsatIN%Ncolumns => cospIN%Ncolumns - cloudsatIN%z_vol => temp_z_vol_cloudsat - cloudsatIN%kr_vol => temp_kr_vol_cloudsat - cloudsatIN%g_vol => temp_g_vol_cloudsat - cloudsatIN%rcfg => cospIN%rcfg_cloudsat - cloudsatIN%hgt_matrix => temp_hgt_matrix + if (verbose) print*,'cloudsatIN%Npoints: ',cloudsatIN%Npoints + if (verbose) print*,'CSCAL_SWATH_MASK: ',CSCAL_SWATH_MASK + if (cloudsatIN%Npoints .gt. 0) then + ! Allocate swathed arrays. + allocate(temp_z_vol_cloudsat(cloudsatIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_kr_vol_cloudsat(cloudsatIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_g_vol_cloudsat(cloudsatIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_hgt_matrix(cloudsatIN%Npoints,cospIN%Nlevels)) + ! Encode step: Read only appropriate values into the new temp arrays. + temp_z_vol_cloudsat = cospIN%z_vol_cloudsat(int(CSCAL_MASK_INDICES),:,:) + temp_kr_vol_cloudsat = cospIN%kr_vol_cloudsat(int(CSCAL_MASK_INDICES),:,:) + temp_g_vol_cloudsat = cospIN%g_vol_cloudsat(int(CSCAL_MASK_INDICES),:,:) + temp_hgt_matrix = cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES),:) + ! Reassign swathed values. + cloudsatIN%Nlevels => cospIN%Nlevels + cloudsatIN%Ncolumns => cospIN%Ncolumns + cloudsatIN%z_vol => temp_z_vol_cloudsat + cloudsatIN%kr_vol => temp_kr_vol_cloudsat + cloudsatIN%g_vol => temp_g_vol_cloudsat + cloudsatIN%rcfg => cospIN%rcfg_cloudsat + cloudsatIN%hgt_matrix => temp_hgt_matrix + endif else cloudsatIN%Npoints => Npoints cloudsatIN%Nlevels => cospIN%Nlevels @@ -1102,9 +1093,8 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (Lmodis_subcolumn) then if (cospIN % cospswathsIN(6) % N_inst_swaths .gt. 0) then - print*,'MODIS SWATHING' allocate(MODIS_SWATH_MASK(Npoints)) - ! ! Do swathing to figure out which cells to simulate on + ! Do swathing to figure out which cells to simulate on call compute_orbitmasks(Npoints, & cospIN % cospswathsIN(6) % N_inst_swaths, & cospIN % cospswathsIN(6) % inst_localtimes, & @@ -1124,12 +1114,13 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) modisIN%w0 => cospIN%ss_alb allocate(modisIN%pres(modisIN%Npoints,cospIN%Nlevels+1)) ! Moving this outside of the sunlit statements for consistency with the other variables - modisIN%pres = cospgridIN%phalf modisIN%Nsunlit = count((cospgridIN%sunlit > 0) .and. MODIS_SWATH_MASK) ! Sunlit mask and indices array will just include swathing as well + modisIN%pres = cospgridIN%phalf if (modisIN%Nsunlit .gt. 0) then allocate(modisIN%sunlit(modisIN%Nsunlit)) modisIN%sunlit = pack((/ (i, i = 1, modisIN%Npoints ) /),mask = ((cospgridIN%sunlit > 0) .and. MODIS_SWATH_MASK)) ! Indices of columns to operate on in modisIN - print*,'modisIN%sunlit: ',modisIN%sunlit + if (verbose) print*,'modisIN%Nsunlit: ',modisIN%Nsunlit + if (verbose) print*,'modisIN%sunlit: ',modisIN%sunlit endif if (modisIN%Npoints - modisIN%Nsunlit .gt. 0) then ! If more than zero tiles are not sunlit and swathed, create array to mask out these gridcells in cospOUT allocate(modisIN%notSunlit(modisIN%Npoints - modisIN%Nsunlit)) @@ -1150,19 +1141,13 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) modisIN%liqFrac => cospIN%fracLiq modisIN%tau => cospIN%tau_067 modisIN%g => cospIN%asym - modisIN%w0 => cospIN%ss_alb - allocate(modisIN%pres(modisIN%Npoints,cospIN%Nlevels+1)) ! Moving this outside of the sunlit statements for consistency with the other variables - modisIN%pres = cospgridIN%phalf + modisIN%w0 => cospIN%ss_alb modisIN%Nsunlit = count(cospgridIN%sunlit > 0) - ! if (modisIN%Nsunlit .gt. 0) then - ! allocate(modisIN%sunlit(modisIN%Nsunlit),modisIN%pres(modisIN%Nsunlit,cospIN%Nlevels+1)) - ! modisIN%sunlit = pack((/ (i, i = 1, Npoints ) /),mask = cospgridIN%sunlit > 0) - ! modisIN%pres = cospgridIN%phalf(int(modisIN%sunlit(:)),:) ! JKS no reason to have this structure differently, right? Memory? - ! endif if (modisIN%Nsunlit .gt. 0) then - allocate(modisIN%sunlit(modisIN%Nsunlit)) + allocate(modisIN%sunlit(modisIN%Nsunlit),modisIN%pres(modisIN%Nsunlit,cospIN%Nlevels+1)) modisIN%sunlit = pack((/ (i, i = 1, Npoints ) /),mask = cospgridIN%sunlit > 0) - endif + modisIN%pres = cospgridIN%phalf(int(modisIN%sunlit(:)),:) ! JKS no reason to have this structure differently, right? Memory? + endif if (count(cospgridIN%sunlit <= 0) .gt. 0) then ! If more than zero tiles are not sunlit a.k.a. if there are dark tiles allocate(modisIN%notSunlit(count(cospgridIN%sunlit <= 0))) modisIN%notSunlit = pack((/ (i, i = 1, Npoints ) /),mask = .not. cospgridIN%sunlit > 0) ! Create an array with the indices of the non-sunlit tiles @@ -1213,8 +1198,8 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) rttovIN%cldIce => cospgridIN%cloudIce rttovIN%DeffLiq => cospgridIN%DeffLiq rttovIN%DeffIce => cospgridIN%DeffIce - rttovIN%fl_rain => cospgridIN%fl_rain ! JKS remove? - rttovIN%fl_snow => cospgridIN%fl_snow ! JKS remove? + rttovIN%fl_rain => cospgridIN%fl_rain ! JKS remove? No, keep in case of RTTOV-SCATT implementation. + rttovIN%fl_snow => cospgridIN%fl_snow ! JKS remove? No, keep in case of RTTOV-SCATT implementation. endif !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1223,44 +1208,50 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! ISCCP (icarus) subcolumn simulator if (Lisccp_subcolumn .or. Lmodis_subcolumn) then - print*,'ISCCP Subcol' - ! Allocate space for local variables - allocate(isccpLEVMATCH(isccpIN%Npoints,isccpIN%Ncolumns), & - isccp_boxttop(isccpIN%Npoints,isccpIN%Ncolumns), & - isccp_boxptop(isccpIN%Npoints,isccpIN%Ncolumns), & - isccp_boxtau(isccpIN%Npoints,isccpIN%Ncolumns), & - isccp_meantbclr(isccpIN%Npoints)) - if (cospIN % cospswathsIN(1) % N_inst_swaths .gt. 0) then ! MODIS and ISCCP - ! Call simulator - ! print*,'ISCCP Subcol-1' - call icarus_subcolumn(isccpIN%npoints,isccpIN%ncolumns,isccpIN%nlevels, & - isccpIN%sunlit,isccpIN%dtau,isccpIN%dem,isccpIN%skt, & - isccpIN%emsfc_lw,isccpIN%qv,isccpIN%at,isccpIN%pfull, & - isccpIN%phalf,isccpIN%frac_out,isccpLEVMATCH, & - isccp_boxtau(:,:),isccp_boxptop(:,:), & - isccp_boxttop(:,:),isccp_meantbclr(:)) - ! Decode outputs from swaths when reading into cospOUT fields - cospOUT%isccp_boxtau(ij:ik,:) = R_UNDEF - cospOUT%isccp_boxptop(ij:ik,:) = R_UNDEF - cospOUT%isccp_meantbclr(ij:ik) = R_UNDEF - ! print*,'ISCCP Subcol-2' - if (associated(cospOUT%isccp_boxtau)) cospOUT%isccp_boxtau(ij+int(ISCCP_MASK_INDICES)-1,:) = isccp_boxtau(:,:) - if (associated(cospOUT%isccp_boxptop)) cospOUT%isccp_boxptop(ij+int(ISCCP_MASK_INDICES)-1,:) = isccp_boxptop(:,:) ! This is used by MODIS as well. - if (associated(cospOUT%isccp_meantbclr)) cospOUT%isccp_meantbclr(ij+int(ISCCP_MASK_INDICES)-1) = isccp_meantbclr(:) - ! print*,'ISCCP Subcol-3' - deallocate(temp_isccp_skt,temp_isccp_qv,temp_isccp_at, & - temp_isccp_frac_out,temp_isccp_tau_067, & - temp_isccp_emiss_11,temp_isccp_phalf, & - temp_isccp_pfull) ! some of these pointers might be needed later! - ! print*,'ISCCP Subcol-4' + if (verbose) print*,'ISCCP Subcol' + if (cospIN % cospswathsIN(1) % N_inst_swaths .gt. 0) then + if (isccpIN%Npoints .gt. 0) then + allocate(isccpLEVMATCH(isccpIN%Npoints,isccpIN%Ncolumns), & + isccp_boxttop(isccpIN%Npoints,isccpIN%Ncolumns), & + isccp_boxptop(isccpIN%Npoints,isccpIN%Ncolumns), & + isccp_boxtau(isccpIN%Npoints,isccpIN%Ncolumns), & + isccp_meantbclr(isccpIN%Npoints)) + ! Call simulator + call icarus_subcolumn(isccpIN%npoints,isccpIN%ncolumns,isccpIN%nlevels, & + isccpIN%sunlit,isccpIN%dtau,isccpIN%dem,isccpIN%skt, & + isccpIN%emsfc_lw,isccpIN%qv,isccpIN%at,isccpIN%pfull, & + isccpIN%phalf,isccpIN%frac_out,isccpLEVMATCH, & + isccp_boxtau(:,:),isccp_boxptop(:,:), & + isccp_boxttop(:,:),isccp_meantbclr(:)) + ! Decode outputs from swaths when reading into cospOUT fields + cospOUT%isccp_boxtau(ij:ik,:) = R_UNDEF + cospOUT%isccp_boxptop(ij:ik,:) = R_UNDEF + cospOUT%isccp_meantbclr(ij:ik) = R_UNDEF + if (associated(cospOUT%isccp_boxtau)) cospOUT%isccp_boxtau(ij+int(ISCCP_MASK_INDICES)-1,:) = isccp_boxtau(:,:) + if (associated(cospOUT%isccp_boxptop)) cospOUT%isccp_boxptop(ij+int(ISCCP_MASK_INDICES)-1,:) = isccp_boxptop(:,:) + if (associated(cospOUT%isccp_meantbclr)) cospOUT%isccp_meantbclr(ij+int(ISCCP_MASK_INDICES)-1) = isccp_meantbclr(:) + deallocate(temp_isccp_skt,temp_isccp_qv,temp_isccp_at, & + temp_isccp_frac_out,temp_isccp_tau_067, & + temp_isccp_emiss_11,temp_isccp_phalf, & + temp_isccp_pfull) + else + cospOUT%isccp_boxtau(ij:ik,:) = R_UNDEF + cospOUT%isccp_boxptop(ij:ik,:) = R_UNDEF + cospOUT%isccp_meantbclr(ij:ik) = R_UNDEF + end if else ! Proceed normally + allocate(isccpLEVMATCH(isccpIN%Npoints,isccpIN%Ncolumns), & + isccp_boxttop(isccpIN%Npoints,isccpIN%Ncolumns), & + isccp_boxptop(isccpIN%Npoints,isccpIN%Ncolumns), & + isccp_boxtau(isccpIN%Npoints,isccpIN%Ncolumns), & + isccp_meantbclr(isccpIN%Npoints)) ! Call simulator call icarus_subcolumn(isccpIN%npoints,isccpIN%ncolumns,isccpIN%nlevels, & - isccpIN%sunlit,isccpIN%dtau,isccpIN%dem,isccpIN%skt, & - isccpIN%emsfc_lw,isccpIN%qv,isccpIN%at,isccpIN%pfull, & - isccpIN%phalf,isccpIN%frac_out,isccpLEVMATCH, & - isccp_boxtau(:,:),isccp_boxptop(:,:), & - isccp_boxttop(:,:),isccp_meantbclr(:)) + isccpIN%sunlit,isccpIN%dtau,isccpIN%dem,isccpIN%skt, & + isccpIN%emsfc_lw,isccpIN%qv,isccpIN%at,isccpIN%pfull, & + isccpIN%phalf,isccpIN%frac_out,isccpLEVMATCH, & + isccp_boxtau(:,:),isccp_boxptop(:,:), & + isccp_boxttop(:,:),isccp_meantbclr(:)) ! Store output (if requested) if (associated(cospOUT%isccp_boxtau)) then cospOUT%isccp_boxtau(ij:ik,:) = isccp_boxtau @@ -1276,25 +1267,31 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! MISR subcolumn simulator if (Lmisr_subcolumn) then - print*,'MISR Subcol-0' - ! Allocate space for local variables. - allocate(misr_boxztop(misrIN%Npoints,misrIN%Ncolumns), & - misr_boxtau(misrIN%Npoints,misrIN%Ncolumns), & - misr_dist_model_layertops(misrIN%Npoints,numMISRHgtBins)) + if (verbose) print*,'MISR Subcol' if (cospIN % cospswathsIN(2) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays - ! Allocate space for local variables. - ! print*,'MISR Subcol-1' - ! Call simulator - call misr_subcolumn(misrIN%Npoints,misrIN%Ncolumns,misrIN%Nlevels,misrIN%dtau, & - misrIN%zfull,misrIN%at,misrIN%sunlit,misr_boxtau, & - misr_dist_model_layertops,misr_boxztop) - ! Decode outputs from swaths when reading into cospOUT fields - ! print*,'MISR Subcol-3' - cospOUT%misr_dist_model_layertops(ij:ik,:) = R_UNDEF - if (associated(cospOUT%misr_dist_model_layertops)) cospOUT%misr_dist_model_layertops(ij+int(MISR_MASK_INDICES)-1,:) = misr_dist_model_layertops(:,:) - ! print*,'MISR Subcol-4' - deallocate(temp_misr_zfull,temp_misr_at,temp_misr_dtau) + if (misrIN%Npoints .gt. 0) then + ! Allocate space for local variables. + allocate(misr_boxztop(misrIN%Npoints,misrIN%Ncolumns), & + misr_boxtau(misrIN%Npoints,misrIN%Ncolumns), & + misr_dist_model_layertops(misrIN%Npoints,numMISRHgtBins)) + ! print*,'MISR Subcol-1' + ! Call simulator + call misr_subcolumn(misrIN%Npoints,misrIN%Ncolumns,misrIN%Nlevels,misrIN%dtau, & + misrIN%zfull,misrIN%at,misrIN%sunlit,misr_boxtau, & + misr_dist_model_layertops,misr_boxztop) + ! Decode outputs from swaths when reading into cospOUT fields + ! print*,'MISR Subcol-3' + cospOUT%misr_dist_model_layertops(ij:ik,:) = R_UNDEF + if (associated(cospOUT%misr_dist_model_layertops)) cospOUT%misr_dist_model_layertops(ij+int(MISR_MASK_INDICES)-1,:) = misr_dist_model_layertops(:,:) + ! print*,'MISR Subcol-4' + deallocate(temp_misr_zfull,temp_misr_at,temp_misr_dtau) + else + cospOUT%misr_dist_model_layertops(ij:ik,:) = R_UNDEF + endif else + allocate(misr_boxztop(misrIN%Npoints,misrIN%Ncolumns), & + misr_boxtau(misrIN%Npoints,misrIN%Ncolumns), & + misr_dist_model_layertops(misrIN%Npoints,numMISRHgtBins)) ! Call simulator call misr_subcolumn(misrIN%Npoints,misrIN%Ncolumns,misrIN%Nlevels,misrIN%dtau, & misrIN%zfull,misrIN%at,misrIN%sunlit,misr_boxtau, & @@ -1308,38 +1305,44 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Calipso subcolumn simulator if (Lcalipso_subcolumn) then - print*,'CALIPSO Subcol-1' - ! Allocate space for local variables - allocate(calipso_beta_mol(calipsoIN%Npoints,calipsoIN%Nlevels), & - calipso_beta_tot(calipsoIN%Npoints,calipsoIN%Ncolumns,calipsoIN%Nlevels),& - calipso_betaperp_tot(calipsoIN%Npoints,calipsoIN%Ncolumns,calipsoIN%Nlevels)) - ! Call simulator - print*,'CALIPSO Subcol-2' - call lidar_subcolumn(calipsoIN%npoints, calipsoIN%ncolumns, calipsoIN%nlevels, .false., & - calipsoIN%beta_mol, calipsoIN%tau_mol, calipsoIN%betatot, calipsoIN%tautot, & - calipso_beta_mol(:,:), calipso_beta_tot(:,:,:), calipsoIN%betatot_ice, & - calipsoIN%tautot_ice, calipsoIN%betatot_liq, calipsoIN%tautot_liq, & - calipso_betaperp_tot(:,:,:)) - if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays - ! Decode outputs from swaths when reading into cospOUT fields - print*,'CALIPSO Subcol-3' + if (verbose) print*,'CALIPSO Subcol' + if (calipsoIN%Npoints .gt. 0) then + ! Allocate space for local variables + allocate(calipso_beta_mol(calipsoIN%Npoints,calipsoIN%Nlevels), & + calipso_beta_tot(calipsoIN%Npoints,calipsoIN%Ncolumns,calipsoIN%Nlevels),& + calipso_betaperp_tot(calipsoIN%Npoints,calipsoIN%Ncolumns,calipsoIN%Nlevels)) + ! Call simulator + ! print*,'CALIPSO Subcol-2' + call lidar_subcolumn(calipsoIN%npoints, calipsoIN%ncolumns, calipsoIN%nlevels, .false., & + calipsoIN%beta_mol, calipsoIN%tau_mol, calipsoIN%betatot, calipsoIN%tautot, & + calipso_beta_mol(:,:), calipso_beta_tot(:,:,:), calipsoIN%betatot_ice, & + calipsoIN%tautot_ice, calipsoIN%betatot_liq, calipsoIN%tautot_liq, & + calipso_betaperp_tot(:,:,:)) + if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + ! Decode outputs from swaths when reading into cospOUT fields + ! print*,'CALIPSO Subcol-3' + cospOUT%calipso_beta_mol(ij:ik,:) = R_UNDEF + cospOUT%calipso_beta_tot(ij:ik,:,:) = R_UNDEF + cospOUT%calipso_betaperp_tot(ij:ik,:,:) = R_UNDEF + if (associated(cospOUT%calipso_beta_mol)) cospOUT%calipso_beta_mol(ij+int(CSCAL_MASK_INDICES)-1,calipsoIN%Nlevels:1:-1) = calipso_beta_mol(:,:) + if (associated(cospOUT%calipso_beta_tot)) cospOUT%calipso_beta_tot(ij+int(CSCAL_MASK_INDICES)-1,:,calipsoIN%Nlevels:1:-1) = calipso_beta_tot(:,:,:) + if (associated(cospOUT%calipso_betaperp_tot)) cospOUT%calipso_betaperp_tot(ij+int(CSCAL_MASK_INDICES)-1,:,:) = calipso_betaperp_tot(:,:,:) + ! print*,'CALIPSO Subcol-4' + deallocate(temp_beta_mol_calipso,temp_tau_mol_calipso,temp_betatot_calipso,temp_tautot_calipso, & + temp_betatot_liq_calipso,temp_tautot_liq_calipso,temp_betatot_ice_calipso,temp_tautot_ice_calipso) + else ! Proceed normally + ! Store output (if requested) + if (associated(cospOUT%calipso_beta_mol)) & + cospOUT%calipso_beta_mol(ij:ik,calipsoIN%Nlevels:1:-1) = calipso_beta_mol + if (associated(cospOUT%calipso_beta_tot)) & + cospOUT%calipso_beta_tot(ij:ik,:,calipsoIN%Nlevels:1:-1) = calipso_beta_tot + if (associated(cospOUT%calipso_betaperp_tot)) & + cospOUT%calipso_betaperp_tot(ij:ik,:,:) = calipso_betaperp_tot + endif + else cospOUT%calipso_beta_mol(ij:ik,:) = R_UNDEF cospOUT%calipso_beta_tot(ij:ik,:,:) = R_UNDEF cospOUT%calipso_betaperp_tot(ij:ik,:,:) = R_UNDEF - if (associated(cospOUT%calipso_beta_mol)) cospOUT%calipso_beta_mol(ij+int(CSCAL_MASK_INDICES)-1,calipsoIN%Nlevels:1:-1) = calipso_beta_mol(:,:) - if (associated(cospOUT%calipso_beta_tot)) cospOUT%calipso_beta_tot(ij+int(CSCAL_MASK_INDICES)-1,:,calipsoIN%Nlevels:1:-1) = calipso_beta_tot(:,:,:) - if (associated(cospOUT%calipso_betaperp_tot)) cospOUT%calipso_betaperp_tot(ij+int(CSCAL_MASK_INDICES)-1,:,:) = calipso_betaperp_tot(:,:,:) - print*,'CALIPSO Subcol-4' - deallocate(temp_beta_mol_calipso,temp_tau_mol_calipso,temp_betatot_calipso,temp_tautot_calipso, & - temp_betatot_liq_calipso,temp_tautot_liq_calipso,temp_betatot_ice_calipso,temp_tautot_ice_calipso) - else ! Proceed normally - ! Store output (if requested) - if (associated(cospOUT%calipso_beta_mol)) & - cospOUT%calipso_beta_mol(ij:ik,calipsoIN%Nlevels:1:-1) = calipso_beta_mol - if (associated(cospOUT%calipso_beta_tot)) & - cospOUT%calipso_beta_tot(ij:ik,:,calipsoIN%Nlevels:1:-1) = calipso_beta_tot - if (associated(cospOUT%calipso_betaperp_tot)) & - cospOUT%calipso_betaperp_tot(ij:ik,:,:) = calipso_betaperp_tot endif endif @@ -1361,54 +1364,60 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! ATLID subcolumn simulator if (Latlid_subcolumn) then - print*,'ATLID Subcol-0' - ! Allocate space for local variables - allocate(atlid_beta_mol(atlidIN%Npoints,atlidIN%Nlevels), & - atlid_beta_tot(atlidIN%Npoints,atlidIN%Ncolumns,atlidIN%Nlevels)) - ! Call simulator - call lidar_subcolumn(atlidIN%npoints, atlidIN%ncolumns, atlidIN%nlevels,& - .false., atlidIN%beta_mol_atlid, atlidIN%tau_mol_atlid, atlidIN%betatot_atlid,& - atlidIN%tautot_atlid, atlid_beta_mol(:,:), atlid_beta_tot(:,:,:)) - ! Decode outputs from swaths when reading into cospOUT fields - if (cospIN % cospswathsIN(4) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays - print*,'ATLID Subcol-1' + if (verbose) print*,'ATLID Subcol' + if (atlidIN%Npoints .gt. 0) then + ! Allocate space for local variables + allocate(atlid_beta_mol(atlidIN%Npoints,atlidIN%Nlevels), & + atlid_beta_tot(atlidIN%Npoints,atlidIN%Ncolumns,atlidIN%Nlevels)) + ! Call simulator + call lidar_subcolumn(atlidIN%npoints, atlidIN%ncolumns, atlidIN%nlevels, & + .false., atlidIN%beta_mol_atlid, atlidIN%tau_mol_atlid, atlidIN%betatot_atlid, & + atlidIN%tautot_atlid, atlid_beta_mol(:,:), atlid_beta_tot(:,:,:)) + ! Decode outputs from swaths when reading into cospOUT fields + if (cospIN % cospswathsIN(4) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + ! print*,'ATLID Subcol-1' + cospOUT%atlid_beta_mol(ij:ik,:) = R_UNDEF + cospOUT%atlid_beta_tot(ij:ik,:,:) = R_UNDEF + if (associated(cospOUT%atlid_beta_mol)) cospOUT%atlid_beta_mol(ij+int(ATLID_MASK_INDICES)-1,atlidIN%Nlevels:1:-1) = atlid_beta_mol(:,:) + if (associated(cospOUT%atlid_beta_tot)) cospOUT%atlid_beta_tot(ij+int(ATLID_MASK_INDICES)-1,:,atlidIN%Nlevels:1:-1) = atlid_beta_tot(:,:,:) + ! print*,'ATLID Subcol-2' + deallocate(temp_beta_mol_atlid,temp_betatot_atlid,temp_tau_mol_atlid,temp_tautot_atlid) + else + ! Store output (if requested) + if (associated(cospOUT%atlid_beta_mol)) & + cospOUT%atlid_beta_mol(ij:ik,atlidIN%Nlevels:1:-1) = atlid_beta_mol + if (associated(cospOUT%atlid_beta_tot)) & + cospOUT%atlid_beta_tot(ij:ik,:,atlidIN%Nlevels:1:-1) = atlid_beta_tot + end if + else cospOUT%atlid_beta_mol(ij:ik,:) = R_UNDEF cospOUT%atlid_beta_tot(ij:ik,:,:) = R_UNDEF - if (associated(cospOUT%atlid_beta_mol)) cospOUT%atlid_beta_mol(ij+int(ATLID_MASK_INDICES)-1,atlidIN%Nlevels:1:-1) = atlid_beta_mol(:,:) - if (associated(cospOUT%atlid_beta_tot)) cospOUT%atlid_beta_tot(ij+int(ATLID_MASK_INDICES)-1,:,atlidIN%Nlevels:1:-1) = atlid_beta_tot(:,:,:) - print*,'ATLID Subcol-2' - deallocate(temp_beta_mol_atlid,temp_betatot_atlid,temp_tau_mol_atlid,temp_tautot_atlid) - else - ! Store output (if requested) - if (associated(cospOUT%atlid_beta_mol)) & - cospOUT%atlid_beta_mol(ij:ik,atlidIN%Nlevels:1:-1) = atlid_beta_mol - if (associated(cospOUT%atlid_beta_tot)) & - cospOUT%atlid_beta_tot(ij:ik,:,atlidIN%Nlevels:1:-1) = atlid_beta_tot - end if + endif endif ! PARASOL subcolumn simulator if (Lparasol_subcolumn) then - print*,'PARASOL Subcol-0' - ! Allocate space for local variables - allocate(parasolPix_refl(parasolIN%Npoints,parasolIN%Ncolumns,PARASOL_NREFL)) - ! Call simulator - do icol=1,parasolIN%Ncolumns - call parasol_subcolumn(parasolIN%npoints, PARASOL_NREFL, & - parasolIN%tautot_S_liq(1:parasolIN%Npoints,icol), & - parasolIN%tautot_S_ice(1:parasolIN%Npoints,icol), & - parasolPix_refl(:,icol,1:PARASOL_NREFL)) - ! Store output (if requested) - if (cospIN % cospswathsIN(5) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays - cospOUT%parasolPix_refl(ij:ik,icol,1:PARASOL_NREFL) = R_UNDEF - if (associated(cospOUT%parasolPix_refl)) cospOUT%parasolPix_refl(ij+int(PARASOL_MASK_INDICES)-1,icol,1:PARASOL_NREFL) = parasolPix_refl(:,icol,1:PARASOL_NREFL) - else - if (associated(cospOUT%parasolPix_refl)) then - cospOUT%parasolPix_refl(ij:ik,icol,1:PARASOL_NREFL) = & - parasolPix_refl(:,icol,1:PARASOL_NREFL) + if (verbose) print*,'PARASOL Subcol' + if (parasolIN%Npoints .gt. 0) then + ! Allocate space for local variables + allocate(parasolPix_refl(parasolIN%Npoints,parasolIN%Ncolumns,PARASOL_NREFL)) + ! Call simulator + do icol=1,parasolIN%Ncolumns + call parasol_subcolumn(parasolIN%npoints, PARASOL_NREFL, & + parasolIN%tautot_S_liq(1:parasolIN%Npoints,icol), & + parasolIN%tautot_S_ice(1:parasolIN%Npoints,icol), & + parasolPix_refl(:,icol,1:PARASOL_NREFL)) + ! Store output (if requested) + if (cospIN % cospswathsIN(5) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + cospOUT%parasolPix_refl(ij:ik,icol,1:PARASOL_NREFL) = R_UNDEF + if (associated(cospOUT%parasolPix_refl)) cospOUT%parasolPix_refl(ij+int(PARASOL_MASK_INDICES)-1,icol,1:PARASOL_NREFL) = parasolPix_refl(:,icol,1:PARASOL_NREFL) + else + if (associated(cospOUT%parasolPix_refl)) cospOUT%parasolPix_refl(ij:ik,icol,1:PARASOL_NREFL) = parasolPix_refl(:,icol,1:PARASOL_NREFL) endif - endif - enddo + enddo + else + cospOUT%parasolPix_refl(ij:ik,:,1:PARASOL_NREFL) = R_UNDEF + endif if (allocated(temp_tautot_S_liq)) deallocate(temp_tautot_S_liq) if (allocated(temp_tautot_S_ice)) deallocate(temp_tautot_S_ice) endif @@ -1416,57 +1425,59 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Cloudsat (quickbeam) subcolumn simulator if (Lcloudsat_subcolumn) then ! Allocate space for local variables - print*,'CLOUDSAT Subcol-0' - allocate(cloudsatDBZe(cloudsatIN%Npoints,cloudsatIN%Ncolumns,cloudsatIN%Nlevels), & - cloudsatZe_non(cloudsatIN%Npoints,cloudsatIN%Ncolumns,cloudsatIN%Nlevels)) - print*,'CLOUDSAT Subcol-0.5' - do icol=1,cloudsatIN%ncolumns - call quickbeam_subcolumn(cloudsatIN%rcfg,cloudsatIN%Npoints,cloudsatIN%Nlevels,& - cloudsatIN%hgt_matrix/1000._wp, & - cloudsatIN%z_vol(:,icol,:), & - cloudsatIN%kr_vol(:,icol,:), & - cloudsatIN%g_vol(:,1,:),cloudsatDBze(:,icol,:),cloudsatZe_non(:,icol,:)) - enddo - print*,'CLOUDSAT Subcol-1' - ! Store output (if requested) - if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays - print*,'CLOUDSAT Subcol-2' - cospOUT%cloudsat_Ze_tot(ij:ik,:,:) = R_UNDEF - if (associated(cospOUT%cloudsat_Ze_tot)) cospOUT%cloudsat_Ze_tot(ij+int(CSCAL_MASK_INDICES)-1,:,1:cloudsatIN%Nlevels) = cloudsatDBZe(:,:,1:cloudsatIN%Nlevels) - print*,'CLOUDSAT Subcol-4' - deallocate(temp_hgt_matrix,temp_z_vol_cloudsat,temp_kr_vol_cloudsat,temp_g_vol_cloudsat) - else - if (associated(cospOUT%cloudsat_Ze_tot)) then - cospOUT%cloudsat_Ze_tot(ij:ik,:,:) = cloudsatDBZe(:,:,1:cloudsatIN%Nlevels) + if (verbose) print*,'CLOUDSAT Subcol' + if (cloudsatIN%Npoints .gt. 0) then + allocate(cloudsatDBZe(cloudsatIN%Npoints,cloudsatIN%Ncolumns,cloudsatIN%Nlevels), & + cloudsatZe_non(cloudsatIN%Npoints,cloudsatIN%Ncolumns,cloudsatIN%Nlevels)) + ! print*,'CLOUDSAT Subcol-0.5' + do icol=1,cloudsatIN%ncolumns + call quickbeam_subcolumn(cloudsatIN%rcfg,cloudsatIN%Npoints,cloudsatIN%Nlevels,& + cloudsatIN%hgt_matrix/1000._wp, & + cloudsatIN%z_vol(:,icol,:), & + cloudsatIN%kr_vol(:,icol,:), & + cloudsatIN%g_vol(:,1,:),cloudsatDBze(:,icol,:),cloudsatZe_non(:,icol,:)) + enddo + ! print*,'CLOUDSAT Subcol-1' + ! Store output (if requested) + if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + ! print*,'CLOUDSAT Subcol-2' + cospOUT%cloudsat_Ze_tot(ij:ik,:,:) = R_UNDEF + if (associated(cospOUT%cloudsat_Ze_tot)) cospOUT%cloudsat_Ze_tot(ij+int(CSCAL_MASK_INDICES)-1,:,1:cloudsatIN%Nlevels) = cloudsatDBZe(:,:,1:cloudsatIN%Nlevels) + ! print*,'CLOUDSAT Subcol-4' + deallocate(temp_hgt_matrix,temp_z_vol_cloudsat,temp_kr_vol_cloudsat,temp_g_vol_cloudsat) + else + if (associated(cospOUT%cloudsat_Ze_tot)) cospOUT%cloudsat_Ze_tot(ij:ik,:,:) = cloudsatDBZe(:,:,1:cloudsatIN%Nlevels) endif - endif + else + cospOUT%cloudsat_Ze_tot(ij:ik,:,:) = R_UNDEF + endif endif if (Lmodis_subcolumn) then + if (verbose) print*,'MODIS Subcol' if (modisiN%nSunlit > 0) then ! Allocate space for local variables - print*,'MODIS Subcol-0' allocate(modisRetrievedTau(modisIN%nSunlit,modisIN%nColumns), & modisRetrievedSize(modisIN%nSunlit,modisIN%nColumns), & modisRetrievedPhase(modisIN%nSunlit,modisIN%nColumns), & modisRetrievedCloudTopPressure(modisIN%nSunlit,modisIN%nColumns)) - print*,'MODIS Subcol-1' + ! print*,'MODIS Subcol-1' if (allocated(ISCCP_SWATH_MASK)) then ! If ISCCP is swathed must run ICARUS separately for MODIS allocate(modisLEVMATCH(modisIN%Npoints,modisIN%Ncolumns), & modis_boxptop(modisIN%Npoints,modisIN%Ncolumns), & modis_boxttop(modisIN%Npoints,modisIN%Ncolumns), & modis_boxtau(modisIN%Npoints,modisIN%Ncolumns), & modis_meantbclr(modisIN%Npoints)) - if (.not. allocated(MODIS_SWATH_MASK)) then + if (.not. allocated(MODIS_SWATH_MASK)) then ! Allows to run when there is no swathing allocate(MODIS_SWATH_MASK(Npoints)) MODIS_SWATH_MASK(:) = .true. end if - call icarus_subcolumn(modisIN%npoints,modisIN%ncolumns,modisIN%nlevels, & + call icarus_subcolumn(modisIN%npoints,modisIN%ncolumns,modisIN%nlevels, & int(MERGE(1,0,MASK=(cospgridIN%sunlit > 0) .and. MODIS_SWATH_MASK)), & - modisIN%tau,cospIN%emiss_11,cospgridIN%skt, & - cospIN%emsfc_lw,cospgridIN%qv,cospgridIN%at,cospgridIN%pfull, & - modisIN%pres,cospIN%frac_out,modisLEVMATCH, & - modis_boxtau(:,:),modis_boxptop(:,:), & - modis_boxttop(:,:),modis_meantbclr(:)) + modisIN%tau,cospIN%emiss_11,cospgridIN%skt, & + cospIN%emsfc_lw,cospgridIN%qv,cospgridIN%at,cospgridIN%pfull, & + modisIN%pres,cospIN%frac_out,modisLEVMATCH, & + modis_boxtau(:,:),modis_boxptop(:,:), & + modis_boxttop(:,:),modis_meantbclr(:)) deallocate(modis_boxtau,modis_boxttop,modis_meantbclr,modisLEVMATCH) else ! If ISCCP runs fully, just use the cospOUT field indexed appropriately allocate(modis_boxptop(modisIN%Npoints,modisIN%Ncolumns)) @@ -1486,7 +1497,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) modisRetrievedTau(i,:),modisRetrievedSize(i,:)) end do deallocate(modis_boxptop) - print*,'MODIS Subcol-2' + ! print*,'MODIS Subcol-2' endif endif @@ -1524,34 +1535,44 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Call simulator if (cospIN % cospswathsIN(1) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays - ! Operate at the masked format. - allocate(temp_isccp_fq(isccpIN%Npoints,numISCCPTauBins,numISCCPPresBins), & - temp_isccp_meanalbedocld(isccpIN%Npoints), & - temp_isccp_meanptop(isccpIN%Npoints), & - temp_isccp_meantaucld(isccpIN%Npoints), & - temp_isccp_totalcldarea(isccpIN%Npoints), & - temp_isccp_meantb(isccpIN%Npoints)) - - call icarus_column(isccpIN%npoints, isccpIN%ncolumns,isccp_boxtau(:,:), & - isccp_boxptop(:,:)/100._wp,isccpIN%sunlit,isccp_boxttop(:,:), & - temp_isccp_fq, & - temp_isccp_meanalbedocld, & - temp_isccp_meanptop,temp_isccp_meantaucld, & - temp_isccp_totalcldarea,temp_isccp_meantb) - ! Decode back to the cospOUT shapes - cospOUT%isccp_fq(ij:ik,:,:) = R_UNDEF - cospOUT%isccp_meanalbedocld(ij:ik) = R_UNDEF - cospOUT%isccp_meanptop(ij:ik) = R_UNDEF - cospOUT%isccp_meantaucld(ij:ik) = R_UNDEF - cospOUT%isccp_totalcldarea(ij:ik) = R_UNDEF - cospOUT%isccp_meantb(ij:ik) = R_UNDEF - if (associated(cospOUT%isccp_fq)) cospOUT%isccp_fq(ij+int(ISCCP_MASK_INDICES)-1,:,:) = temp_isccp_fq(:,:,:) - if (associated(cospOUT%isccp_meanalbedocld)) cospOUT%isccp_meanalbedocld(ij+int(ISCCP_MASK_INDICES)-1) = temp_isccp_meanalbedocld(:) - if (associated(cospOUT%isccp_meanptop)) cospOUT%isccp_meanptop(ij+int(ISCCP_MASK_INDICES)-1) = temp_isccp_meanptop(:) - if (associated(cospOUT%isccp_meantaucld)) cospOUT%isccp_meantaucld(ij+int(ISCCP_MASK_INDICES)-1) = temp_isccp_meantaucld(:) - if (associated(cospOUT%isccp_totalcldarea)) cospOUT%isccp_totalcldarea(ij+int(ISCCP_MASK_INDICES)-1) = temp_isccp_totalcldarea(:) - if (associated(cospOUT%isccp_meantb)) cospOUT%isccp_meantb(ij+int(ISCCP_MASK_INDICES)-1) = temp_isccp_meantb(:) - deallocate(ISCCP_SWATH_MASK,ISCCP_MASK_INDICES,temp_isccp_fq,temp_isccp_meanalbedocld,temp_isccp_meanptop,temp_isccp_meantaucld,temp_isccp_totalcldarea,temp_isccp_meantb) + if (isccpIN%Npoints .gt. 0) then + ! Operate at the masked format. + allocate(temp_isccp_fq(isccpIN%Npoints,numISCCPTauBins,numISCCPPresBins), & + temp_isccp_meanalbedocld(isccpIN%Npoints), & + temp_isccp_meanptop(isccpIN%Npoints), & + temp_isccp_meantaucld(isccpIN%Npoints), & + temp_isccp_totalcldarea(isccpIN%Npoints), & + temp_isccp_meantb(isccpIN%Npoints)) + + call icarus_column(isccpIN%npoints, isccpIN%ncolumns,isccp_boxtau(:,:), & + isccp_boxptop(:,:)/100._wp,isccpIN%sunlit,isccp_boxttop(:,:), & + temp_isccp_fq, & + temp_isccp_meanalbedocld, & + temp_isccp_meanptop,temp_isccp_meantaucld, & + temp_isccp_totalcldarea,temp_isccp_meantb) + ! Decode back to the cospOUT shapes + cospOUT%isccp_fq(ij:ik,:,:) = R_UNDEF + cospOUT%isccp_meanalbedocld(ij:ik) = R_UNDEF + cospOUT%isccp_meanptop(ij:ik) = R_UNDEF + cospOUT%isccp_meantaucld(ij:ik) = R_UNDEF + cospOUT%isccp_totalcldarea(ij:ik) = R_UNDEF + cospOUT%isccp_meantb(ij:ik) = R_UNDEF + if (associated(cospOUT%isccp_fq)) cospOUT%isccp_fq(ij+int(ISCCP_MASK_INDICES)-1,:,:) = temp_isccp_fq(:,:,:) + if (associated(cospOUT%isccp_meanalbedocld)) cospOUT%isccp_meanalbedocld(ij+int(ISCCP_MASK_INDICES)-1) = temp_isccp_meanalbedocld(:) + if (associated(cospOUT%isccp_meanptop)) cospOUT%isccp_meanptop(ij+int(ISCCP_MASK_INDICES)-1) = temp_isccp_meanptop(:) + if (associated(cospOUT%isccp_meantaucld)) cospOUT%isccp_meantaucld(ij+int(ISCCP_MASK_INDICES)-1) = temp_isccp_meantaucld(:) + if (associated(cospOUT%isccp_totalcldarea)) cospOUT%isccp_totalcldarea(ij+int(ISCCP_MASK_INDICES)-1) = temp_isccp_totalcldarea(:) + if (associated(cospOUT%isccp_meantb)) cospOUT%isccp_meantb(ij+int(ISCCP_MASK_INDICES)-1) = temp_isccp_meantb(:) + deallocate(ISCCP_SWATH_MASK,ISCCP_MASK_INDICES,temp_isccp_fq,temp_isccp_meanalbedocld,temp_isccp_meanptop,temp_isccp_meantaucld,temp_isccp_totalcldarea,temp_isccp_meantb) + else + cospOUT%isccp_fq(ij:ik,:,:) = R_UNDEF + cospOUT%isccp_meanalbedocld(ij:ik) = R_UNDEF + cospOUT%isccp_meanptop(ij:ik) = R_UNDEF + cospOUT%isccp_meantaucld(ij:ik) = R_UNDEF + cospOUT%isccp_totalcldarea(ij:ik) = R_UNDEF + cospOUT%isccp_meantb(ij:ik) = R_UNDEF + deallocate(ISCCP_SWATH_MASK,ISCCP_MASK_INDICES) + end if else call icarus_column(isccpIN%npoints, isccpIN%ncolumns,isccp_boxtau(:,:), & isccp_boxptop(:,:)/100._wp, isccpIN%sunlit,isccp_boxttop(:,:), & @@ -1620,25 +1641,32 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Call simulator if (cospIN % cospswathsIN(2) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays - ! print*,'MISR' - ! Operate at the masked format. - allocate(temp_misr_cldarea(misrIN%Npoints), & - temp_misr_meanztop(misrIN%Npoints), & - temp_misr_fq(misrIN%Npoints,numMISRTauBins,numMISRHgtBins)) - ! print*,'MISR-1' - call misr_column(misrIN%Npoints,misrIN%Ncolumns,misr_boxztop,misrIN%sunlit,& - misr_boxtau,temp_misr_cldarea(:), & - temp_misr_meanztop(:),temp_misr_fq(:,:,:)) - ! print*,'MISR-2' - ! Decode back to the cospOUT shapes - cospOUT%misr_cldarea(ij:ik) = R_UNDEF - cospOUT%misr_meanztop(ij:ik) = R_UNDEF - cospOUT%misr_fq(ij:ik,:,:) = R_UNDEF - if (associated(cospOUT%misr_cldarea)) cospOUT%misr_cldarea(ij+int(MISR_MASK_INDICES)-1) = temp_misr_cldarea(:) - if (associated(cospOUT%misr_meanztop)) cospOUT%misr_meanztop(ij+int(MISR_MASK_INDICES)-1) = temp_misr_meanztop(:) - if (associated(cospOUT%misr_fq)) cospOUT%misr_fq(ij+int(MISR_MASK_INDICES)-1,:,:) = temp_misr_fq(:,:,:) - ! print*,'MISR-3' - deallocate(MISR_SWATH_MASK,MISR_MASK_INDICES,temp_misr_sunlit,temp_misr_cldarea,temp_misr_meanztop,temp_misr_fq) + if (verbose) print*,'MISR' + if (isccpIN%Npoints .gt. 0) then + ! Operate at the masked format. + allocate(temp_misr_cldarea(misrIN%Npoints), & + temp_misr_meanztop(misrIN%Npoints), & + temp_misr_fq(misrIN%Npoints,numMISRTauBins,numMISRHgtBins)) + ! print*,'MISR-1' + call misr_column(misrIN%Npoints,misrIN%Ncolumns,misr_boxztop,misrIN%sunlit, & + misr_boxtau,temp_misr_cldarea(:), & + temp_misr_meanztop(:),temp_misr_fq(:,:,:)) + ! print*,'MISR-2' + ! Decode back to the cospOUT shapes + cospOUT%misr_cldarea(ij:ik) = R_UNDEF + cospOUT%misr_meanztop(ij:ik) = R_UNDEF + cospOUT%misr_fq(ij:ik,:,:) = R_UNDEF + if (associated(cospOUT%misr_cldarea)) cospOUT%misr_cldarea(ij+int(MISR_MASK_INDICES)-1) = temp_misr_cldarea(:) + if (associated(cospOUT%misr_meanztop)) cospOUT%misr_meanztop(ij+int(MISR_MASK_INDICES)-1) = temp_misr_meanztop(:) + if (associated(cospOUT%misr_fq)) cospOUT%misr_fq(ij+int(MISR_MASK_INDICES)-1,:,:) = temp_misr_fq(:,:,:) + ! print*,'MISR-3' + deallocate(MISR_SWATH_MASK,MISR_MASK_INDICES,temp_misr_sunlit,temp_misr_cldarea,temp_misr_meanztop,temp_misr_fq) + else + cospOUT%misr_cldarea(ij:ik) = R_UNDEF + cospOUT%misr_meanztop(ij:ik) = R_UNDEF + cospOUT%misr_fq(ij:ik,:,:) = R_UNDEF + deallocate(MISR_SWATH_MASK,MISR_MASK_INDICES) + endif else call misr_column(misrIN%Npoints,misrIN%Ncolumns,misr_boxztop,misrIN%sunlit,& misr_boxtau,cospOUT%misr_cldarea(ij:ik), & @@ -1717,63 +1745,80 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Call simulator if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays ! Operate at the masked format. - print*,'CALIPSO' - allocate(temp_calipso_cfad_sr(calipsoIN%Npoints,SR_BINS,Nlvgrid), & - temp_calipso_lidarcld(calipsoIN%Npoints,Nlvgrid), & - temp_calipso_cldlayer(calipsoIN%Npoints,LIDAR_NCAT), & - temp_calipso_lidarcldphase(calipsoIN%Npoints,Nlvgrid,6), & - temp_calipso_lidarcldtype(calipsoIN%Npoints,Nlvgrid,LIDAR_NTYPE+1), & - temp_calipso_cldtype(calipsoIN%Npoints,LIDAR_NTYPE), & - temp_calipso_cldtypetemp(calipsoIN%Npoints,LIDAR_NTYPE), & - temp_calipso_cldtypemeanz(calipsoIN%Npoints,2), & - temp_calipso_cldtypemeanzse(calipsoIN%Npoints,3), & - temp_calipso_cldthinemis(calipsoIN%Npoints), & - temp_calipso_cldlayerphase(calipsoIN%Npoints,LIDAR_NCAT,6), & - temp_calipso_lidarcldtmp(calipsoIN%Npoints,LIDAR_NTEMP,5)) - ok_lidar_cfad=.true. - print*,'CALIPSO-1' - call lidar_column(calipsoIN%Npoints, calipsoIN%Ncolumns, calipsoIN%Nlevels, & - Nlvgrid, SR_BINS, LIDAR_NTYPE, 'calipso',calipso_beta_tot(:,:,:), calipso_beta_mol(:,:),& - cospgridIN%phalf(int(CSCAL_MASK_INDICES),2:calipsoIN%Nlevels+1),cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES),:), & ! JKS issues here, add ij - 1? - cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES),:), vgrid_z(:), ok_lidar_cfad, LIDAR_NCAT, & ! JKS issues here - temp_calipso_cfad_sr(:,:,:), temp_calipso_lidarcld(:,:), & - temp_calipso_cldlayer(:,:), & - cospgridIN%at(int(CSCAL_MASK_INDICES),:), calipso_betaperp_tot(:,:,:), cospgridIN%surfelev(int(CSCAL_MASK_INDICES)), & ! JKS issues here - temp_calipso_lidarcldphase(:,:,:), & - temp_calipso_lidarcldtype(:,:,:), temp_calipso_cldtype(:,:), & - temp_calipso_cldtypetemp(:,:), temp_calipso_cldtypemeanz(:,:), & - temp_calipso_cldtypemeanzse(:,:), temp_calipso_cldthinemis(:), & - temp_calipso_cldlayerphase(:,:,:), temp_calipso_lidarcldtmp(:,:,:)) - ! Decode back to the cospOUT shapes - print*,'CALIPSO-2' - cospOUT%calipso_cfad_sr(ij:ik,:,:) = R_UNDEF - cospOUT%calipso_lidarcld(ij:ik,:) = R_UNDEF - cospOUT%calipso_cldlayer(ij:ik,:) = R_UNDEF - cospOUT%calipso_lidarcldphase(ij:ik,:,:) = R_UNDEF - cospOUT%calipso_lidarcldtype(ij:ik,:,:) = R_UNDEF - cospOUT%calipso_cldtype(ij:ik,:) = R_UNDEF - cospOUT%calipso_cldtypetemp(ij:ik,:) = R_UNDEF - cospOUT%calipso_cldtypemeanz(ij:ik,:) = R_UNDEF - cospOUT%calipso_cldtypemeanzse(ij:ik,:) = R_UNDEF - cospOUT%calipso_cldthinemis(ij:ik) = R_UNDEF - cospOUT%calipso_cldlayerphase(ij:ik,:,:) = R_UNDEF - cospOUT%calipso_lidarcldtmp(ij:ik,:,:) = R_UNDEF - if (associated(cospOUT%calipso_cfad_sr)) cospOUT%calipso_cfad_sr(ij+int(CSCAL_MASK_INDICES)-1,:,:) = temp_calipso_cfad_sr(:,:,:) ! JKS indexing correct? - if (associated(cospOUT%calipso_lidarcld)) cospOUT%calipso_lidarcld(ij+int(CSCAL_MASK_INDICES)-1,:) = temp_calipso_lidarcld(:,:) - if (associated(cospOUT%calipso_cldlayer)) cospOUT%calipso_cldlayer(ij+int(CSCAL_MASK_INDICES)-1,:) = temp_calipso_cldlayer(:,:) - if (associated(cospOUT%calipso_lidarcldphase)) cospOUT%calipso_lidarcldphase(ij+int(CSCAL_MASK_INDICES)-1,:,:) = temp_calipso_lidarcldphase(:,:,:) - if (associated(cospOUT%calipso_lidarcldtype)) cospOUT%calipso_lidarcldtype(ij+int(CSCAL_MASK_INDICES)-1,:,:) = temp_calipso_lidarcldtype(:,:,:) - if (associated(cospOUT%calipso_cldtype)) cospOUT%calipso_cldtype(ij+int(CSCAL_MASK_INDICES)-1,:) = temp_calipso_cldtype(:,:) - if (associated(cospOUT%calipso_cldtypetemp)) cospOUT%calipso_cldtypetemp(ij+int(CSCAL_MASK_INDICES)-1,:) = temp_calipso_cldtypetemp(:,:) - if (associated(cospOUT%calipso_cldtypemeanz)) cospOUT%calipso_cldtypemeanz(ij+int(CSCAL_MASK_INDICES)-1,:) = temp_calipso_cldtypemeanz(:,:) - if (associated(cospOUT%calipso_cldtypemeanzse)) cospOUT%calipso_cldtypemeanzse(ij+int(CSCAL_MASK_INDICES)-1,:) = temp_calipso_cldtypemeanzse(:,:) - if (associated(cospOUT%calipso_cldthinemis)) cospOUT%calipso_cldthinemis(ij+int(CSCAL_MASK_INDICES)-1) = temp_calipso_cldthinemis(:) - if (associated(cospOUT%calipso_cldlayerphase)) cospOUT%calipso_cldlayerphase(ij+int(CSCAL_MASK_INDICES)-1,:,:) = temp_calipso_cldlayerphase(:,:,:) - if (associated(cospOUT%calipso_lidarcldtmp)) cospOUT%calipso_lidarcldtmp(ij+int(CSCAL_MASK_INDICES)-1,:,:) = temp_calipso_lidarcldtmp(:,:,:) - print*,'CALIPSO-3' - deallocate(CSCAL_SWATH_MASK,temp_calipso_cfad_sr,temp_calipso_lidarcld,temp_calipso_cldlayer,temp_calipso_lidarcldphase, & - temp_calipso_lidarcldtype,temp_calipso_cldtype,temp_calipso_cldtypetemp,temp_calipso_cldtypemeanz, & - temp_calipso_cldtypemeanzse,temp_calipso_cldthinemis,temp_calipso_cldlayerphase,temp_calipso_lidarcldtmp) + if (verbose) print*,'CALIPSO' + if (calipsoIN%Npoints .gt. 0) then + allocate(temp_calipso_cfad_sr(calipsoIN%Npoints,SR_BINS,Nlvgrid), & + temp_calipso_lidarcld(calipsoIN%Npoints,Nlvgrid), & + temp_calipso_cldlayer(calipsoIN%Npoints,LIDAR_NCAT), & + temp_calipso_lidarcldphase(calipsoIN%Npoints,Nlvgrid,6), & + temp_calipso_lidarcldtype(calipsoIN%Npoints,Nlvgrid,LIDAR_NTYPE+1), & + temp_calipso_cldtype(calipsoIN%Npoints,LIDAR_NTYPE), & + temp_calipso_cldtypetemp(calipsoIN%Npoints,LIDAR_NTYPE), & + temp_calipso_cldtypemeanz(calipsoIN%Npoints,2), & + temp_calipso_cldtypemeanzse(calipsoIN%Npoints,3), & + temp_calipso_cldthinemis(calipsoIN%Npoints), & + temp_calipso_cldlayerphase(calipsoIN%Npoints,LIDAR_NCAT,6), & + temp_calipso_lidarcldtmp(calipsoIN%Npoints,LIDAR_NTEMP,5)) + ok_lidar_cfad=.true. + ! print*,'CALIPSO-1' + call lidar_column(calipsoIN%Npoints, calipsoIN%Ncolumns, calipsoIN%Nlevels, & + Nlvgrid, SR_BINS, LIDAR_NTYPE, 'calipso',calipso_beta_tot(:,:,:), calipso_beta_mol(:,:), & + cospgridIN%phalf(int(CSCAL_MASK_INDICES),2:calipsoIN%Nlevels+1), & + cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES),:), & + cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES),:), vgrid_z(:), ok_lidar_cfad, LIDAR_NCAT, & + temp_calipso_cfad_sr(:,:,:), temp_calipso_lidarcld(:,:), temp_calipso_cldlayer(:,:), & + cospgridIN%at(int(CSCAL_MASK_INDICES),:), calipso_betaperp_tot(:,:,:), & + cospgridIN%surfelev(int(CSCAL_MASK_INDICES)), & + temp_calipso_lidarcldphase(:,:,:), & + temp_calipso_lidarcldtype(:,:,:), temp_calipso_cldtype(:,:), & + temp_calipso_cldtypetemp(:,:), temp_calipso_cldtypemeanz(:,:), & + temp_calipso_cldtypemeanzse(:,:), temp_calipso_cldthinemis(:), & + temp_calipso_cldlayerphase(:,:,:), temp_calipso_lidarcldtmp(:,:,:)) + ! Decode back to the cospOUT shapes + ! print*,'CALIPSO-2' + cospOUT%calipso_cfad_sr(ij:ik,:,:) = R_UNDEF + cospOUT%calipso_lidarcld(ij:ik,:) = R_UNDEF + cospOUT%calipso_cldlayer(ij:ik,:) = R_UNDEF + cospOUT%calipso_lidarcldphase(ij:ik,:,:) = R_UNDEF + cospOUT%calipso_lidarcldtype(ij:ik,:,:) = R_UNDEF + cospOUT%calipso_cldtype(ij:ik,:) = R_UNDEF + cospOUT%calipso_cldtypetemp(ij:ik,:) = R_UNDEF + cospOUT%calipso_cldtypemeanz(ij:ik,:) = R_UNDEF + cospOUT%calipso_cldtypemeanzse(ij:ik,:) = R_UNDEF + cospOUT%calipso_cldthinemis(ij:ik) = R_UNDEF + cospOUT%calipso_cldlayerphase(ij:ik,:,:) = R_UNDEF + cospOUT%calipso_lidarcldtmp(ij:ik,:,:) = R_UNDEF + if (associated(cospOUT%calipso_cfad_sr)) cospOUT%calipso_cfad_sr(ij+int(CSCAL_MASK_INDICES)-1,:,:) = temp_calipso_cfad_sr(:,:,:) + if (associated(cospOUT%calipso_lidarcld)) cospOUT%calipso_lidarcld(ij+int(CSCAL_MASK_INDICES)-1,:) = temp_calipso_lidarcld(:,:) + if (associated(cospOUT%calipso_cldlayer)) cospOUT%calipso_cldlayer(ij+int(CSCAL_MASK_INDICES)-1,:) = temp_calipso_cldlayer(:,:) + if (associated(cospOUT%calipso_lidarcldphase)) cospOUT%calipso_lidarcldphase(ij+int(CSCAL_MASK_INDICES)-1,:,:) = temp_calipso_lidarcldphase(:,:,:) + if (associated(cospOUT%calipso_lidarcldtype)) cospOUT%calipso_lidarcldtype(ij+int(CSCAL_MASK_INDICES)-1,:,:) = temp_calipso_lidarcldtype(:,:,:) + if (associated(cospOUT%calipso_cldtype)) cospOUT%calipso_cldtype(ij+int(CSCAL_MASK_INDICES)-1,:) = temp_calipso_cldtype(:,:) + if (associated(cospOUT%calipso_cldtypetemp)) cospOUT%calipso_cldtypetemp(ij+int(CSCAL_MASK_INDICES)-1,:) = temp_calipso_cldtypetemp(:,:) + if (associated(cospOUT%calipso_cldtypemeanz)) cospOUT%calipso_cldtypemeanz(ij+int(CSCAL_MASK_INDICES)-1,:) = temp_calipso_cldtypemeanz(:,:) + if (associated(cospOUT%calipso_cldtypemeanzse)) cospOUT%calipso_cldtypemeanzse(ij+int(CSCAL_MASK_INDICES)-1,:) = temp_calipso_cldtypemeanzse(:,:) + if (associated(cospOUT%calipso_cldthinemis)) cospOUT%calipso_cldthinemis(ij+int(CSCAL_MASK_INDICES)-1) = temp_calipso_cldthinemis(:) + if (associated(cospOUT%calipso_cldlayerphase)) cospOUT%calipso_cldlayerphase(ij+int(CSCAL_MASK_INDICES)-1,:,:) = temp_calipso_cldlayerphase(:,:,:) + if (associated(cospOUT%calipso_lidarcldtmp)) cospOUT%calipso_lidarcldtmp(ij+int(CSCAL_MASK_INDICES)-1,:,:) = temp_calipso_lidarcldtmp(:,:,:) + ! print*,'CALIPSO-3' + deallocate(CSCAL_SWATH_MASK,temp_calipso_cfad_sr,temp_calipso_lidarcld,temp_calipso_cldlayer,temp_calipso_lidarcldphase, & + temp_calipso_lidarcldtype,temp_calipso_cldtype,temp_calipso_cldtypetemp,temp_calipso_cldtypemeanz, & + temp_calipso_cldtypemeanzse,temp_calipso_cldthinemis,temp_calipso_cldlayerphase,temp_calipso_lidarcldtmp) + else + cospOUT%calipso_cfad_sr(ij:ik,:,:) = R_UNDEF + cospOUT%calipso_lidarcld(ij:ik,:) = R_UNDEF + cospOUT%calipso_cldlayer(ij:ik,:) = R_UNDEF + cospOUT%calipso_lidarcldphase(ij:ik,:,:) = R_UNDEF + cospOUT%calipso_lidarcldtype(ij:ik,:,:) = R_UNDEF + cospOUT%calipso_cldtype(ij:ik,:) = R_UNDEF + cospOUT%calipso_cldtypetemp(ij:ik,:) = R_UNDEF + cospOUT%calipso_cldtypemeanz(ij:ik,:) = R_UNDEF + cospOUT%calipso_cldtypemeanzse(ij:ik,:) = R_UNDEF + cospOUT%calipso_cldthinemis(ij:ik) = R_UNDEF + cospOUT%calipso_cldlayerphase(ij:ik,:,:) = R_UNDEF + cospOUT%calipso_lidarcldtmp(ij:ik,:,:) = R_UNDEF + deallocate(CSCAL_SWATH_MASK) + endif else ok_lidar_cfad=.true. call lidar_column(calipsoIN%Npoints, calipsoIN%Ncolumns, calipsoIN%Nlevels, & @@ -1889,6 +1934,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! ATLID Simulator if (Latlid_column) then + if (verbose) print*,'ATLID' ! Check to see which outputs are requested. If not requested, use a local dummy array if (.not. associated(cospOUT%atlid_cfad_sr)) then allocate(out1D_1(Npoints*SR_BINS*Nlvgrid)) @@ -1905,27 +1951,34 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Call simulator ok_lidar_cfad_atlid=.true. if (cospIN % cospswathsIN(4) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays - print*,'ATLID' - allocate(temp_atlid_cfad_sr(atlidIN%Npoints,SR_BINS,Nlvgrid), & - temp_atlid_lidarcld(atlidIN%Npoints,Nlvgrid), & - temp_atlid_cldlayer(atlidIN%Npoints,LIDAR_NCAT)) - print*,'ATLID-1' - call lidar_column(atlidIN%Npoints, atlidIN%Ncolumns, atlidIN%Nlevels, & - Nlvgrid, SR_BINS, LIDAR_NTYPE, 'atlid',atlid_beta_tot(:,:,:), & - atlid_beta_mol(:,:), cospgridIN%phalf(int(ATLID_MASK_INDICES),2:atlidIN%Nlevels+1), & - cospgridIN%hgt_matrix(int(ATLID_MASK_INDICES),:), cospgridIN%hgt_matrix_half(int(ATLID_MASK_INDICES),:), vgrid_z(:), & - ok_lidar_cfad_atlid, LIDAR_NCAT, temp_atlid_cfad_sr(:,:,:), & - temp_atlid_lidarcld(:,:), temp_atlid_cldlayer(:,:)) - ! Decode back to the cospOUT shapes - print*,'ATLID-2' - cospOUT%atlid_cfad_sr(ij:ik,:,:) = R_UNDEF ! JKS move within associated statement for all of these? - cospOUT%atlid_lidarcld(ij:ik,:) = R_UNDEF - cospOUT%atlid_cldlayer(ij:ik,:) = R_UNDEF - if (associated(cospOUT%atlid_cfad_sr)) cospOUT%atlid_cfad_sr(ij+int(ATLID_MASK_INDICES)-1,:,:) = temp_atlid_cfad_sr(:,:,:) - if (associated(cospOUT%atlid_lidarcld)) cospOUT%atlid_lidarcld(ij+int(ATLID_MASK_INDICES)-1,:) = temp_atlid_lidarcld(:,:) - if (associated(cospOUT%atlid_cldlayer)) cospOUT%atlid_cldlayer(ij+int(ATLID_MASK_INDICES)-1,:) = temp_atlid_cldlayer(:,:) - print*,'ATLID-3' - deallocate(ATLID_SWATH_MASK,ATLID_MASK_INDICES,temp_atlid_cfad_sr,temp_atlid_lidarcld,temp_atlid_cldlayer) + if (atlidIN%Npoints .gt. 0) then + allocate(temp_atlid_cfad_sr(atlidIN%Npoints,SR_BINS,Nlvgrid), & + temp_atlid_lidarcld(atlidIN%Npoints,Nlvgrid), & + temp_atlid_cldlayer(atlidIN%Npoints,LIDAR_NCAT)) + ! print*,'ATLID-1' + call lidar_column(atlidIN%Npoints, atlidIN%Ncolumns, atlidIN%Nlevels, & + Nlvgrid, SR_BINS, LIDAR_NTYPE, 'atlid',atlid_beta_tot(:,:,:), & + atlid_beta_mol(:,:), cospgridIN%phalf(int(ATLID_MASK_INDICES),2:atlidIN%Nlevels+1), & + cospgridIN%hgt_matrix(int(ATLID_MASK_INDICES),:), & + cospgridIN%hgt_matrix_half(int(ATLID_MASK_INDICES),:), vgrid_z(:), & + ok_lidar_cfad_atlid, LIDAR_NCAT, temp_atlid_cfad_sr(:,:,:), & + temp_atlid_lidarcld(:,:), temp_atlid_cldlayer(:,:)) + ! Decode back to the cospOUT shapes + ! print*,'ATLID-2' + cospOUT%atlid_cfad_sr(ij:ik,:,:) = R_UNDEF + cospOUT%atlid_lidarcld(ij:ik,:) = R_UNDEF + cospOUT%atlid_cldlayer(ij:ik,:) = R_UNDEF + if (associated(cospOUT%atlid_cfad_sr)) cospOUT%atlid_cfad_sr(ij+int(ATLID_MASK_INDICES)-1,:,:) = temp_atlid_cfad_sr(:,:,:) + if (associated(cospOUT%atlid_lidarcld)) cospOUT%atlid_lidarcld(ij+int(ATLID_MASK_INDICES)-1,:) = temp_atlid_lidarcld(:,:) + if (associated(cospOUT%atlid_cldlayer)) cospOUT%atlid_cldlayer(ij+int(ATLID_MASK_INDICES)-1,:) = temp_atlid_cldlayer(:,:) + ! print*,'ATLID-3' + deallocate(ATLID_SWATH_MASK,ATLID_MASK_INDICES,temp_atlid_cfad_sr,temp_atlid_lidarcld,temp_atlid_cldlayer) + else + deallocate(ATLID_SWATH_MASK,ATLID_MASK_INDICES) + cospOUT%atlid_cfad_sr(ij:ik,:,:) = R_UNDEF + cospOUT%atlid_lidarcld(ij:ik,:) = R_UNDEF + cospOUT%atlid_cldlayer(ij:ik,:) = R_UNDEF + endif else call lidar_column(atlidIN%Npoints, atlidIN%Ncolumns, atlidIN%Nlevels, & Nlvgrid, SR_BINS, LIDAR_NTYPE, 'atlid',atlid_beta_tot(:,:,:), & @@ -1955,18 +2008,22 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! PARASOL if (Lparasol_column) then if (cospIN % cospswathsIN(5) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays - print*,'PARASOL' - allocate(temp_parasolGrid_refl(parasolIN%Npoints,PARASOL_NREFL)) - print*,'PARASOL-1' - call parasol_column(parasolIN%Npoints,PARASOL_NREFL,parasolIN%Ncolumns, & - cospgridIN%land(int(PARASOL_MASK_INDICES)),parasolPix_refl(:,:,:), & - temp_parasolGrid_refl(:,:)) - ! Decode back to the cospOUT shapes - print*,'PARASOL-2' - ! print*,'temp_parasolGrid_refl: ',temp_parasolGrid_refl - cospOUT%parasolGrid_refl(ij:ik,:) = R_UNDEF - if (associated(cospOUT%parasolGrid_refl)) cospOUT%parasolGrid_refl(ij+int(PARASOL_MASK_INDICES)-1,:) = temp_parasolGrid_refl(:,:) - deallocate(PARASOL_SWATH_MASK,temp_parasolGrid_refl) + if (verbose) print*,'PARASOL' + if (parasolIN%Npoints .gt. 0) then + allocate(temp_parasolGrid_refl(parasolIN%Npoints,PARASOL_NREFL)) + ! print*,'PARASOL-1' + call parasol_column(parasolIN%Npoints,PARASOL_NREFL,parasolIN%Ncolumns, & + cospgridIN%land(int(PARASOL_MASK_INDICES)),parasolPix_refl(:,:,:), & + temp_parasolGrid_refl(:,:)) + ! Decode back to the cospOUT shapes + ! print*,'PARASOL-2' + ! print*,'temp_parasolGrid_refl: ',temp_parasolGrid_refl + cospOUT%parasolGrid_refl(ij:ik,:) = R_UNDEF + if (associated(cospOUT%parasolGrid_refl)) cospOUT%parasolGrid_refl(ij+int(PARASOL_MASK_INDICES)-1,:) = temp_parasolGrid_refl(:,:) + deallocate(PARASOL_SWATH_MASK,temp_parasolGrid_refl) + else + cospOUT%parasolGrid_refl(ij:ik,:) = R_UNDEF + endif else call parasol_column(parasolIN%Npoints,PARASOL_NREFL,parasolIN%Ncolumns, & cospgridIN%land(:),parasolPix_refl(:,:,:), & @@ -1997,28 +2054,34 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Call simulator if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays - print*,'CLOUDSAT' - allocate(temp_cloudsat_cfad_ze(cloudsatIN%Npoints,cloudsat_DBZE_BINS,Nlvgrid), & - temp_cloudsat_precip_cover(cloudsatIN%Npoints,cloudsat_DBZE_BINS), & - temp_cloudsat_pia(cloudsatIN%Npoints)) - print*,'CLOUDSAT-1' - call quickbeam_column(cloudsatIN%Npoints, cloudsatIN%Ncolumns, cloudsatIN%Nlevels,& - Nlvgrid, cloudsat_DBZE_BINS, 'cloudsat', cloudsatDBZe, cloudsatZe_non, & - cospgridIN%land(int(CSCAL_MASK_INDICES)), cospgridIN%surfelev(int(CSCAL_MASK_INDICES)), cospgridIN%at(int(CSCAL_MASK_INDICES),cospIN%Nlevels), & ! JKS - cospIN%fracPrecipIce(int(CSCAL_MASK_INDICES),:), cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES),:), cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES),:), & ! JKS - temp_cloudsat_cfad_ze(:,:,:), temp_cloudsat_precip_cover(:,:), & - temp_cloudsat_pia(:)) - print*,'CLOUDSAT-2' - ! Decode back to the cospOUT shapes - cospOUT%cloudsat_cfad_ze(ij:ik,:,:) = R_UNDEF - cospOUT%cloudsat_precip_cover(ij:ik,:) = R_UNDEF - cospOUT%cloudsat_pia(ij:ik) = R_UNDEF - if (associated(cospOUT%cloudsat_cfad_ze)) cospOUT%cloudsat_cfad_ze(ij+int(CSCAL_MASK_INDICES)-1,:,:) = temp_cloudsat_cfad_ze(:,:,:) - if (associated(cospOUT%cloudsat_precip_cover)) cospOUT%cloudsat_precip_cover(ij+int(CSCAL_MASK_INDICES)-1,:) = temp_cloudsat_precip_cover(:,:) - if (associated(cospOUT%cloudsat_pia)) cospOUT%cloudsat_pia(ij+int(CSCAL_MASK_INDICES)-1) = temp_cloudsat_pia(:) - deallocate(temp_cloudsat_cfad_ze,temp_cloudsat_precip_cover,temp_cloudsat_pia) - if (allocated(CSCAL_SWATH_MASK)) deallocate(CSCAL_SWATH_MASK) - print*,'CLOUDSAT-4' + if (verbose) print*,'CLOUDSAT' + if (cloudsatIN%Npoints .gt. 0) then + allocate(temp_cloudsat_cfad_ze(cloudsatIN%Npoints,cloudsat_DBZE_BINS,Nlvgrid), & + temp_cloudsat_precip_cover(cloudsatIN%Npoints,cloudsat_DBZE_BINS), & + temp_cloudsat_pia(cloudsatIN%Npoints)) + ! print*,'CLOUDSAT-1' + call quickbeam_column(cloudsatIN%Npoints, cloudsatIN%Ncolumns, cloudsatIN%Nlevels, & + Nlvgrid, cloudsat_DBZE_BINS, 'cloudsat', cloudsatDBZe, cloudsatZe_non, & + cospgridIN%land(int(CSCAL_MASK_INDICES)), cospgridIN%surfelev(int(CSCAL_MASK_INDICES)), & + cospgridIN%at(int(CSCAL_MASK_INDICES),cospIN%Nlevels), cospIN%fracPrecipIce(int(CSCAL_MASK_INDICES),:), & + cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES),:), cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES),:), & + temp_cloudsat_cfad_ze(:,:,:), temp_cloudsat_precip_cover(:,:), temp_cloudsat_pia(:)) + ! print*,'CLOUDSAT-2' + ! Decode back to the cospOUT shapes + cospOUT%cloudsat_cfad_ze(ij:ik,:,:) = R_UNDEF + cospOUT%cloudsat_precip_cover(ij:ik,:) = R_UNDEF + cospOUT%cloudsat_pia(ij:ik) = R_UNDEF + if (associated(cospOUT%cloudsat_cfad_ze)) cospOUT%cloudsat_cfad_ze(ij+int(CSCAL_MASK_INDICES)-1,:,:) = temp_cloudsat_cfad_ze(:,:,:) + if (associated(cospOUT%cloudsat_precip_cover)) cospOUT%cloudsat_precip_cover(ij+int(CSCAL_MASK_INDICES)-1,:) = temp_cloudsat_precip_cover(:,:) + if (associated(cospOUT%cloudsat_pia)) cospOUT%cloudsat_pia(ij+int(CSCAL_MASK_INDICES)-1) = temp_cloudsat_pia(:) + deallocate(temp_cloudsat_cfad_ze,temp_cloudsat_precip_cover,temp_cloudsat_pia) + if (allocated(CSCAL_SWATH_MASK)) deallocate(CSCAL_SWATH_MASK) + ! print*,'CLOUDSAT-4' + else + cospOUT%cloudsat_cfad_ze(ij:ik,:,:) = R_UNDEF + cospOUT%cloudsat_precip_cover(ij:ik,:) = R_UNDEF + cospOUT%cloudsat_pia(ij:ik) = R_UNDEF + endif else call quickbeam_column(cloudsatIN%Npoints, cloudsatIN%Ncolumns, cloudsatIN%Nlevels,& Nlvgrid, cloudsat_DBZE_BINS, 'cloudsat', cloudsatDBZe, cloudsatZe_non, & @@ -2044,9 +2107,9 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! MODIS if (Lmodis_column) then - print*,'MODIS' - if(modisIN%nSunlit > 0) then - print*,'MODIS-1' + if (verbose) print*,'MODIS' + if (modisIN%nSunlit > 0) then + ! print*,'MODIS-1' ! Allocate space for local variables allocate(modisCftotal(modisIN%nSunlit), modisCfLiquid(modisIN%nSunlit), & modisCfIce(modisIN%nSunlit),modisCfHigh(modisIN%nSunlit), & @@ -2064,7 +2127,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) modisJointHistogram(modisIN%nSunlit,numMODISTauBins,numMODISPresBins),& modisJointHistogramIce(modisIN%nSunlit,numModisTauBins,numMODISReffIceBins),& modisJointHistogramLiq(modisIN%nSunlit,numModisTauBins,numMODISReffLiqBins)) - print*,'MODIS-2' + ! print*,'MODIS-2' ! Call simulator call modis_column(modisIN%nSunlit, modisIN%Ncolumns,modisRetrievedPhase, & modisRetrievedCloudTopPressure,modisRetrievedTau, & @@ -2076,7 +2139,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) modisMeanCloudTopPressure, modisMeanLiquidWaterPath, & modisMeanIceWaterPath, modisJointHistogram, & modisJointHistogramIce,modisJointHistogramLiq) - print*,'MODIS-3' + ! print*,'MODIS-3' ! Store data (if requested) if (associated(cospOUT%modis_Cloud_Fraction_Total_Mean)) then cospOUT%modis_Cloud_Fraction_Total_Mean(ij+int(modisIN%sunlit(:))-1) = & @@ -2163,7 +2226,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospOUT%modis_Optical_Thickness_vs_ReffLiq(ij+int(modisIN%sunlit(:))-1, 1:numMODISTauBins,:) = & modisJointHistogramLiq(:,:,:) endif - print*,'MODIS-4' + ! print*,'MODIS-4' if(modisIN%nSunlit < modisIN%Npoints) then ! Where it's night and we haven't done the retrievals the values are undefined @@ -2209,7 +2272,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospOUT%modis_Optical_Thickness_vs_ReffLiq(ij+int(modisIN%notSunlit(:))-1, :, :) = R_UNDEF end if else - print*,'MODIS-5' + ! print*,'MODIS-5' ! It's nightime everywhere - everything is undefined if (associated(cospOUT%modis_Cloud_Fraction_Total_Mean)) & cospOUT%modis_Cloud_Fraction_Total_Mean(ij:ik) = R_UNDEF @@ -2283,7 +2346,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (allocated(isccp_meantbclr)) deallocate(isccp_meantbclr) if (allocated(isccpLEVMATCH)) deallocate(isccpLEVMATCH) if (allocated(MODIS_SWATH_MASK)) deallocate(MODIS_SWATH_MASK) - if (allocated(MODIS_MASK_INDICES)) deallocate(MODIS_MASK_INDICES) endif ! RTTOV multi-instrument @@ -2381,77 +2443,76 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! CLOUDSAT/CALIPSO products if (Lradar_lidar_tcc .or. Llidar_only_freq_cloud .or. Lcloudsat_tcc .or. Lcloudsat_tcc2) then - print*,'CLOUDSAT/CALIPSO joint' - if (use_vgrid) then - allocate(lidar_only_freq_cloud(cloudsatIN%Npoints,Nlvgrid), & - radar_lidar_tcc(cloudsatIN%Npoints), cloudsat_tcc(cloudsatIN%Npoints), & - cloudsat_tcc2(cloudsatIN%Npoints)) - allocate(betamol_in(cloudsatIN%Npoints,1,cloudsatIN%Nlevels), & - betamolI(cloudsatIN%Npoints,1,Nlvgrid), & - pnormI(cloudsatIN%Npoints,cloudsatIN%Ncolumns,Nlvgrid), & - Ze_totI(cloudsatIN%Npoints,cloudsatIN%Ncolumns,Nlvgrid)) - - ! Regrid in the vertical (*NOTE* This routine requires SFC-2-TOA ordering, so flip - ! inputs and outputs to maintain TOA-2-SFC ordering convention in COSP2.) - print*,'CLOUDSAT/CALIPSO joint-1' - ! print*,'allocated(CSCAL_MASK_INDICES): ',allocated(CSCAL_MASK_INDICES) - ! print*,'allocated(calipso_beta_mol): ',allocated(calipso_beta_mol) - ! print*,'allocated(cloudsatDBZe): ',allocated(cloudsatDBZe) - ! Use CLOUDSAT masking array here (it should be the same as calipso) - if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays - betamol_in(:,1,:) = calipso_beta_mol(:,cloudsatIN%Nlevels:1:-1) - call cosp_change_vertical_grid(cloudsatIN%Npoints,1,cloudsatIN%Nlevels, & - cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & - cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1),betamol_in, & - Nlvgrid,vgrid_zl(Nlvgrid:1:-1),vgrid_zu(Nlvgrid:1:-1), & - betamolI(:,1,Nlvgrid:1:-1)) - call cosp_change_vertical_grid(cloudsatIN%Npoints,cloudsatIN%Ncolumns, & - cloudsatIN%Nlevels,cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & - cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & - calipso_beta_tot(:,:,cloudsatIN%Nlevels:1:-1),Nlvgrid, & - vgrid_zl(Nlvgrid:1:-1),vgrid_zu(Nlvgrid:1:-1),pnormI(:,:,Nlvgrid:1:-1)) - call cosp_change_vertical_grid(cloudsatIN%Npoints,cloudsatIN%Ncolumns, & - cloudsatIN%Nlevels,cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & - cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & - cloudsatDBZe(:,:,cloudsatIN%Nlevels:1:-1),Nlvgrid,vgrid_zl(Nlvgrid:1:-1), & - vgrid_zu(Nlvgrid:1:-1),Ze_totI(:,:,Nlvgrid:1:-1),log_units=.true.) - print*,'CLOUDSAT/CALIPSO joint-2' + if (verbose) print*,'CLOUDSAT/CALIPSO joint' + if (calipsoIN%Npoints .gt. 0) then + if (use_vgrid) then + allocate(lidar_only_freq_cloud(cloudsatIN%Npoints,Nlvgrid), & + radar_lidar_tcc(cloudsatIN%Npoints), cloudsat_tcc(cloudsatIN%Npoints), & + cloudsat_tcc2(cloudsatIN%Npoints)) + allocate(betamol_in(cloudsatIN%Npoints,1,cloudsatIN%Nlevels), & + betamolI(cloudsatIN%Npoints,1,Nlvgrid), & + pnormI(cloudsatIN%Npoints,cloudsatIN%Ncolumns,Nlvgrid), & + Ze_totI(cloudsatIN%Npoints,cloudsatIN%Ncolumns,Nlvgrid)) + + ! Regrid in the vertical (*NOTE* This routine requires SFC-2-TOA ordering, so flip + ! inputs and outputs to maintain TOA-2-SFC ordering convention in COSP2.) + ! print*,'CLOUDSAT/CALIPSO joint-1' + ! Use CLOUDSAT masking array here (it is the same as calipso) + if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + betamol_in(:,1,:) = calipso_beta_mol(:,cloudsatIN%Nlevels:1:-1) + call cosp_change_vertical_grid(cloudsatIN%Npoints,1,cloudsatIN%Nlevels, & + cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & + cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1),betamol_in, & + Nlvgrid,vgrid_zl(Nlvgrid:1:-1),vgrid_zu(Nlvgrid:1:-1), & + betamolI(:,1,Nlvgrid:1:-1)) + call cosp_change_vertical_grid(cloudsatIN%Npoints,cloudsatIN%Ncolumns, & + cloudsatIN%Nlevels,cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & + cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & + calipso_beta_tot(:,:,cloudsatIN%Nlevels:1:-1),Nlvgrid, & + vgrid_zl(Nlvgrid:1:-1),vgrid_zu(Nlvgrid:1:-1),pnormI(:,:,Nlvgrid:1:-1)) + call cosp_change_vertical_grid(cloudsatIN%Npoints,cloudsatIN%Ncolumns, & + cloudsatIN%Nlevels,cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & + cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & + cloudsatDBZe(:,:,cloudsatIN%Nlevels:1:-1),Nlvgrid,vgrid_zl(Nlvgrid:1:-1), & + vgrid_zu(Nlvgrid:1:-1),Ze_totI(:,:,Nlvgrid:1:-1),log_units=.true.) + ! print*,'CLOUDSAT/CALIPSO joint-2' + else + betamol_in(:,1,:) = calipso_beta_mol(:,cloudsatIN%Nlevels:1:-1) + call cosp_change_vertical_grid(cloudsatIN%Npoints,1,cloudsatIN%Nlevels, & + cospgridIN%hgt_matrix(:,cloudsatIN%Nlevels:1:-1), & + cospgridIN%hgt_matrix_half(:,cloudsatIN%Nlevels:1:-1),betamol_in, & + Nlvgrid,vgrid_zl(Nlvgrid:1:-1),vgrid_zu(Nlvgrid:1:-1), & + betamolI(:,1,Nlvgrid:1:-1)) + + call cosp_change_vertical_grid(cloudsatIN%Npoints,cloudsatIN%Ncolumns, & + cloudsatIN%Nlevels,cospgridIN%hgt_matrix(:,cloudsatIN%Nlevels:1:-1), & + cospgridIN%hgt_matrix_half(:,cloudsatIN%Nlevels:1:-1), & + calipso_beta_tot(:,:,cloudsatIN%Nlevels:1:-1),Nlvgrid, & + vgrid_zl(Nlvgrid:1:-1),vgrid_zu(Nlvgrid:1:-1),pnormI(:,:,Nlvgrid:1:-1)) + + call cosp_change_vertical_grid(cloudsatIN%Npoints,cloudsatIN%Ncolumns, & + cloudsatIN%Nlevels,cospgridIN%hgt_matrix(:,cloudsatIN%Nlevels:1:-1), & + cospgridIN%hgt_matrix_half(:,cloudsatIN%Nlevels:1:-1), & + cloudsatDBZe(:,:,cloudsatIN%Nlevels:1:-1),Nlvgrid,vgrid_zl(Nlvgrid:1:-1), & + vgrid_zu(Nlvgrid:1:-1),Ze_totI(:,:,Nlvgrid:1:-1),log_units=.true.) + ! print*,'CLOUDSAT/CALIPSO joint-2b' + end if + call cosp_lidar_only_cloud(cloudsatIN%Npoints, cloudsatIN%Ncolumns, Nlvgrid, & + pnormI, betamolI, Ze_totI, lidar_only_freq_cloud, radar_lidar_tcc, & + cloudsat_tcc, cloudsat_tcc2) + deallocate(betamol_in,betamolI,pnormI,ze_totI) else - betamol_in(:,1,:) = calipso_beta_mol(:,cloudsatIN%Nlevels:1:-1) - call cosp_change_vertical_grid(cloudsatIN%Npoints,1,cloudsatIN%Nlevels, & - cospgridIN%hgt_matrix(:,cloudsatIN%Nlevels:1:-1), & - cospgridIN%hgt_matrix_half(:,cloudsatIN%Nlevels:1:-1),betamol_in, & - Nlvgrid,vgrid_zl(Nlvgrid:1:-1),vgrid_zu(Nlvgrid:1:-1), & - betamolI(:,1,Nlvgrid:1:-1)) - - call cosp_change_vertical_grid(cloudsatIN%Npoints,cloudsatIN%Ncolumns, & - cloudsatIN%Nlevels,cospgridIN%hgt_matrix(:,cloudsatIN%Nlevels:1:-1), & - cospgridIN%hgt_matrix_half(:,cloudsatIN%Nlevels:1:-1), & - calipso_beta_tot(:,:,cloudsatIN%Nlevels:1:-1),Nlvgrid, & - vgrid_zl(Nlvgrid:1:-1),vgrid_zu(Nlvgrid:1:-1),pnormI(:,:,Nlvgrid:1:-1)) - - call cosp_change_vertical_grid(cloudsatIN%Npoints,cloudsatIN%Ncolumns, & - cloudsatIN%Nlevels,cospgridIN%hgt_matrix(:,cloudsatIN%Nlevels:1:-1), & - cospgridIN%hgt_matrix_half(:,cloudsatIN%Nlevels:1:-1), & - cloudsatDBZe(:,:,cloudsatIN%Nlevels:1:-1),Nlvgrid,vgrid_zl(Nlvgrid:1:-1), & - vgrid_zu(Nlvgrid:1:-1),Ze_totI(:,:,Nlvgrid:1:-1),log_units=.true.) - print*,'CLOUDSAT/CALIPSO joint-2b' - end if - call cosp_lidar_only_cloud(cloudsatIN%Npoints, cloudsatIN%Ncolumns, Nlvgrid, & - pnormI, betamolI, Ze_totI, lidar_only_freq_cloud, radar_lidar_tcc, & - cloudsat_tcc, cloudsat_tcc2) - deallocate(betamol_in,betamolI,pnormI,ze_totI) - else - allocate(lidar_only_freq_cloud(cloudsatIN%Npoints,cloudsatIN%Nlevels), & - radar_lidar_tcc(cloudsatIN%Npoints), cloudsat_tcc(cloudsatIN%Npoints), & - cloudsat_tcc2(cloudsatIN%Npoints)) - print*,'CLOUDSAT/CALIPSO joint-3' - call cosp_lidar_only_cloud(cloudsatIN%Npoints,cloudsatIN%Ncolumns, & - cospIN%Nlevels,calipso_beta_tot(:,:,cloudsatIN%Nlevels:1:-1), & - calipso_beta_mol(:,cloudsatIN%Nlevels:1:-1), & - cloudsatDBZe(:,:,cloudsatIN%Nlevels:1:-1),lidar_only_freq_cloud, & - radar_lidar_tcc, cloudsat_tcc, cloudsat_tcc2) - print*,'CLOUDSAT/CALIPSO joint-4' + allocate(lidar_only_freq_cloud(cloudsatIN%Npoints,cloudsatIN%Nlevels), & + radar_lidar_tcc(cloudsatIN%Npoints), cloudsat_tcc(cloudsatIN%Npoints), & + cloudsat_tcc2(cloudsatIN%Npoints)) + ! print*,'CLOUDSAT/CALIPSO joint-3' + call cosp_lidar_only_cloud(cloudsatIN%Npoints,cloudsatIN%Ncolumns, & + cospIN%Nlevels,calipso_beta_tot(:,:,cloudsatIN%Nlevels:1:-1), & + calipso_beta_mol(:,cloudsatIN%Nlevels:1:-1), & + cloudsatDBZe(:,:,cloudsatIN%Nlevels:1:-1),lidar_only_freq_cloud, & + radar_lidar_tcc, cloudsat_tcc, cloudsat_tcc2) + ! print*,'CLOUDSAT/CALIPSO joint-4' + endif endif ! Store, when necessary @@ -2490,172 +2551,177 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! CloudSat/MODIS joint products (CFODDs and Occurrence Frequency of Warm Clouds) if (Lcloudsat_modis_wr) then - print*,'CLOUDSAT/MODIS joint' - allocate( cfodd_ntotal(cloudsatIN%Npoints, CFODD_NDBZE, CFODD_NICOD, CFODD_NCLASS) ) - allocate( wr_occfreq_ntotal(cloudsatIN%Npoints, WR_NREGIME) ) - - if ( use_vgrid ) then - !! interporation for fixed vertical grid: - print*,'CLOUDSAT/MODIS joint-1' - allocate( zlev(cloudsatIN%Npoints,Nlvgrid), & - t_in(cloudsatIN%Npoints,1,cloudsatIN%Nlevels), & - tempI(cloudsatIN%Npoints,1,Nlvgrid), & - Ze_totI(cloudsatIN%Npoints,cloudsatIN%Ncolumns,Nlvgrid), & - frac_outI(cloudsatIN%Npoints,cloudsatIN%Ncolumns,Nlvgrid) ) - do k = 1, Nlvgrid - zlev(:,k) = vgrid_zu(k) - enddo - print*,'CLOUDSAT/MODIS joint-2' - ! Use CLOUDSAT masking array here (it should be the same as calipso) - if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays - t_in(:,1,:) = cospgridIN%at(int(CSCAL_MASK_INDICES(:)),:) - call cosp_change_vertical_grid ( & - cloudsatIN%Npoints, 1, cloudsatIN%Nlevels, & - cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & - cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & - t_in(:,:,cloudsatIN%Nlevels:1:-1), Nlvgrid, & - vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), & - tempI(:,:,Nlvgrid:1:-1) ) - call cosp_change_vertical_grid ( & - cloudsatIN%Npoints, cloudsatIN%Ncolumns, cloudsatIN%Nlevels, & - cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & - cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & - cloudsatDBZe(:,:,cloudsatIN%Nlevels:1:-1), Nlvgrid, & - vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), & - Ze_totI(:,:,Nlvgrid:1:-1), log_units=.true. ) - call cosp_change_vertical_grid ( & - cloudsatIN%Npoints, cloudsatIN%Ncolumns, cloudsatIN%Nlevels, & - cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & - cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & - cospIN%frac_out(int(CSCAL_MASK_INDICES(:)),:,cloudsatIN%Nlevels:1:-1), Nlvgrid, & - vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), & - frac_outI(:,:,Nlvgrid:1:-1) ) - print*,'CLOUDSAT/MODIS joint-3' - call cosp_diag_warmrain( & - cloudsatIN%Npoints, cloudsatIN%Ncolumns, Nlvgrid, & !! in - tempI, zlev, & !! in - cospOUT%modis_Liquid_Water_Path_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in - cospOUT%modis_Optical_Thickness_Water_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in - cospOUT%modis_Cloud_Particle_Size_Water_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in - cospOUT%modis_Cloud_Fraction_Water_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in - cospOUT%modis_Ice_Water_Path_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in - cospOUT%modis_Optical_Thickness_Ice_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in - cospOUT%modis_Cloud_Particle_Size_Ice_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in - cospOUT%modis_Cloud_Fraction_Ice_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in - frac_outI, & !! in - Ze_totI, & !! in - cfodd_ntotal, wr_occfreq_ntotal ) !! inout - else - t_in(:,1,:) = cospgridIN%at(:,:) - call cosp_change_vertical_grid ( & - cloudsatIN%Npoints, 1, cloudsatIN%Nlevels, & - cospgridIN%hgt_matrix(:,cloudsatIN%Nlevels:1:-1), & - cospgridIN%hgt_matrix_half(:,cloudsatIN%Nlevels:1:-1), & - t_in(:,:,cloudsatIN%Nlevels:1:-1), Nlvgrid, & - vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), & - tempI(:,:,Nlvgrid:1:-1) ) - call cosp_change_vertical_grid ( & - cloudsatIN%Npoints, cloudsatIN%Ncolumns, cloudsatIN%Nlevels, & - cospgridIN%hgt_matrix(:,cloudsatIN%Nlevels:1:-1), & - cospgridIN%hgt_matrix_half(:,cloudsatIN%Nlevels:1:-1), & - cloudsatDBZe(:,:,cloudsatIN%Nlevels:1:-1), Nlvgrid, & - vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), & - Ze_totI(:,:,Nlvgrid:1:-1), log_units=.true. ) - call cosp_change_vertical_grid ( & - cloudsatIN%Npoints, cloudsatIN%Ncolumns, cloudsatIN%Nlevels, & - cospgridIN%hgt_matrix(:,cloudsatIN%Nlevels:1:-1), & - cospgridIN%hgt_matrix_half(:,cloudsatIN%Nlevels:1:-1), & - cospIN%frac_out(:,:,cloudsatIN%Nlevels:1:-1), Nlvgrid, & - vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), & - frac_outI(:,:,Nlvgrid:1:-1) ) - print*,'CLOUDSAT/MODIS joint-3b' - call cosp_diag_warmrain( & - cloudsatIN%Npoints, cloudsatIN%Ncolumns, Nlvgrid, & !! in - tempI, zlev, & !! in - cospOUT%modis_Liquid_Water_Path_Mean(ij:ik), & !! in ! JKS fix bug here. - cospOUT%modis_Optical_Thickness_Water_Mean(ij:ik), & !! in - cospOUT%modis_Cloud_Particle_Size_Water_Mean(ij:ik), & !! in - cospOUT%modis_Cloud_Fraction_Water_Mean(ij:ik), & !! in - cospOUT%modis_Ice_Water_Path_Mean(ij:ik), & !! in - cospOUT%modis_Optical_Thickness_Ice_Mean(ij:ik), & !! in - cospOUT%modis_Cloud_Particle_Size_Ice_Mean(ij:ik), & !! in - cospOUT%modis_Cloud_Fraction_Ice_Mean(ij:ik), & !! in - frac_outI, & !! in - Ze_totI, & !! in - cfodd_ntotal, wr_occfreq_ntotal ) !! inout - endif - print*,'CLOUDSAT/MODIS joint-4' - deallocate( zlev, t_in, tempI, frac_outI, Ze_totI ) - else ! do not use vgrid interporation ---------------------------------------! - !! original model grid - print*,'CLOUDSAT/MODIS joint-5' - if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays - call cosp_diag_warmrain( & - cloudsatIN%Npoints, cloudsatIN%Ncolumns, cospIN%Nlevels, & !! in - cospgridIN%at(int(CSCAL_MASK_INDICES(:)),:), cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES(:)),:), & !! in - cospOUT%modis_Liquid_Water_Path_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in - cospOUT%modis_Optical_Thickness_Water_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in - cospOUT%modis_Cloud_Particle_Size_Water_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in - cospOUT%modis_Cloud_Fraction_Water_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in - cospOUT%modis_Ice_Water_Path_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in - cospOUT%modis_Optical_Thickness_Ice_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in - cospOUT%modis_Cloud_Particle_Size_Ice_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in - cospOUT%modis_Cloud_Fraction_Ice_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in - cospIN%frac_out(int(CSCAL_MASK_INDICES(:)),:,:), & !! in - cloudsatDBZe, & !! in - cfodd_ntotal, wr_occfreq_ntotal ) !! inout - else - call cosp_diag_warmrain( & - cloudsatIN%Npoints, cloudsatIN%Ncolumns, cospIN%Nlevels, & !! in - cospgridIN%at, cospgridIN%hgt_matrix, & !! in - cospOUT%modis_Liquid_Water_Path_Mean(ij:ik), & !! in - cospOUT%modis_Optical_Thickness_Water_Mean(ij:ik), & !! in - cospOUT%modis_Cloud_Particle_Size_Water_Mean(ij:ik), & !! in - cospOUT%modis_Cloud_Fraction_Water_Mean(ij:ik), & !! in - cospOUT%modis_Ice_Water_Path_Mean(ij:ik), & !! in - cospOUT%modis_Optical_Thickness_Ice_Mean(ij:ik), & !! in - cospOUT%modis_Cloud_Particle_Size_Ice_Mean(ij:ik), & !! in - cospOUT%modis_Cloud_Fraction_Ice_Mean(ij:ik), & !! in - cospIN%frac_out, & !! in - cloudsatDBZe, & !! in - cfodd_ntotal, wr_occfreq_ntotal ) !! inout - endif - print*,'CLOUDSAT/MODIS joint-6' - endif !! use_vgrid or not - - ! Store, when necessary - cospOUT%lidar_only_freq_cloud(ij+int(CSCAL_MASK_INDICES(:))-1,:) = lidar_only_freq_cloud(:,:) - - if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays for CSCAL - if (cospIN % cospswathsIN(6) % N_inst_swaths .gt. 0) then ! If MODIS is also swathed then use the joint mask MODIS_CSCAL_MASK_INDICES for setting R_UNDEF - if ( associated(cospOUT%cfodd_ntotal) ) then - cospOUT%cfodd_ntotal(ij+int(CSCAL_MASK_INDICES(:))-1,:,:,:) = cfodd_ntotal - cospOUT%cfodd_ntotal(ij+int(MODIS_CSCAL_MASK_INDICES(:))-1,:,:,:) = R_UNDEF + if (verbose) print*,'CLOUDSAT/MODIS joint' + if (cloudsatIN%Npoints .gt. 0) then + allocate( cfodd_ntotal(cloudsatIN%Npoints, CFODD_NDBZE, CFODD_NICOD, CFODD_NCLASS) ) + allocate( wr_occfreq_ntotal(cloudsatIN%Npoints, WR_NREGIME) ) + + if ( use_vgrid ) then + !! interporation for fixed vertical grid: + ! print*,'CLOUDSAT/MODIS joint-1' + allocate( zlev(cloudsatIN%Npoints,Nlvgrid), & + t_in(cloudsatIN%Npoints,1,cloudsatIN%Nlevels), & + tempI(cloudsatIN%Npoints,1,Nlvgrid), & + Ze_totI(cloudsatIN%Npoints,cloudsatIN%Ncolumns,Nlvgrid), & + frac_outI(cloudsatIN%Npoints,cloudsatIN%Ncolumns,Nlvgrid) ) + do k = 1, Nlvgrid + zlev(:,k) = vgrid_zu(k) + enddo + ! print*,'CLOUDSAT/MODIS joint-2' + ! Use CLOUDSAT masking array here (it is the same as calipso) + if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + t_in(:,1,:) = cospgridIN%at(int(CSCAL_MASK_INDICES(:)),:) + call cosp_change_vertical_grid ( & + cloudsatIN%Npoints, 1, cloudsatIN%Nlevels, & + cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & + cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & + t_in(:,:,cloudsatIN%Nlevels:1:-1), Nlvgrid, & + vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), & + tempI(:,:,Nlvgrid:1:-1) ) + call cosp_change_vertical_grid ( & + cloudsatIN%Npoints, cloudsatIN%Ncolumns, cloudsatIN%Nlevels, & + cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & + cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & + cloudsatDBZe(:,:,cloudsatIN%Nlevels:1:-1), Nlvgrid, & + vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), & + Ze_totI(:,:,Nlvgrid:1:-1), log_units=.true. ) + call cosp_change_vertical_grid ( & + cloudsatIN%Npoints, cloudsatIN%Ncolumns, cloudsatIN%Nlevels, & + cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & + cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & + cospIN%frac_out(int(CSCAL_MASK_INDICES(:)),:,cloudsatIN%Nlevels:1:-1), Nlvgrid, & + vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), & + frac_outI(:,:,Nlvgrid:1:-1) ) + ! print*,'CLOUDSAT/MODIS joint-3' + call cosp_diag_warmrain( & + cloudsatIN%Npoints, cloudsatIN%Ncolumns, Nlvgrid, & !! in + tempI, zlev, & !! in + cospOUT%modis_Liquid_Water_Path_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Optical_Thickness_Water_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Cloud_Particle_Size_Water_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Cloud_Fraction_Water_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Ice_Water_Path_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Optical_Thickness_Ice_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Cloud_Particle_Size_Ice_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Cloud_Fraction_Ice_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + frac_outI, & !! in + Ze_totI, & !! in + cfodd_ntotal, wr_occfreq_ntotal ) !! inout + else + t_in(:,1,:) = cospgridIN%at(:,:) + call cosp_change_vertical_grid ( & + cloudsatIN%Npoints, 1, cloudsatIN%Nlevels, & + cospgridIN%hgt_matrix(:,cloudsatIN%Nlevels:1:-1), & + cospgridIN%hgt_matrix_half(:,cloudsatIN%Nlevels:1:-1), & + t_in(:,:,cloudsatIN%Nlevels:1:-1), Nlvgrid, & + vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), & + tempI(:,:,Nlvgrid:1:-1) ) + call cosp_change_vertical_grid ( & + cloudsatIN%Npoints, cloudsatIN%Ncolumns, cloudsatIN%Nlevels, & + cospgridIN%hgt_matrix(:,cloudsatIN%Nlevels:1:-1), & + cospgridIN%hgt_matrix_half(:,cloudsatIN%Nlevels:1:-1), & + cloudsatDBZe(:,:,cloudsatIN%Nlevels:1:-1), Nlvgrid, & + vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), & + Ze_totI(:,:,Nlvgrid:1:-1), log_units=.true. ) + call cosp_change_vertical_grid ( & + cloudsatIN%Npoints, cloudsatIN%Ncolumns, cloudsatIN%Nlevels, & + cospgridIN%hgt_matrix(:,cloudsatIN%Nlevels:1:-1), & + cospgridIN%hgt_matrix_half(:,cloudsatIN%Nlevels:1:-1), & + cospIN%frac_out(:,:,cloudsatIN%Nlevels:1:-1), Nlvgrid, & + vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), & + frac_outI(:,:,Nlvgrid:1:-1) ) + ! print*,'CLOUDSAT/MODIS joint-3b' + call cosp_diag_warmrain( & + cloudsatIN%Npoints, cloudsatIN%Ncolumns, Nlvgrid, & !! in + tempI, zlev, & !! in + cospOUT%modis_Liquid_Water_Path_Mean(ij:ik), & !! in + cospOUT%modis_Optical_Thickness_Water_Mean(ij:ik), & !! in + cospOUT%modis_Cloud_Particle_Size_Water_Mean(ij:ik), & !! in + cospOUT%modis_Cloud_Fraction_Water_Mean(ij:ik), & !! in + cospOUT%modis_Ice_Water_Path_Mean(ij:ik), & !! in + cospOUT%modis_Optical_Thickness_Ice_Mean(ij:ik), & !! in + cospOUT%modis_Cloud_Particle_Size_Ice_Mean(ij:ik), & !! in + cospOUT%modis_Cloud_Fraction_Ice_Mean(ij:ik), & !! in + frac_outI, & !! in + Ze_totI, & !! in + cfodd_ntotal, wr_occfreq_ntotal ) !! inout endif - if ( associated(cospOUT%wr_occfreq_ntotal) ) then - cospOUT%wr_occfreq_ntotal(ij+int(CSCAL_MASK_INDICES(:))-1,:) = wr_occfreq_ntotal - cospOUT%wr_occfreq_ntotal(ij+int(MODIS_CSCAL_MASK_INDICES(:))-1,:) = R_UNDEF - endif - else ! Otherwise just mask simpling + ! print*,'CLOUDSAT/MODIS joint-4' + deallocate( zlev, t_in, tempI, frac_outI, Ze_totI ) + else ! do not use vgrid interporation ---------------------------------------! + !! original model grid + ! print*,'CLOUDSAT/MODIS joint-5' + if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + call cosp_diag_warmrain( & + cloudsatIN%Npoints, cloudsatIN%Ncolumns, cospIN%Nlevels, & !! in + cospgridIN%at(int(CSCAL_MASK_INDICES(:)),:), & !! in + cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES(:)),:), & !! in + cospOUT%modis_Liquid_Water_Path_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Optical_Thickness_Water_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Cloud_Particle_Size_Water_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Cloud_Fraction_Water_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Ice_Water_Path_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Optical_Thickness_Ice_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Cloud_Particle_Size_Ice_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospOUT%modis_Cloud_Fraction_Ice_Mean(ij+int(CSCAL_MASK_INDICES(:))-1), & !! in + cospIN%frac_out(int(CSCAL_MASK_INDICES(:)),:,:), & !! in + cloudsatDBZe, & !! in + cfodd_ntotal, wr_occfreq_ntotal ) !! inout + else + call cosp_diag_warmrain( & + cloudsatIN%Npoints, cloudsatIN%Ncolumns, cospIN%Nlevels, & !! in + cospgridIN%at, cospgridIN%hgt_matrix, & !! in + cospOUT%modis_Liquid_Water_Path_Mean(ij:ik), & !! in + cospOUT%modis_Optical_Thickness_Water_Mean(ij:ik), & !! in + cospOUT%modis_Cloud_Particle_Size_Water_Mean(ij:ik), & !! in + cospOUT%modis_Cloud_Fraction_Water_Mean(ij:ik), & !! in + cospOUT%modis_Ice_Water_Path_Mean(ij:ik), & !! in + cospOUT%modis_Optical_Thickness_Ice_Mean(ij:ik), & !! in + cospOUT%modis_Cloud_Particle_Size_Ice_Mean(ij:ik), & !! in + cospOUT%modis_Cloud_Fraction_Ice_Mean(ij:ik), & !! in + cospIN%frac_out, & !! in + cloudsatDBZe, & !! in + cfodd_ntotal, wr_occfreq_ntotal ) !! inout + endif + ! print*,'CLOUDSAT/MODIS joint-6' + endif !! use_vgrid or not + + ! Store, when necessary + cospOUT%lidar_only_freq_cloud(ij+int(CSCAL_MASK_INDICES(:))-1,:) = lidar_only_freq_cloud(:,:) + + if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays for CSCAL + if (cospIN % cospswathsIN(6) % N_inst_swaths .gt. 0) then ! If MODIS is also swathed then use the joint mask MODIS_CSCAL_MASK_INDICES for setting R_UNDEF + if ( associated(cospOUT%cfodd_ntotal) ) then + cospOUT%cfodd_ntotal(ij+int(CSCAL_MASK_INDICES(:))-1,:,:,:) = cfodd_ntotal + cospOUT%cfodd_ntotal(ij+int(MODIS_CSCAL_MASK_INDICES(:))-1,:,:,:) = R_UNDEF + endif + if ( associated(cospOUT%wr_occfreq_ntotal) ) then + cospOUT%wr_occfreq_ntotal(ij+int(CSCAL_MASK_INDICES(:))-1,:) = wr_occfreq_ntotal + cospOUT%wr_occfreq_ntotal(ij+int(MODIS_CSCAL_MASK_INDICES(:))-1,:) = R_UNDEF + endif + else + if ( associated(cospOUT%cfodd_ntotal) ) then + cospOUT%cfodd_ntotal(ij:ik,:,:,:) = R_UNDEF + cospOUT%cfodd_ntotal(ij+int(CSCAL_MASK_INDICES(:))-1,:,:,:) = cfodd_ntotal + endif + if ( associated(cospOUT%wr_occfreq_ntotal) ) then + cospOUT%wr_occfreq_ntotal(ij:ik,:) = R_UNDEF + cospOUT%wr_occfreq_ntotal(ij+int(CSCAL_MASK_INDICES(:))-1,:) = wr_occfreq_ntotal + endif + endif + else if ( associated(cospOUT%cfodd_ntotal) ) then - cospOUT%cfodd_ntotal(ij:ik,:,:,:) = R_UNDEF - cospOUT%cfodd_ntotal(ij+int(CSCAL_MASK_INDICES(:))-1,:,:,:) = cfodd_ntotal + cospOUT%cfodd_ntotal(ij:ik,:,:,:) = cfodd_ntotal endif if ( associated(cospOUT%wr_occfreq_ntotal) ) then - cospOUT%wr_occfreq_ntotal(ij:ik,:) = R_UNDEF - cospOUT%wr_occfreq_ntotal(ij+int(CSCAL_MASK_INDICES(:))-1,:) = wr_occfreq_ntotal + cospOUT%wr_occfreq_ntotal(ij:ik,:) = wr_occfreq_ntotal endif endif - else - if ( associated(cospOUT%cfodd_ntotal) ) then - cospOUT%cfodd_ntotal(ij:ik,:,:,:) = cfodd_ntotal - endif - if ( associated(cospOUT%wr_occfreq_ntotal) ) then - cospOUT%wr_occfreq_ntotal(ij:ik,:) = wr_occfreq_ntotal - endif + else + if ( associated(cospOUT%cfodd_ntotal) ) cospOUT%cfodd_ntotal(ij:ik,:,:,:) = R_UNDEF + if ( associated(cospOUT%wr_occfreq_ntotal) ) cospOUT%wr_occfreq_ntotal(ij:ik,:) = R_UNDEF endif endif - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 7) Cleanup !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From 5ae38ff8737071f345e65e1f891f513d587f0274 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 27 Feb 2024 16:31:43 -0700 Subject: [PATCH 111/159] Clean up swathing in RTTOV. Skip allocation if swath is empty. --- driver/run/cosp2_input_rttov_nl.txt | 14 +- .../run/instrument_nls/cosp2_rttov_inst5.txt | 0 .../cosp2_rttov_inst5PREFIRE_CESM2.txt | 0 .../cosp2_rttov_inst5_PREFIRE_CESM2.txt | 4 +- .../cosp2_rttov_inst6_AIRS_CESM2_bin.txt | 6 +- .../cosp2_rttov_inst7_VIIRS_CESM2.txt | 6 +- driver/src/cosp2_test.F90 | 48 ++- src/cosp.F90 | 12 +- src/simulator/cosp_rttov_interface_v13.F90 | 324 +++++++++--------- src/simulator/rttov/cosp_rttov_v13.F90 | 135 ++++---- 10 files changed, 271 insertions(+), 278 deletions(-) delete mode 100644 driver/run/instrument_nls/cosp2_rttov_inst5.txt delete mode 100644 driver/run/instrument_nls/cosp2_rttov_inst5PREFIRE_CESM2.txt diff --git a/driver/run/cosp2_input_rttov_nl.txt b/driver/run/cosp2_input_rttov_nl.txt index 2c90b744aa..cf4beecb88 100644 --- a/driver/run/cosp2_input_rttov_nl.txt +++ b/driver/run/cosp2_input_rttov_nl.txt @@ -98,20 +98,20 @@ !---------------------------------------------------------------------------------- N_SWATHS_ISCCP=2, SWATH_LOCALTIMES_ISCCP=5.25,18.0, - SWATH_WIDTHS_ISCCP=20000,20000, + SWATH_WIDTHS_ISCCP=2000,2000, N_SWATHS_MISR=2, SWATH_LOCALTIMES_MISR=6.5,18.25, - SWATH_WIDTHS_MISR=20000,20000, + SWATH_WIDTHS_MISR=2000,2000, N_SWATHS_MODIS=2, - SWATH_LOCALTIMES_MODIS=5.75,18.5, - SWATH_WIDTHS_MODIS=20000,20000, + SWATH_LOCALTIMES_MODIS=5.75,13.5, + SWATH_WIDTHS_MODIS=2000,2000, N_SWATHS_CSCAL=2, SWATH_LOCALTIMES_CSCAL=6.75,19.25, - SWATH_WIDTHS_CSCAL=20000,20000, + SWATH_WIDTHS_CSCAL=2000,2000, N_SWATHS_PARASOL=2, SWATH_LOCALTIMES_PARASOL=6.75,19, - SWATH_WIDTHS_PARASOL=20000,20000, + SWATH_WIDTHS_PARASOL=2000,2000, N_SWATHS_ATLID=2, SWATH_LOCALTIMES_ATLID=7.25,19.5, - SWATH_WIDTHS_ATLID=20000,20000, + SWATH_WIDTHS_ATLID=2000,2000, / diff --git a/driver/run/instrument_nls/cosp2_rttov_inst5.txt b/driver/run/instrument_nls/cosp2_rttov_inst5.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/driver/run/instrument_nls/cosp2_rttov_inst5PREFIRE_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_inst5PREFIRE_CESM2.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt index e8f926ae0e..9ceb9fdcf9 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt @@ -76,5 +76,7 @@ rttov_nthreads=1, rttov_ZenAng=0.0, ! Satellite Zenith Angle ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at + rttov_Nlocaltime=2, ! Number of local times to sample at + rttov_localtime=6.75,19.25, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=15000,2000, ! Swath width (km) / diff --git a/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt b/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt index 7a3186572b..fa9f3c14e6 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt @@ -71,7 +71,7 @@ rttov_nthreads=1, rttov_ZenAng=0.0, ! Satellite Zenith Angle ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at -! rttov_localtime=0.75,13.5, ! Local times to sample at in hrs [0,24] -! rttov_localtime_width=2.e3,5.6e3, ! Swath width (km) + rttov_Nlocaltime=2, ! Number of local times to sample at + rttov_localtime=5.75,13.5, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=2000,2000, ! Swath width (km) / diff --git a/driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt index 5295d190a3..8c2589361c 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt @@ -74,7 +74,7 @@ rttov_nthreads=1, rttov_ZenAng=0.0, ! Satellite Zenith Angle ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at -! rttov_localtime=0.75,13.5, ! Local times to sample at in hrs [0,24] -! rttov_localtime_width=2.e3,5.6e3, ! Swath width (km) + rttov_Nlocaltime=2, ! Number of local times to sample at + rttov_localtime=5.75,13.5, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=2000,2000, ! Swath width (km) / diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index afd369f098..c06ba9a756 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -315,12 +315,9 @@ program cosp2_test real(wp),dimension(:),allocatable :: & cosp_localtime, & cosp_localtime_width - - logical,dimension(:),allocatable :: & - swath_mask_out ! Mask of reals over all local times ! Swathing DDT array - type(swath_inputs),dimension(7) :: & + type(swath_inputs),dimension(6) :: & cospswathsIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -352,24 +349,24 @@ program cosp2_test ! Read orbital swathing inputs into structure: ! Indexing order is ISCCP, MISR, CLOUDSAT-CALIPSO, ATLID, PARASOL, MODIS - cospswathsIN(1) % N_inst_swaths = N_SWATHS_ISCCP - cospswathsIN(1) % inst_localtimes => SWATH_LOCALTIMES_ISCCP(1:N_SWATHS_ISCCP) - cospswathsIN(1) % inst_localtime_widths => SWATH_WIDTHS_ISCCP(1:N_SWATHS_ISCCP) - cospswathsIN(2) % N_inst_swaths = N_SWATHS_MISR - cospswathsIN(2) % inst_localtimes => SWATH_LOCALTIMES_MISR(1:N_SWATHS_MISR) - cospswathsIN(2) % inst_localtime_widths => SWATH_WIDTHS_MISR(1:N_SWATHS_MISR) - cospswathsIN(3) % N_inst_swaths = N_SWATHS_CSCAL - cospswathsIN(3) % inst_localtimes => SWATH_LOCALTIMES_CSCAL(1:N_SWATHS_CSCAL) - cospswathsIN(3) % inst_localtime_widths => SWATH_WIDTHS_CSCAL(1:N_SWATHS_CSCAL) - cospswathsIN(4) % N_inst_swaths = N_SWATHS_ATLID - cospswathsIN(4) % inst_localtimes => SWATH_LOCALTIMES_ATLID(1:N_SWATHS_ATLID) - cospswathsIN(4) % inst_localtime_widths => SWATH_WIDTHS_ATLID(1:N_SWATHS_ATLID) - cospswathsIN(5) % N_inst_swaths = N_SWATHS_PARASOL - cospswathsIN(5) % inst_localtimes => SWATH_LOCALTIMES_PARASOL(1:N_SWATHS_PARASOL) - cospswathsIN(5) % inst_localtime_widths => SWATH_WIDTHS_PARASOL(1:N_SWATHS_PARASOL) - cospswathsIN(6) % N_inst_swaths = N_SWATHS_MODIS - cospswathsIN(6) % inst_localtimes => SWATH_LOCALTIMES_MODIS(1:N_SWATHS_MODIS) - cospswathsIN(6) % inst_localtime_widths => SWATH_WIDTHS_MODIS(1:N_SWATHS_MODIS) + cospswathsIN(1) % N_inst_swaths = N_SWATHS_ISCCP + cospswathsIN(1) % inst_localtimes(1:N_SWATHS_ISCCP) = SWATH_LOCALTIMES_ISCCP(1:N_SWATHS_ISCCP) + cospswathsIN(1) % inst_localtime_widths(1:N_SWATHS_ISCCP) = SWATH_WIDTHS_ISCCP(1:N_SWATHS_ISCCP) + cospswathsIN(2) % N_inst_swaths = N_SWATHS_MISR + cospswathsIN(2) % inst_localtimes(1:N_SWATHS_MISR) = SWATH_LOCALTIMES_MISR(1:N_SWATHS_MISR) + cospswathsIN(2) % inst_localtime_widths(1:N_SWATHS_MISR) = SWATH_WIDTHS_MISR(1:N_SWATHS_MISR) + cospswathsIN(3) % N_inst_swaths = N_SWATHS_CSCAL + cospswathsIN(3) % inst_localtimes(1:N_SWATHS_CSCAL) = SWATH_LOCALTIMES_CSCAL(1:N_SWATHS_CSCAL) + cospswathsIN(3) % inst_localtime_widths(1:N_SWATHS_CSCAL) = SWATH_WIDTHS_CSCAL(1:N_SWATHS_CSCAL) + cospswathsIN(4) % N_inst_swaths = N_SWATHS_ATLID + cospswathsIN(4) % inst_localtimes(1:N_SWATHS_ATLID) = SWATH_LOCALTIMES_ATLID(1:N_SWATHS_ATLID) + cospswathsIN(4) % inst_localtime_widths(1:N_SWATHS_ATLID) = SWATH_WIDTHS_ATLID(1:N_SWATHS_ATLID) + cospswathsIN(5) % N_inst_swaths = N_SWATHS_PARASOL + cospswathsIN(5) % inst_localtimes(1:N_SWATHS_PARASOL) = SWATH_LOCALTIMES_PARASOL(1:N_SWATHS_PARASOL) + cospswathsIN(5) % inst_localtime_widths(1:N_SWATHS_PARASOL) = SWATH_WIDTHS_PARASOL(1:N_SWATHS_PARASOL) + cospswathsIN(6) % N_inst_swaths = N_SWATHS_MODIS + cospswathsIN(6) % inst_localtimes(1:N_SWATHS_MODIS) = SWATH_LOCALTIMES_MODIS(1:N_SWATHS_MODIS) + cospswathsIN(6) % inst_localtime_widths(1:N_SWATHS_MODIS) = SWATH_WIDTHS_MODIS(1:N_SWATHS_MODIS) !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Read in sample input data. @@ -749,14 +746,9 @@ program cosp2_test if (rttov_verbose) print*,'Calling "destroy_cospIN".' call destroy_cospIN(cospIN) if (rttov_verbose) print*,'Calling "destroy_cospstateIN".' - call destroy_cospstateIN(cospstateIN) + call destroy_cospstateIN(cospstateIN) if (rttov_verbose) print*,'Calling "cosp_cleanUp".' call cosp_cleanUp() - ! Clean swathing DDT - do ij=1,7 - if (associated(cospswathsIN(ij) % inst_localtimes)) nullify(cospswathsIN(ij) % inst_localtimes) - if (associated(cospswathsIN(ij) % inst_localtime_widths)) nullify(cospswathsIN(ij) % inst_localtime_widths) - end do if (rttov_verbose) print*,'all done.' contains diff --git a/src/cosp.F90 b/src/cosp.F90 index 524958925f..59b3ac6abe 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -140,7 +140,7 @@ MODULE MOD_COSP integer :: & N_inst_swaths = 0 - real(wp),dimension(:),pointer :: & + real(wp),dimension(20) :: & inst_localtimes, & inst_localtime_widths @@ -195,7 +195,7 @@ MODULE MOD_COSP rcfg_cloudsat ! Radar configuration information (CLOUDSAT) type(rttov_cfg),dimension(:),pointer :: & cfg_rttov ! RTTOV configuration information (multiple instruments) - type(swath_inputs),dimension(7) :: & ! Could be a pointer but fine + type(swath_inputs),dimension(6) :: & ! Could be a pointer but fine cospswathsIN end type cosp_optical_inputs @@ -1642,7 +1642,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Call simulator if (cospIN % cospswathsIN(2) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays if (verbose) print*,'MISR' - if (isccpIN%Npoints .gt. 0) then + if (misrIN%Npoints .gt. 0) then ! Operate at the masked format. allocate(temp_misr_cldarea(misrIN%Npoints), & temp_misr_meanztop(misrIN%Npoints), & @@ -2969,7 +2969,7 @@ subroutine compute_orbitmasks(Npoints,Nlocaltimes,localtimes,localtime_widths, swath_mask_all ! Mask of logicals over all local times, gridcells ! Iterate over local times - swath_mask_all(:,:) = 0 + swath_mask_all(:,:) = .false. do i=1,Nlocaltimes ! Calculate the central longitude for each gridcell and orbit sat_lon(:,i) = 15.0 * (localtimes(i) - (hour + minute / 60)) @@ -2984,9 +2984,9 @@ subroutine compute_orbitmasks(Npoints,Nlocaltimes,localtimes,localtime_widths, end do ! Mask is true where values should be calculated - swath_mask_out = ALL( swath_mask_all(:,:),2) ! Compute mask by collapsing the localtimes dimension ! ANY(swath_mask_all,dim=1) + swath_mask_out = ANY( swath_mask_all(:,:),2) ! Compute mask by collapsing the localtimes dimension + Nswathed_out = count(swath_mask_out) ! Number of gridcells that should be calculated. - Nswathed_out = count(swath_mask_out) ! Mask is true where values should be masked to R_UNDEF ! swath_mask_out = ALL( swath_mask_all(:,:) .eq. .false.,2) ! Compute mask by collapsing the localtimes dimension ! ANY(swath_mask_all,dim=1) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index f19f5d0930..31bb8e5b7f 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -297,9 +297,9 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & channel_filepath,rttov_srcDir,rttov_coefDir, & OD_coef_filepath,aer_coef_filepath,cld_coef_filepath, & PC_coef_filepath, & - CO2_data,CH4_data,CO_data,N2O_data,SO2_data,ozone_data, & ! User-supplied trace gas concentrations + CO2_data,CH4_data,CO_data,N2O_data,SO2_data,ozone_data, & ! Use trace gases for radiative transfer? clw_data, & ! MW option - user_tracegas_input, & + user_tracegas_input, & ! User-supplied trace gas concentrations CO2_mr,CH4_mr,CO_mr,N2O_mr,SO2_mr, & ! Mixing ratios ipcbnd,ipcreg,npcscores, & ! PC-RTTOV config values rttov_nthreads,rttov_ZenAng,rttov_Nlocaltime, & @@ -758,96 +758,100 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig, calcemis, & emissivity, & calcrefl, & - reflectance) - ! Could shortcut out if all values are swathed out -! if (rttovConfig % nprof .eq. 0) then print*,'swathed chunk' - - call cpu_time(driver_time(2)) - !if (verbose) print*,'Beginning "cosp_rttov_construct_profiles".' - call cosp_rttov_construct_profiles(rttovIN, & - profiles, & - rttovConfig % Lrttov_cld, & - rttovConfig % Lrttov_aer, & - rttovConfig % Lrttov_solar, & - rttovConfig % user_tracegas_input, & - rttovConfig % opts % rt_all % CO2_data, & - rttovConfig % opts % rt_all % CH4_data, & - rttovConfig % opts % rt_all % CO_data, & - rttovConfig % opts % rt_all % N2O_data, & - rttovConfig % opts % rt_all % SO2_data, & - rttovConfig % opts % rt_all % ozone_data, & - rttovConfig % CO2_mr, & - rttovConfig % CH4_mr, & - rttovConfig % CO_mr, & - rttovConfig % N2O_mr, & - rttovConfig % SO2_mr, & - rttovConfig % ZenAng, & - rttovConfig % nprof, & - rttovConfig % swath_mask, & - verbose) - - call cpu_time(driver_time(3)) + reflectance, & + verbose) + + if (rttovConfig % nprof .gt. 0) then ! Skip calculations if all values are swathed out - !if (verbose) print*,'Beginning "cosp_rttov_setup_emissivity_reflectance".' - if (associated(rttovIN % emis_grey)) then - call cosp_rttov_setup_emissivity_reflectance(calcemis, & - emissivity, & - calcrefl, & - reflectance, & - emis_grey = rttovIN % emis_grey) ! Config agnostic after allocate step. + call cpu_time(driver_time(2)) + !if (verbose) print*,'Beginning "cosp_rttov_construct_profiles".' + call cosp_rttov_construct_profiles(rttovIN, & + profiles, & + rttovConfig % Lrttov_cld, & + rttovConfig % Lrttov_aer, & + rttovConfig % Lrttov_solar, & + rttovConfig % user_tracegas_input, & + rttovConfig % opts % rt_all % CO2_data, & + rttovConfig % opts % rt_all % CH4_data, & + rttovConfig % opts % rt_all % CO_data, & + rttovConfig % opts % rt_all % N2O_data, & + rttovConfig % opts % rt_all % SO2_data, & + rttovConfig % opts % rt_all % ozone_data, & + rttovConfig % CO2_mr, & + rttovConfig % CH4_mr, & + rttovConfig % CO_mr, & + rttovConfig % N2O_mr, & + rttovConfig % SO2_mr, & + rttovConfig % ZenAng, & + rttovConfig % nprof, & + rttovConfig % swath_mask, & + verbose) + + call cpu_time(driver_time(3)) + + !if (verbose) print*,'Beginning "cosp_rttov_setup_emissivity_reflectance".' + if (associated(rttovIN % emis_grey)) then + call cosp_rttov_setup_emissivity_reflectance(calcemis, & + emissivity, & + calcrefl, & + reflectance, & + emis_grey = rttovIN % emis_grey) ! Config agnostic after allocate step. + else + call cosp_rttov_setup_emissivity_reflectance(calcemis, & + emissivity, & + calcrefl, & + reflectance) + end if + call cpu_time(driver_time(4)) + + !if (verbose) print*,'Beginning "cosp_rttov_call_direct".' + call cosp_rttov_call_direct(rttovConfig % rttov_direct_nthreads, & + rttovConfig % opts, & + profiles, & + rttovConfig % coefs, & + chanprof, & + transmission, & + radiance, & + calcemis, & + emissivity, & + calcrefl, & + reflectance) + + call cpu_time(driver_time(5)) + + !if (verbose) print*,'Beginning "cosp_rttov_save_output".' + call cosp_rttov_save_output(rttovIN % nPoints, & + rttovConfig % nchan_out, & + rttovConfig % swath_mask, & + rttovConfig % Lrttov_bt, & + rttovConfig % Lrttov_rad, & + rttovConfig % Lrttov_refl, & + rttovConfig % Lrttov_cld, & + rttovConfig % Lrttov_aer, & + radiance, & + bt_total,bt_clear, & + rad_total,rad_clear,rad_cloudy, & + refl_total,refl_clear) + + call cpu_time(driver_time(6)) + !if (verbose) print*,'Beginning "cosp_rttov_deallocate_profiles".' + call cosp_rttov_deallocate_profiles(rttovConfig % nprof, & + rttovConfig % nchanprof, & + rttovIN % nLevels, & + rttovConfig % opts, & + profiles, & + rttovConfig % coefs, & + chanprof, & + transmission, & + radiance, & + calcemis, & + emissivity, & + calcrefl, & + reflectance) + call cpu_time(driver_time(7)) else - call cosp_rttov_setup_emissivity_reflectance(calcemis, & - emissivity, & - calcrefl, & - reflectance) + print*,'empty chunk' end if - call cpu_time(driver_time(4)) - - !if (verbose) print*,'Beginning "cosp_rttov_call_direct".' - call cosp_rttov_call_direct(rttovConfig % rttov_direct_nthreads, & - rttovConfig % opts, & - profiles, & - rttovConfig % coefs, & - chanprof, & - transmission, & - radiance, & - calcemis, & - emissivity, & - calcrefl, & - reflectance) - - call cpu_time(driver_time(5)) - - !if (verbose) print*,'Beginning "cosp_rttov_save_output".' - call cosp_rttov_save_output(rttovIN % nPoints, & - rttovConfig % nchan_out, & - rttovConfig % swath_mask, & - rttovConfig % Lrttov_bt, & - rttovConfig % Lrttov_rad, & - rttovConfig % Lrttov_refl, & - rttovConfig % Lrttov_cld, & - rttovConfig % Lrttov_aer, & - radiance, & - bt_total,bt_clear, & - rad_total,rad_clear,rad_cloudy, & - refl_total,refl_clear) - - call cpu_time(driver_time(6)) - !if (verbose) print*,'Beginning "cosp_rttov_deallocate_profiles".' - call cosp_rttov_deallocate_profiles(rttovConfig % nprof, & - rttovConfig % nchanprof, & - rttovIN % nLevels, & - rttovConfig % opts, & - profiles, & - rttovConfig % coefs, & - chanprof, & - transmission, & - radiance, & - calcemis, & - emissivity, & - calcrefl, & - reflectance) - call cpu_time(driver_time(7)) ! print*,'Time to run "cosp_rttov_allocate": ', driver_time(2)-driver_time(1) ! print*,'Time to run "cosp_rttov_construct_profiles": ', driver_time(3)-driver_time(2) @@ -926,75 +930,79 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig, rttovConfig % pccomp, & predictindex) call cpu_time(driver_time(2)) -! if (verbose) print*,'Beginning "cosp_rttov_construct_profiles".' - call cosp_rttov_construct_profiles(rttovIN, & - profiles, & - rttovConfig % Lrttov_cld, & - rttovConfig % Lrttov_aer, & - rttovConfig % Lrttov_solar, & - rttovConfig % user_tracegas_input, & - rttovConfig % opts % rt_all % CO2_data, & - rttovConfig % opts % rt_all % CH4_data, & - rttovConfig % opts % rt_all % CO_data, & - rttovConfig % opts % rt_all % N2O_data, & - rttovConfig % opts % rt_all % SO2_data, & - rttovConfig % opts % rt_all % ozone_data, & - rttovConfig % CO2_mr, & - rttovConfig % CH4_mr, & - rttovConfig % CO_mr, & - rttovConfig % N2O_mr, & - rttovConfig % SO2_mr, & - rttovConfig % ZenAng, & - rttovConfig % nprof, & - rttovConfig % swath_mask, & - verbose) - call cpu_time(driver_time(3)) - call cosp_pc_rttov_setup_emissivity(calcemis, & - emissivity) - call cpu_time(driver_time(4)) -! if (verbose) print*,'Beginning "cosp_pc_rttov_call_direct".' - call cosp_pc_rttov_call_direct(rttovConfig % rttov_direct_nthreads, & - rttovConfig % opts, & - profiles, & - rttovConfig % coefs, & - chanprof, & - transmission, & - rttovConfig % nchannels_rec, & - rttovConfig % iChannel_out, & - radiance, & - calcemis, & - emissivity, & - rttovConfig % pccomp) - - call cpu_time(driver_time(5)) -! if (verbose) print*,'Beginning "cosp_pc_rttov_save_output".' - call cosp_pc_rttov_save_output(rttovIN % nPoints, & - rttovConfig % nchannels_rec, & - rttovConfig % swath_mask, & - rttovConfig % pccomp, & - rttovConfig % Lrttov_bt, & - rttovConfig % Lrttov_rad, & - bt_clear, & - rad_clear) - - call cpu_time(driver_time(6)) -! if (verbose) print*,'Beginning "cosp_pc_rttov_deallocate_profiles".' - call cosp_pc_rttov_deallocate_profiles(rttovConfig % nprof, & - rttovConfig % nchanprof, & - rttovIN % nlevels, & - rttovConfig % nChannels_rec, & - rttovConfig % opts, & - profiles, & - rttovConfig % coefs, & - chanprof, & - transmission, & - radiance, & - calcemis, & - emissivity, & - rttovConfig % pccomp, & - predictindex) - - call cpu_time(driver_time(7)) + + if (rttovConfig % nprof .gt. 0) then ! Skip calculations if all values are swathed out. + + ! if (verbose) print*,'Beginning "cosp_rttov_construct_profiles".' + call cosp_rttov_construct_profiles(rttovIN, & + profiles, & + rttovConfig % Lrttov_cld, & + rttovConfig % Lrttov_aer, & + rttovConfig % Lrttov_solar, & + rttovConfig % user_tracegas_input, & + rttovConfig % opts % rt_all % CO2_data, & + rttovConfig % opts % rt_all % CH4_data, & + rttovConfig % opts % rt_all % CO_data, & + rttovConfig % opts % rt_all % N2O_data, & + rttovConfig % opts % rt_all % SO2_data, & + rttovConfig % opts % rt_all % ozone_data, & + rttovConfig % CO2_mr, & + rttovConfig % CH4_mr, & + rttovConfig % CO_mr, & + rttovConfig % N2O_mr, & + rttovConfig % SO2_mr, & + rttovConfig % ZenAng, & + rttovConfig % nprof, & + rttovConfig % swath_mask, & + verbose) + call cpu_time(driver_time(3)) + call cosp_pc_rttov_setup_emissivity(calcemis, & + emissivity) + call cpu_time(driver_time(4)) + ! if (verbose) print*,'Beginning "cosp_pc_rttov_call_direct".' + call cosp_pc_rttov_call_direct(rttovConfig % rttov_direct_nthreads, & + rttovConfig % opts, & + profiles, & + rttovConfig % coefs, & + chanprof, & + transmission, & + rttovConfig % nchannels_rec, & + rttovConfig % iChannel_out, & + radiance, & + calcemis, & + emissivity, & + rttovConfig % pccomp) + + call cpu_time(driver_time(5)) + ! if (verbose) print*,'Beginning "cosp_pc_rttov_save_output".' + call cosp_pc_rttov_save_output(rttovIN % nPoints, & + rttovConfig % nchannels_rec, & + rttovConfig % swath_mask, & + rttovConfig % pccomp, & + rttovConfig % Lrttov_bt, & + rttovConfig % Lrttov_rad, & + bt_clear, & + rad_clear) + + call cpu_time(driver_time(6)) + ! if (verbose) print*,'Beginning "cosp_pc_rttov_deallocate_profiles".' + call cosp_pc_rttov_deallocate_profiles(rttovConfig % nprof, & + rttovConfig % nchanprof, & + rttovIN % nlevels, & + rttovConfig % nChannels_rec, & + rttovConfig % opts, & + profiles, & + rttovConfig % coefs, & + chanprof, & + transmission, & + radiance, & + calcemis, & + emissivity, & + rttovConfig % pccomp, & + predictindex) + + call cpu_time(driver_time(7)) + end if ! print*,'Time to run "cosp_pc_rttov_allocate": ', driver_time(2)-driver_time(1) ! print*,'Time to run "cosp_rttov_construct_profiles": ', driver_time(3)-driver_time(2) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 5a755cfd5f..4fd2ec3556 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -234,9 +234,11 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs, real(kind=jprb), dimension(rttovIN % nPoints,rttov_Nlocaltime) :: & sat_lon, & ! Central longitude of the instrument. - swath_mask_all, & ! Mask of reals over all local times dlon, & ! distance to satellite longitude in degrees dx ! distance to satellite longitude in km? + + logical(kind=jplm), dimension(rttovIN % nPoints,rttov_Nlocaltime) :: & + swath_mask_all ! Mask of reals over all local times logical :: verbose = .false. @@ -246,9 +248,10 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs, ! 3. Allocate RTTOV input and output structures ! ------------------------------------------------------ ! Largely from RTTOV documentation. - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Handle swathing here. Initial code from Genevieve with implementation changes. + swath_mask_all = .false. if (rttov_Nlocaltime .gt. 0) then ! Iterate over local times do j=1,rttov_Nlocaltime @@ -258,23 +261,13 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs, dlon(:,j) = mod((rttovIN%longitude - sat_lon(:,j) + 180.0), 360.0) - 180.0 ! calculate distance to satellite in km. Remember to convert to radians for cos/sine calls dx(:,j) = dlon(:,j) * (pi/180.0) * COS(rttovIN%latitude * pi / 180) * radius - end do - - ! inside swath = 1, outside swath = 0 for "swath_mask_all" - swath_mask_all = 0 - do j=1,rttov_Nlocaltime + ! Determine if a gridcell falls in the swath width where (abs(dx(:,j))<(rttov_localtime_width(j)*0.5)) - swath_mask_all(:,j) = 1 - end where + swath_mask_all(:,j) = .true. + end where end do - ! Collapse along the Nlocaltimes dimension and shift to logicals - inst_swath_mask(:) = .false. ! Initialize to false - do j = 1,rttovIN % nPoints - if ( ANY( swath_mask_all(j,:) .eq. 1) ) then - inst_swath_mask(j) = .true. - end if - end do + inst_swath_mask = ANY( swath_mask_all(:,:),2) else inst_swath_mask(:) = .true. ! Compute on all columns in no local times are passed. end if @@ -286,43 +279,49 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs, print*,'inst_nprof: ',inst_nprof print*,'inst_nChannels_rec: ',inst_nChannels_rec print*,'inst_nchanprof: ',inst_nchanprof - end if + end if - ! Allocate structures for rttov_direct - call rttov_alloc_direct( & - errorstatus, & - 1_jpim, & ! 1 => allocate - inst_nprof, & - inst_nchanprof, & - rttovIN%nLevels, & - inst_chanprof, & - inst_opts, & - inst_profiles, & - inst_coefs, & - inst_transmission, & - inst_radiance, & - calcemis=inst_calcemis, & - emissivity=inst_emissivity, & - calcrefl=inst_calcrefl, & - reflectance=inst_reflectance, & - init=.TRUE._jplm) - call rttov_error('allocation error for rttov_direct structures' , lalloc = .false.) + if (inst_nprof .gt. 0_jpim) then ! Only allocate if there are calculations to make + + ! Allocate structures for rttov_direct + call rttov_alloc_direct( & + errorstatus, & + 1_jpim, & ! 1 => allocate + inst_nprof, & + inst_nchanprof, & + rttovIN%nLevels, & + inst_chanprof, & + inst_opts, & + inst_profiles, & + inst_coefs, & + inst_transmission, & + inst_radiance, & + calcemis=inst_calcemis, & + emissivity=inst_emissivity, & + calcrefl=inst_calcrefl, & + reflectance=inst_reflectance, & + init=.TRUE._jplm) + call rttov_error('allocation error for rttov_direct structures' , lalloc = .false.) + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 4. Build the list of profile/channel indices in chanprof + ! ------------------------------------------------------ + ! Largely from RTTOV documentation. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + nch = 0_jpim + do j = 1, inst_nprof + do jch = 1, inst_nChannels_rec ! nChannels + nch = nch + 1_jpim + inst_chanprof(nch)%prof = j + inst_chanprof(nch)%chan = inst_iChannel(jch) ! Example code used channel_list + end do + end do + if (verbose) print*,'Done with "cosp_rttov_allocate"' - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! 4. Build the list of profile/channel indices in chanprof - ! ------------------------------------------------------ - ! Largely from RTTOV documentation. - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - nch = 0_jpim - do j = 1, inst_nprof - do jch = 1, inst_nChannels_rec ! nChannels - nch = nch + 1_jpim - inst_chanprof(nch)%prof = j - inst_chanprof(nch)%chan = inst_iChannel(jch) ! Example code used channel_list - end do - end do - if (verbose) print*,'Done with "cosp_rttov_allocate"' + else + print*,'nothing swathed' + end if end subroutine cosp_rttov_allocate @@ -399,9 +398,11 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, real(kind=jprb), dimension(rttovIN % nPoints,rttov_Nlocaltime) :: & sat_lon, & ! Central longitude of the instrument. - swath_mask_all, & ! Mask of reals over all local times dlon, & ! distance to satellite longitude in degrees dx ! distance to satellite longitude in km? + + logical(kind=jplm), dimension(rttovIN % nPoints,rttov_Nlocaltime) :: & + swath_mask_all ! Mask of reals over all local times logical :: verbose = .false. @@ -415,10 +416,11 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, nullify(inst_predictindex) call rttov_get_pc_predictindex(errorstatus, inst_opts, inst_predictindex, file_pccoef=inst_PC_coef_filepath) - call rttov_error('rttov_get_pc_predictindex fatal error' , lalloc = .false.) + call rttov_error('rttov_get_pc_predictindex fatal error' , lalloc = .false.) - ! Handle swathing here. Initial code from Genevieve with minor changes. - if (rttov_Nlocaltime > 0) then + ! Handle swathing here. Initial code from Genevieve with implementation changes. + swath_mask_all = .false. + if (rttov_Nlocaltime .gt. 0) then ! Iterate over local times do j=1,rttov_Nlocaltime ! Calculate the central longitude for each gridcell and orbit @@ -427,30 +429,19 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, dlon(:,j) = mod((rttovIN%longitude - sat_lon(:,j) + 180.0), 360.0) - 180.0 ! calculate distance to satellite in km. Remember to convert to radians for cos/sine calls dx(:,j) = dlon(:,j) * (pi/180.0) * COS(rttovIN%latitude * pi / 180) * radius - end do - - ! inside swath = 1, outside swath = 0 for "swath_mask_all" - swath_mask_all = 0 - do j=1,rttov_Nlocaltime + ! Determine if a gridcell falls in the swath width where (abs(dx(:,j))<(rttov_localtime_width(j)*0.5)) - swath_mask_all(:,j) = 1 - end where + swath_mask_all(:,j) = .true. + end where end do - ! Collapse along the Nlocaltimes dimension and shift to logicals - inst_swath_mask(:) = .false. ! Initialize to false - do j = 1,rttovIN % nPoints - if ( ANY( swath_mask_all(j,:) .eq. 1) ) then - inst_swath_mask(j) = .true. - end if - end do - ! Determine the total number of radiances to simulate (nchanprof). + inst_swath_mask = ANY( swath_mask_all(:,:),2) else inst_swath_mask(:) = .true. ! Compute on all columns in no local times are passed. - end if + end if + ! Determine the total number of radiances to simulate (nchanprof). inst_nprof = count(inst_swath_mask) - inst_npred_pc = SIZE(inst_predictindex) inst_nchanprof = inst_npred_pc * inst_nprof ! Size of chanprof array is total number of predictors over all profiles From 3c7d9be798d93f1de9d3517ed45490e071bb5fba Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Thu, 21 Mar 2024 15:31:16 -0600 Subject: [PATCH 112/159] Small updates --- src/simulator/cosp_rttov_interface_v13.F90 | 2 +- src/simulator/rttov/cosp_rttov_v13.F90 | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 31bb8e5b7f..390cdb1723 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -850,7 +850,7 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig, reflectance) call cpu_time(driver_time(7)) else - print*,'empty chunk' + if (verbose) print*,'empty chunk' end if ! print*,'Time to run "cosp_rttov_allocate": ', driver_time(2)-driver_time(1) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 4fd2ec3556..45550e2c14 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -238,7 +238,7 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs, dx ! distance to satellite longitude in km? logical(kind=jplm), dimension(rttovIN % nPoints,rttov_Nlocaltime) :: & - swath_mask_all ! Mask of reals over all local times + swath_mask_all ! Mask of logicals over all local times logical :: verbose = .false. @@ -320,7 +320,7 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs, if (verbose) print*,'Done with "cosp_rttov_allocate"' else - print*,'nothing swathed' + if (verbose) print*,'nothing swathed' end if end subroutine cosp_rttov_allocate @@ -402,7 +402,7 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, dx ! distance to satellite longitude in km? logical(kind=jplm), dimension(rttovIN % nPoints,rttov_Nlocaltime) :: & - swath_mask_all ! Mask of reals over all local times + swath_mask_all ! Mask of logicals over all local times logical :: verbose = .false. From 25a085b0465851931aad9555897e94f4c42f6c7d Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Fri, 22 Mar 2024 15:21:01 -0600 Subject: [PATCH 113/159] Remove memory leak. Reorganize swathing. --- driver/src/cosp2_test.F90 | 5 +- src/simulator/cosp_rttov_interface_v13.F90 | 391 ++++++++++----------- src/simulator/rttov/cosp_rttov_v13.F90 | 232 ++++++------ 3 files changed, 303 insertions(+), 325 deletions(-) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index c06ba9a756..2d8d66f44a 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -1220,10 +1220,6 @@ subroutine construct_cospIN(npoints,ncolumns,nlevels,ninst_rttov,y,emis_grey) y%ss_alb(npoints, ncolumns,nlevels)) endif - if (Lrttov) then - allocate(y%cfg_rttov(ninst_rttov)) - ! JKS allocate localtime - endif end subroutine construct_cospIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1662,6 +1658,7 @@ subroutine destroy_cospIN(y) if (allocated(y%tau_mol_atlid)) deallocate(y%tau_mol_atlid) if (allocated(y%tautot_atlid)) deallocate(y%tautot_atlid) if (allocated(y%fracPrecipIce)) deallocate(y%fracPrecipIce) + if (associated(y%cfg_rttov)) nullify(y%cfg_rttov) end subroutine destroy_cospIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 390cdb1723..cb3ed2562b 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -654,6 +654,8 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,error, refl_total,refl_clear, & ! Reflectance Outputs debug) + use mod_cosp_rttov, only: cosp_rttov_swath + type(rttov_in),intent(in) :: & rttovIN type(rttov_cfg),intent(inout) :: & @@ -674,17 +676,32 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,error, logical :: verbose = .false. if (present(debug)) verbose = debug - ! Check options to determine if the principal component approach should be run - if (rttovConfig % opts % rt_ir % pc % addpc) then - call COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig, & - bt_clear,rad_clear, & - error,verbose) + if (allocated(rttovConfig % swath_mask)) deallocate(rttovConfig % swath_mask) + allocate(rttovConfig % swath_mask(rttovIN % nPoints)) + + call cosp_rttov_swath(rttovIN, & + rttovConfig % rttov_Nlocaltime, & + rttovConfig % rttov_localtime, & + rttovConfig % rttov_localtime_width, & + rttovConfig % swath_mask, & + debug) + rttovConfig % nprof = count(rttovConfig % swath_mask) + + if (rttovConfig % nprof .gt. 0) then ! Skip calculations if all values are swathed out + ! Check options to determine if the principal component approach should be run + if (rttovConfig % opts % rt_ir % pc % addpc) then + call COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig, & + bt_clear,rad_clear, & + error,verbose) + else + call COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig, & + bt_total,bt_clear, & + rad_total,rad_clear,rad_cloudy, & + refl_total,refl_clear, & + error,verbose) + endif else - call COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig, & - bt_total,bt_clear, & - rad_total,rad_clear,rad_cloudy, & - refl_total,refl_clear, & - error,verbose) + if (verbose) print*,'empty chunk' endif END SUBROUTINE COSP_RTTOV_SIMULATE @@ -737,121 +754,111 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig, ! Run each step for running RTTOV from mod_cosp_rttov (and time them) call cpu_time(driver_time(1)) - if (allocated(rttovConfig % swath_mask)) deallocate(rttovConfig % swath_mask) - allocate(rttovConfig % swath_mask(rttovIN % nPoints)) !if (verbose) print*,'Beginning "cosp_rttov_allocate".' call cosp_rttov_allocate(rttovIN, & - rttovConfig % nChannels_rec, & - rttovConfig % opts, & - rttovConfig % coefs, & - profiles, & - rttovConfig % iChannel, & - rttovConfig % rttov_Nlocaltime, & - rttovConfig % rttov_localtime, & - rttovConfig % rttov_localtime_width, & - chanprof, & - rttovConfig % nchanprof, & - rttovConfig % nprof, & - rttovConfig % swath_mask, & - transmission, & - radiance, & - calcemis, & - emissivity, & - calcrefl, & - reflectance, & - verbose) + rttovConfig % nChannels_rec, & + rttovConfig % opts, & + rttovConfig % coefs, & + profiles, & + rttovConfig % iChannel, & + chanprof, & + rttovConfig % nchanprof, & + rttovConfig % nprof, & + rttovConfig % swath_mask, & + transmission, & + radiance, & + calcemis, & + emissivity, & + calcrefl, & + reflectance, & + verbose) - if (rttovConfig % nprof .gt. 0) then ! Skip calculations if all values are swathed out - - call cpu_time(driver_time(2)) - !if (verbose) print*,'Beginning "cosp_rttov_construct_profiles".' - call cosp_rttov_construct_profiles(rttovIN, & - profiles, & - rttovConfig % Lrttov_cld, & - rttovConfig % Lrttov_aer, & - rttovConfig % Lrttov_solar, & - rttovConfig % user_tracegas_input, & - rttovConfig % opts % rt_all % CO2_data, & - rttovConfig % opts % rt_all % CH4_data, & - rttovConfig % opts % rt_all % CO_data, & - rttovConfig % opts % rt_all % N2O_data, & - rttovConfig % opts % rt_all % SO2_data, & - rttovConfig % opts % rt_all % ozone_data, & - rttovConfig % CO2_mr, & - rttovConfig % CH4_mr, & - rttovConfig % CO_mr, & - rttovConfig % N2O_mr, & - rttovConfig % SO2_mr, & - rttovConfig % ZenAng, & - rttovConfig % nprof, & - rttovConfig % swath_mask, & - verbose) - - call cpu_time(driver_time(3)) - - !if (verbose) print*,'Beginning "cosp_rttov_setup_emissivity_reflectance".' - if (associated(rttovIN % emis_grey)) then - call cosp_rttov_setup_emissivity_reflectance(calcemis, & - emissivity, & - calcrefl, & - reflectance, & - emis_grey = rttovIN % emis_grey) ! Config agnostic after allocate step. - else - call cosp_rttov_setup_emissivity_reflectance(calcemis, & - emissivity, & - calcrefl, & - reflectance) - end if - call cpu_time(driver_time(4)) - - !if (verbose) print*,'Beginning "cosp_rttov_call_direct".' - call cosp_rttov_call_direct(rttovConfig % rttov_direct_nthreads, & - rttovConfig % opts, & - profiles, & - rttovConfig % coefs, & - chanprof, & - transmission, & - radiance, & - calcemis, & - emissivity, & - calcrefl, & - reflectance) - - call cpu_time(driver_time(5)) - - !if (verbose) print*,'Beginning "cosp_rttov_save_output".' - call cosp_rttov_save_output(rttovIN % nPoints, & - rttovConfig % nchan_out, & - rttovConfig % swath_mask, & - rttovConfig % Lrttov_bt, & - rttovConfig % Lrttov_rad, & - rttovConfig % Lrttov_refl, & + call cpu_time(driver_time(2)) + !if (verbose) print*,'Beginning "cosp_rttov_construct_profiles".' + call cosp_rttov_construct_profiles(rttovIN, & + profiles, & rttovConfig % Lrttov_cld, & rttovConfig % Lrttov_aer, & - radiance, & - bt_total,bt_clear, & - rad_total,rad_clear,rad_cloudy, & - refl_total,refl_clear) - - call cpu_time(driver_time(6)) - !if (verbose) print*,'Beginning "cosp_rttov_deallocate_profiles".' - call cosp_rttov_deallocate_profiles(rttovConfig % nprof, & - rttovConfig % nchanprof, & - rttovIN % nLevels, & - rttovConfig % opts, & - profiles, & - rttovConfig % coefs, & - chanprof, & - transmission, & - radiance, & - calcemis, & - emissivity, & - calcrefl, & - reflectance) - call cpu_time(driver_time(7)) + rttovConfig % Lrttov_solar, & + rttovConfig % user_tracegas_input, & + rttovConfig % opts % rt_all % CO2_data, & + rttovConfig % opts % rt_all % CH4_data, & + rttovConfig % opts % rt_all % CO_data, & + rttovConfig % opts % rt_all % N2O_data, & + rttovConfig % opts % rt_all % SO2_data, & + rttovConfig % opts % rt_all % ozone_data, & + rttovConfig % CO2_mr, & + rttovConfig % CH4_mr, & + rttovConfig % CO_mr, & + rttovConfig % N2O_mr, & + rttovConfig % SO2_mr, & + rttovConfig % ZenAng, & + rttovConfig % nprof, & + rttovConfig % swath_mask, & + verbose) + + call cpu_time(driver_time(3)) + + !if (verbose) print*,'Beginning "cosp_rttov_setup_emissivity_reflectance".' + if (associated(rttovIN % emis_grey)) then + call cosp_rttov_setup_emissivity_reflectance(calcemis, & + emissivity, & + calcrefl, & + reflectance, & + emis_grey = rttovIN % emis_grey) ! Config agnostic after allocate step. else - if (verbose) print*,'empty chunk' + call cosp_rttov_setup_emissivity_reflectance(calcemis, & + emissivity, & + calcrefl, & + reflectance) end if + call cpu_time(driver_time(4)) + + !if (verbose) print*,'Beginning "cosp_rttov_call_direct".' + call cosp_rttov_call_direct(rttovConfig % rttov_direct_nthreads, & + rttovConfig % opts, & + profiles, & + rttovConfig % coefs, & + chanprof, & + transmission, & + radiance, & + calcemis, & + emissivity, & + calcrefl, & + reflectance) + + call cpu_time(driver_time(5)) + + !if (verbose) print*,'Beginning "cosp_rttov_save_output".' + call cosp_rttov_save_output(rttovIN % nPoints, & + rttovConfig % nchan_out, & + rttovConfig % swath_mask, & + rttovConfig % Lrttov_bt, & + rttovConfig % Lrttov_rad, & + rttovConfig % Lrttov_refl, & + rttovConfig % Lrttov_cld, & + rttovConfig % Lrttov_aer, & + radiance, & + bt_total,bt_clear, & + rad_total,rad_clear,rad_cloudy, & + refl_total,refl_clear) + + call cpu_time(driver_time(6)) + !if (verbose) print*,'Beginning "cosp_rttov_deallocate_profiles".' + call cosp_rttov_deallocate_profiles(rttovConfig % nprof, & + rttovConfig % nchanprof, & + rttovIN % nLevels, & + rttovConfig % opts, & + profiles, & + rttovConfig % coefs, & + chanprof, & + transmission, & + radiance, & + calcemis, & + emissivity, & + calcrefl, & + reflectance) + call cpu_time(driver_time(7)) ! print*,'Time to run "cosp_rttov_allocate": ', driver_time(2)-driver_time(1) ! print*,'Time to run "cosp_rttov_construct_profiles": ', driver_time(3)-driver_time(2) @@ -905,9 +912,7 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig, ! Run each step for running RTTOV from mod_cosp_rttov (and time them) call cpu_time(driver_time(1)) - if (allocated(rttovConfig % swath_mask)) deallocate(rttovConfig % swath_mask) - allocate(rttovConfig % swath_mask(rttovIN % nPoints)) -! if (verbose) print*,'Beginning "cosp_pc_rttov_allocate".' + ! if (verbose) print*,'Beginning "cosp_pc_rttov_allocate".' call cosp_pc_rttov_allocate(rttovIN, & rttovConfig % PC_coef_filepath, & rttovConfig % coefs, & @@ -915,9 +920,6 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig, profiles, & rttovConfig % nchannels_rec, & rttovConfig % iChannel, & - rttovConfig % rttov_Nlocaltime, & - rttovConfig % rttov_localtime, & - rttovConfig % rttov_localtime_width, & chanprof, & rttovConfig % nchanprof, & rttovConfig % nprof, & @@ -931,78 +933,75 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig, predictindex) call cpu_time(driver_time(2)) - if (rttovConfig % nprof .gt. 0) then ! Skip calculations if all values are swathed out. - - ! if (verbose) print*,'Beginning "cosp_rttov_construct_profiles".' - call cosp_rttov_construct_profiles(rttovIN, & - profiles, & - rttovConfig % Lrttov_cld, & - rttovConfig % Lrttov_aer, & - rttovConfig % Lrttov_solar, & - rttovConfig % user_tracegas_input, & - rttovConfig % opts % rt_all % CO2_data, & - rttovConfig % opts % rt_all % CH4_data, & - rttovConfig % opts % rt_all % CO_data, & - rttovConfig % opts % rt_all % N2O_data, & - rttovConfig % opts % rt_all % SO2_data, & - rttovConfig % opts % rt_all % ozone_data, & - rttovConfig % CO2_mr, & - rttovConfig % CH4_mr, & - rttovConfig % CO_mr, & - rttovConfig % N2O_mr, & - rttovConfig % SO2_mr, & - rttovConfig % ZenAng, & - rttovConfig % nprof, & - rttovConfig % swath_mask, & - verbose) - call cpu_time(driver_time(3)) - call cosp_pc_rttov_setup_emissivity(calcemis, & - emissivity) - call cpu_time(driver_time(4)) - ! if (verbose) print*,'Beginning "cosp_pc_rttov_call_direct".' - call cosp_pc_rttov_call_direct(rttovConfig % rttov_direct_nthreads, & - rttovConfig % opts, & - profiles, & - rttovConfig % coefs, & - chanprof, & - transmission, & - rttovConfig % nchannels_rec, & - rttovConfig % iChannel_out, & - radiance, & - calcemis, & - emissivity, & - rttovConfig % pccomp) - - call cpu_time(driver_time(5)) - ! if (verbose) print*,'Beginning "cosp_pc_rttov_save_output".' - call cosp_pc_rttov_save_output(rttovIN % nPoints, & - rttovConfig % nchannels_rec, & - rttovConfig % swath_mask, & - rttovConfig % pccomp, & - rttovConfig % Lrttov_bt, & - rttovConfig % Lrttov_rad, & - bt_clear, & - rad_clear) - - call cpu_time(driver_time(6)) - ! if (verbose) print*,'Beginning "cosp_pc_rttov_deallocate_profiles".' - call cosp_pc_rttov_deallocate_profiles(rttovConfig % nprof, & - rttovConfig % nchanprof, & - rttovIN % nlevels, & - rttovConfig % nChannels_rec, & - rttovConfig % opts, & - profiles, & - rttovConfig % coefs, & - chanprof, & - transmission, & - radiance, & - calcemis, & - emissivity, & - rttovConfig % pccomp, & - predictindex) - - call cpu_time(driver_time(7)) - end if +! if (verbose) print*,'Beginning "cosp_rttov_construct_profiles".' + call cosp_rttov_construct_profiles(rttovIN, & + profiles, & + rttovConfig % Lrttov_cld, & + rttovConfig % Lrttov_aer, & + rttovConfig % Lrttov_solar, & + rttovConfig % user_tracegas_input, & + rttovConfig % opts % rt_all % CO2_data, & + rttovConfig % opts % rt_all % CH4_data, & + rttovConfig % opts % rt_all % CO_data, & + rttovConfig % opts % rt_all % N2O_data, & + rttovConfig % opts % rt_all % SO2_data, & + rttovConfig % opts % rt_all % ozone_data, & + rttovConfig % CO2_mr, & + rttovConfig % CH4_mr, & + rttovConfig % CO_mr, & + rttovConfig % N2O_mr, & + rttovConfig % SO2_mr, & + rttovConfig % ZenAng, & + rttovConfig % nprof, & + rttovConfig % swath_mask, & + verbose) + call cpu_time(driver_time(3)) + call cosp_pc_rttov_setup_emissivity(calcemis, & + emissivity) + call cpu_time(driver_time(4)) +! if (verbose) print*,'Beginning "cosp_pc_rttov_call_direct".' + call cosp_pc_rttov_call_direct(rttovConfig % rttov_direct_nthreads, & + rttovConfig % opts, & + profiles, & + rttovConfig % coefs, & + chanprof, & + transmission, & + rttovConfig % nchannels_rec, & + rttovConfig % iChannel_out, & + radiance, & + calcemis, & + emissivity, & + rttovConfig % pccomp) + + call cpu_time(driver_time(5)) +! if (verbose) print*,'Beginning "cosp_pc_rttov_save_output".' + call cosp_pc_rttov_save_output(rttovIN % nPoints, & + rttovConfig % nchannels_rec, & + rttovConfig % swath_mask, & + rttovConfig % pccomp, & + rttovConfig % Lrttov_bt, & + rttovConfig % Lrttov_rad, & + bt_clear, & + rad_clear) + + call cpu_time(driver_time(6)) +! if (verbose) print*,'Beginning "cosp_pc_rttov_deallocate_profiles".' + call cosp_pc_rttov_deallocate_profiles(rttovConfig % nprof, & + rttovConfig % nchanprof, & + rttovIN % nlevels, & + rttovConfig % nChannels_rec, & + rttovConfig % opts, & + profiles, & + rttovConfig % coefs, & + chanprof, & + transmission, & + radiance, & + calcemis, & + emissivity, & + rttovConfig % pccomp, & + predictindex) + + call cpu_time(driver_time(7)) ! print*,'Time to run "cosp_pc_rttov_allocate": ', driver_time(2)-driver_time(1) ! print*,'Time to run "cosp_rttov_construct_profiles": ', driver_time(3)-driver_time(2) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 45550e2c14..c007448b76 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -169,6 +169,73 @@ subroutine rttov_error(msg, lalloc) end subroutine rttov_error + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE cosp_rttov_swath - JKS + ! ------------------------------------------------------ + ! Determine which gridcells should be swathed. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + subroutine cosp_rttov_swath(rttovIN,rttov_Nlocaltime, & + rttov_localtime,rttov_localtime_width, & + inst_swath_mask, debug) + + type(rttov_in),intent(in) :: & + rttovIN + integer(KIND=jpim),intent(in) :: & + rttov_Nlocaltime + real(kind=jprb), dimension(rttov_Nlocaltime), intent(in) :: & + rttov_localtime, & + rttov_localtime_width + logical(jplm),dimension(rttovIN % nPoints),intent(inout) :: & + inst_swath_mask + logical,intent(in),optional :: & + debug + + !---- Local variables ----! + ! Loop variables + integer(kind=jpim) :: j, jch, nch + + real(kind=jprb),parameter :: & + pi = 4.D0*DATAN(1.D0), & ! yum + radius = 6371.0 ! Earth's radius in km (mean volumetric) + + real(kind=jprb), dimension(rttovIN % nPoints,rttov_Nlocaltime) :: & + sat_lon, & ! Central longitude of the instrument. + dlon, & ! distance to satellite longitude in degrees + dx ! distance to satellite longitude in km? + + logical(kind=jplm), dimension(rttovIN % nPoints,rttov_Nlocaltime) :: & + swath_mask_all ! Mask of logicals over all local times + + logical :: verbose = .false. + + if (present(debug)) verbose = debug + + ! Handle swathing here. Initial code from Genevieve with implementation changes. + swath_mask_all = .false. + if (rttov_Nlocaltime .gt. 0) then + ! Iterate over local times + do j=1,rttov_Nlocaltime + ! Calculate the central longitude for each gridcell and orbit + sat_lon(:,j) = 15.0 * (rttov_localtime(j) - (rttovIN%rttov_time(:,1) + rttovIN%rttov_time(:,2) / 60)) + ! Calculate distance (in degrees) from each grid cell to the satellite central long + dlon(:,j) = mod((rttovIN%longitude - sat_lon(:,j) + 180.0), 360.0) - 180.0 + ! calculate distance to satellite in km. Remember to convert to radians for cos/sine calls + dx(:,j) = dlon(:,j) * (pi/180.0) * COS(rttovIN%latitude * pi / 180) * radius + ! Determine if a gridcell falls in the swath width + where (abs(dx(:,j))<(rttov_localtime_width(j)*0.5)) + swath_mask_all(:,j) = .true. + end where + end do + + inst_swath_mask = ANY( swath_mask_all(:,:),2) + else + inst_swath_mask(:) = .true. ! Compute on all columns in no local times are passed. + end if + if (verbose) print*,'inst_swath_mask: ',inst_swath_mask + + end subroutine cosp_rttov_swath + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE rttov_allocate - JKS ! ------------------------------------------------------ @@ -177,9 +244,7 @@ end subroutine rttov_error ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs, & - inst_profiles, inst_iChannel,rttov_Nlocaltime, & - rttov_localtime,rttov_localtime_width, & - inst_chanprof, & + inst_profiles, inst_iChannel, inst_chanprof, & inst_nchanprof,inst_nprof,inst_swath_mask, & inst_transmission,inst_radiance,inst_calcemis, & inst_emissivity,inst_calcrefl,inst_reflectance, & @@ -197,15 +262,11 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs, inst_profiles(:) integer(kind=jpim),dimension(inst_nChannels_rec),intent(in) :: & inst_iChannel - integer(KIND=jpim),intent(in) :: & - rttov_Nlocaltime - real(kind=jprb), dimension(rttov_Nlocaltime), intent(in) :: & - rttov_localtime, & - rttov_localtime_width type(rttov_chanprof),pointer,intent(inout) :: & inst_chanprof(:) integer(kind=jpim),intent(inout) :: & - inst_nchanprof, & + inst_nchanprof + integer(kind=jpim),intent(in) :: & inst_nprof ! Now accounting for orbits logical(jplm),dimension(rttovIN % nPoints),intent(inout) :: & inst_swath_mask @@ -228,17 +289,6 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs, ! Loop variables integer(kind=jpim) :: j, jch, nch - real(kind=jprb),parameter :: & - pi = 4.D0*DATAN(1.D0), & ! yum - radius = 6371.0 ! Earth's radius in km (mean volumetric) - - real(kind=jprb), dimension(rttovIN % nPoints,rttov_Nlocaltime) :: & - sat_lon, & ! Central longitude of the instrument. - dlon, & ! distance to satellite longitude in degrees - dx ! distance to satellite longitude in km? - - logical(kind=jplm), dimension(rttovIN % nPoints,rttov_Nlocaltime) :: & - swath_mask_all ! Mask of logicals over all local times logical :: verbose = .false. @@ -250,29 +300,7 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs, ! Largely from RTTOV documentation. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Handle swathing here. Initial code from Genevieve with implementation changes. - swath_mask_all = .false. - if (rttov_Nlocaltime .gt. 0) then - ! Iterate over local times - do j=1,rttov_Nlocaltime - ! Calculate the central longitude for each gridcell and orbit - sat_lon(:,j) = 15.0 * (rttov_localtime(j) - (rttovIN%rttov_time(:,1) + rttovIN%rttov_time(:,2) / 60)) - ! Calculate distance (in degrees) from each grid cell to the satellite central long - dlon(:,j) = mod((rttovIN%longitude - sat_lon(:,j) + 180.0), 360.0) - 180.0 - ! calculate distance to satellite in km. Remember to convert to radians for cos/sine calls - dx(:,j) = dlon(:,j) * (pi/180.0) * COS(rttovIN%latitude * pi / 180) * radius - ! Determine if a gridcell falls in the swath width - where (abs(dx(:,j))<(rttov_localtime_width(j)*0.5)) - swath_mask_all(:,j) = .true. - end where - end do - - inst_swath_mask = ANY( swath_mask_all(:,:),2) - else - inst_swath_mask(:) = .true. ! Compute on all columns in no local times are passed. - end if ! Determine the total number of radiances to simulate (nchanprof). - inst_nprof = count(inst_swath_mask) inst_nchanprof = inst_nChannels_rec * inst_nprof if (verbose) then @@ -281,47 +309,41 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs, print*,'inst_nchanprof: ',inst_nchanprof end if - if (inst_nprof .gt. 0_jpim) then ! Only allocate if there are calculations to make - - ! Allocate structures for rttov_direct - call rttov_alloc_direct( & - errorstatus, & - 1_jpim, & ! 1 => allocate - inst_nprof, & - inst_nchanprof, & - rttovIN%nLevels, & - inst_chanprof, & - inst_opts, & - inst_profiles, & - inst_coefs, & - inst_transmission, & - inst_radiance, & - calcemis=inst_calcemis, & - emissivity=inst_emissivity, & - calcrefl=inst_calcrefl, & - reflectance=inst_reflectance, & - init=.TRUE._jplm) - call rttov_error('allocation error for rttov_direct structures' , lalloc = .false.) - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! 4. Build the list of profile/channel indices in chanprof - ! ------------------------------------------------------ - ! Largely from RTTOV documentation. - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - nch = 0_jpim - do j = 1, inst_nprof - do jch = 1, inst_nChannels_rec ! nChannels - nch = nch + 1_jpim - inst_chanprof(nch)%prof = j - inst_chanprof(nch)%chan = inst_iChannel(jch) ! Example code used channel_list - end do - end do - if (verbose) print*,'Done with "cosp_rttov_allocate"' + ! Allocate structures for rttov_direct + call rttov_alloc_direct( & + errorstatus, & + 1_jpim, & ! 1 => allocate + inst_nprof, & + inst_nchanprof, & + rttovIN%nLevels, & + inst_chanprof, & + inst_opts, & + inst_profiles, & + inst_coefs, & + inst_transmission, & + inst_radiance, & + calcemis=inst_calcemis, & + emissivity=inst_emissivity, & + calcrefl=inst_calcrefl, & + reflectance=inst_reflectance, & + init=.TRUE._jplm) + call rttov_error('allocation error for rttov_direct structures' , lalloc = .false.) - else - if (verbose) print*,'nothing swathed' - end if + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! 4. Build the list of profile/channel indices in chanprof + ! ------------------------------------------------------ + ! Largely from RTTOV documentation. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + nch = 0_jpim + do j = 1, inst_nprof + do jch = 1, inst_nChannels_rec ! nChannels + nch = nch + 1_jpim + inst_chanprof(nch)%prof = j + inst_chanprof(nch)%chan = inst_iChannel(jch) ! Example code used channel_list + end do + end do + if (verbose) print*,'Done with "cosp_rttov_allocate"' end subroutine cosp_rttov_allocate @@ -334,9 +356,7 @@ end subroutine cosp_rttov_allocate subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, & inst_coefs,inst_opts,inst_profiles, & - inst_nchannels_rec,inst_iChannel_in, & - rttov_Nlocaltime,rttov_localtime,rttov_localtime_width, & - inst_chanprof, & + inst_nchannels_rec,inst_iChannel_in,inst_chanprof, & inst_nchanprof,inst_nprof,inst_iChannel_out, & inst_swath_mask,inst_transmission,inst_radiance, & inst_calcemis,inst_emissivity,inst_pccomp, & @@ -356,15 +376,11 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, inst_nchannels_rec integer(kind=jpim),intent(in),dimension(inst_nchannels_rec) :: & inst_iChannel_in ! Channel indices the user initially requests. - integer(KIND=jpim),intent(in) :: & - rttov_Nlocaltime - real(kind=jprb), dimension(rttov_Nlocaltime), intent(in) :: & - rttov_localtime, & - rttov_localtime_width type(rttov_chanprof),pointer,intent(inout) :: & inst_chanprof(:) integer(kind=jpim),intent(inout) :: & - inst_nchanprof, & + inst_nchanprof + integer(kind=jpim),intent(in) :: & inst_nprof integer(kind=jpim),intent(inout),allocatable :: & inst_iChannel_out(:) ! Passing out the channel indices @@ -391,18 +407,6 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, ! Local variables integer(kind=jpim) :: inst_npred_pc - - real(kind=jprb),parameter :: & - pi = 4.D0*DATAN(1.D0), & ! yum - radius = 6371.0 ! Earth's radius in km (mean volumetric) - - real(kind=jprb), dimension(rttovIN % nPoints,rttov_Nlocaltime) :: & - sat_lon, & ! Central longitude of the instrument. - dlon, & ! distance to satellite longitude in degrees - dx ! distance to satellite longitude in km? - - logical(kind=jplm), dimension(rttovIN % nPoints,rttov_Nlocaltime) :: & - swath_mask_all ! Mask of logicals over all local times logical :: verbose = .false. @@ -418,30 +422,8 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, call rttov_get_pc_predictindex(errorstatus, inst_opts, inst_predictindex, file_pccoef=inst_PC_coef_filepath) call rttov_error('rttov_get_pc_predictindex fatal error' , lalloc = .false.) - ! Handle swathing here. Initial code from Genevieve with implementation changes. - swath_mask_all = .false. - if (rttov_Nlocaltime .gt. 0) then - ! Iterate over local times - do j=1,rttov_Nlocaltime - ! Calculate the central longitude for each gridcell and orbit - sat_lon(:,j) = 15.0 * (rttov_localtime(j) - (rttovIN%rttov_time(:,1) + rttovIN%rttov_time(:,2) / 60)) - ! Calculate distance (in degrees) from each grid cell to the satellite central long - dlon(:,j) = mod((rttovIN%longitude - sat_lon(:,j) + 180.0), 360.0) - 180.0 - ! calculate distance to satellite in km. Remember to convert to radians for cos/sine calls - dx(:,j) = dlon(:,j) * (pi/180.0) * COS(rttovIN%latitude * pi / 180) * radius - ! Determine if a gridcell falls in the swath width - where (abs(dx(:,j))<(rttov_localtime_width(j)*0.5)) - swath_mask_all(:,j) = .true. - end where - end do - - inst_swath_mask = ANY( swath_mask_all(:,:),2) - else - inst_swath_mask(:) = .true. ! Compute on all columns in no local times are passed. - end if ! Determine the total number of radiances to simulate (nchanprof). - inst_nprof = count(inst_swath_mask) inst_npred_pc = SIZE(inst_predictindex) inst_nchanprof = inst_npred_pc * inst_nprof ! Size of chanprof array is total number of predictors over all profiles From 4523f2beb5ee6da3edef6cf3491f1313448e0b4d Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 23 Apr 2024 13:43:33 -0600 Subject: [PATCH 114/159] Add namelist for IASI simulation (validation again RRTMG-LW) --- driver/run/cosp2_input_iasi_nl.txt | 113 +++++++++++++ driver/run/cosp2_output_iasi_nl.txt | 152 ++++++++++++++++++ .../cosp2_rttov_IASI_CESM2_val.txt | 76 +++++++++ .../cosp2_rttov_IASI_CESM2_val1.txt | 76 +++++++++ .../cosp2_rttov_IASI_CESM2_val2.txt | 76 +++++++++ .../cosp2_rttov_IASI_CESM2_val3.txt | 76 +++++++++ 6 files changed, 569 insertions(+) create mode 100644 driver/run/cosp2_input_iasi_nl.txt create mode 100644 driver/run/cosp2_output_iasi_nl.txt create mode 100644 driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val.txt create mode 100644 driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val1.txt create mode 100644 driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val2.txt create mode 100644 driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val3.txt diff --git a/driver/run/cosp2_input_iasi_nl.txt b/driver/run/cosp2_input_iasi_nl.txt new file mode 100644 index 0000000000..c612af90f3 --- /dev/null +++ b/driver/run/cosp2_input_iasi_nl.txt @@ -0,0 +1,113 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&COSP_INPUT + NPOINTS=153,! Number of gridpoints 153,27840,7081,6912 + NPOINTS_IT=2,! 50,5000, Max number of gridpoints to be processed in one iteration + NCOLUMNS=20, ! Number of subcolumns + NLEVELS=38, ! Number of model levels + USE_VGRID=.true., ! Use fixed vertical grid for outputs? (if .true. then you need to define number of levels with Nlr) + NLVGRID=40, ! Number of levels in statistical outputs (only used if USE_VGRID=.true.) + CSAT_VGRID=.true., ! CloudSat vertical grid? (if .true. then the CloudSat standard grid is used for the outputs. + ! USE_VGRID needs also be .true.) + DINPUT='./', ! Directory where the input files are located. Useful when processing multiple files. + ! Leave blank ('') if you are using the full path in FINPUT. + FINPUT='../data/inputs/UKMO/cosp_input_um.nc', ! List input NetCDF files + FOUTPUT='../data/outputs/UKMO/cosp2_output_um_iasi.nc', + !---------------------------------------------------------------------------------- + !--------------- Inputs related to radar simulations + !---------------------------------------------------------------------------------- + cloudsat_RADAR_FREQ=94.0, ! CloudSat radar frequency (GHz) + SURFACE_RADAR=0, ! surface=1, spaceborne=0 + cloudsat_use_gas_abs=1, ! include gaseous absorption? yes=1,no=0 + cloudsat_do_ray=0, ! calculate/output Rayleigh refl=1, not=0 + cloudsat_k2=-1, ! |K|^2, -1=use frequency dependent default + use_precipitation_fluxes=.true., ! True if precipitation fluxes are input to the algorithm + cloudsat_micro_scheme='MMF_v3_single_moment', !'MMF_v3.5_two_moment' + !---------------------------------------------------------------------------------- + !---------------- Inputs related to lidar simulations + !---------------------------------------------------------------------------------- + lidar_ice_type=0, ! Ice particle shape in lidar calculations (0=ice-spheres ; 1=ice-non-spherical) + OVERLAP=3, ! overlap assumption used by scops: 1=max, 2=rand, 3=max/rand + !---------------------------------------------------------------------------------- + !---------------- Inputs related to ISCCP simulator + !---------------------------------------------------------------------------------- + ISCCP_TOPHEIGHT=1, ! 1 = adjust top height using both a computed + ! infrared brightness temperature and the visible + ! optical depth to adjust cloud top pressure. Note + ! that this calculation is most appropriate to compare + ! to ISCCP data during sunlit hours. + ! 2 = do not adjust top height, that is cloud top + ! pressure is the actual cloud top pressure + ! in the model + ! 3 = adjust top height using only the computed + ! infrared brightness temperature. Note that this + ! calculation is most appropriate to compare to ISCCP + ! IR only algortihm (i.e. you can compare to nighttime + ! ISCCP data with this option) + ISCCP_TOPHEIGHT_DIRECTION=2, ! direction for finding atmosphere pressure level + ! with interpolated temperature equal to the radiance + ! determined cloud-top temperature + ! 1 = find the *lowest* altitude (highest pressure) level + ! with interpolated temperature equal to the radiance + ! determined cloud-top temperature + ! 2 = find the *highest* altitude (lowest pressure) level + ! with interpolated temperature equal to the radiance + ! determined cloud-top temperature. This is the + ! default value since V4.0 of the ISCCP simulator. + ! ONLY APPLICABLE IF top_height EQUALS 1 or 3 + !---------------------------------------------------------------------------------- + !-------------- RTTOV inputs + !---------------------------------------------------------------------------------- + ! Simulating a single Nadir-viewing IASI instrument. + !rttov_Ninstruments=1, + !rttov_instrument_namelists='instrument_nls/cosp2_rttov_IASI_CESM2_val.txt', + ! Simulating three IASI instruments + rttov_Ninstruments=3, + rttov_instrument_namelists='instrument_nls/cosp2_rttov_IASI_CESM2_val1.txt','instrument_nls/cosp2_rttov_IASI_CESM2_val2.txt','instrument_nls/cosp2_rttov_IASI_CESM2_val3.txt', + rttov_verbose=.true. + !---------------------------------------------------------------------------------- + !-------------- Swathing inputs + !---------------------------------------------------------------------------------- + N_SWATHS_ISCCP=0, + SWATH_LOCALTIMES_ISCCP=0,0, + SWATH_WIDTHS_ISCCP=0,0, + N_SWATHS_MISR=0, + SWATH_LOCALTIMES_MISR=0,0, + SWATH_WIDTHS_MISR=0,0, + N_SWATHS_MODIS=0, + SWATH_LOCALTIMES_MODIS=0,0, + SWATH_WIDTHS_MODIS=0,0, + N_SWATHS_CSCAL=0, + SWATH_LOCALTIMES_CSCAL=0,0, + SWATH_WIDTHS_CSCAL=0,0, + N_SWATHS_PARASOL=0, + SWATH_LOCALTIMES_PARASOL=0,0, + SWATH_WIDTHS_PARASOL=0,0, + N_SWATHS_ATLID=0, + SWATH_LOCALTIMES_ATLID=0,0, + SWATH_WIDTHS_ATLID=0,0, +/ diff --git a/driver/run/cosp2_output_iasi_nl.txt b/driver/run/cosp2_output_iasi_nl.txt new file mode 100644 index 0000000000..9726a5c6a7 --- /dev/null +++ b/driver/run/cosp2_output_iasi_nl.txt @@ -0,0 +1,152 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +! Namelist that sets up output-related variables. It controls +! the instrument simulators to run and the list of variables +! to be written to file +&COSP_OUTPUT + !- CloudSat + Lcfaddbze94=.false., + Ldbze94=.false., + !- CALIPSO + Latb532=.false., + LcfadLidarsr532=.false., + Lclcalipso=.false., + Lclhcalipso=.false., + Lcllcalipso=.false., + Lclmcalipso=.false., + Lcltcalipso=.false., + LparasolRefl=.false., + ! CALIPSO phase diagnostics + Lclcalipsoliq=.false., + Lclcalipsoice=.false., + Lclcalipsoun=.false., + Lclcalipsotmp=.false., + Lclcalipsotmpliq=.false., + Lclcalipsotmpice=.false., + Lclcalipsotmpun=.false., + Lclhcalipsoliq=.false., + Lcllcalipsoliq=.false., + Lclmcalipsoliq=.false., + Lcltcalipsoliq=.false., + Lclhcalipsoice=.false., + Lcllcalipsoice=.false., + Lclmcalipsoice=.false., + Lcltcalipsoice=.false., + Lclhcalipsoun=.false., + Lcllcalipsoun=.false., + Lclmcalipsoun=.false., + Lcltcalipsoun=.false., + ! CALIPSO OPAQ diagnostics + Lclopaquecalipso=.false., + Lclthincalipso=.false., + Lclzopaquecalipso=.false., + Lclcalipsoopaque=.false., + Lclcalipsothin=.false., + Lclcalipsozopaque=.false., + Lclcalipsoopacity=.false., + Lclopaquetemp=.false., + Lclthintemp=.false., + Lclzopaquetemp=.false., + Lclopaquemeanz=.false., + Lclthinmeanz=.false., + Lclthinemis=.false., + Lclopaquemeanzse=.false., + Lclthinmeanzse=.false., + Lclzopaquecalipsose=.false., + ! GROUND LIDAR diagnostics + LlidarBetaMol532gr=.false., + LcfadLidarsr532gr=.false., + Latb532gr=.false., + LclgrLidar532=.false., + LclhgrLidar532=.false., + LcllgrLidar532=.false., + LclmgrLidar532=.false., + LcltgrLidar532=.false., + ! ATLID diagnostics + LlidarBetaMol355=.false., + LcfadLidarsr355=.false., + Latb355=.false., + Lclatlid=.false., + Lclhatlid=.false., + Lcllatlid=.false., + Lclmatlid=.false., + Lcltatlid=.false., + !- ISCCP + Lalbisccp=.false., + Lboxptopisccp=.false., + Lboxtauisccp=.false., + Lpctisccp=.false., + Lclisccp=.false., + Ltauisccp=.false., + Lcltisccp=.false., + Lmeantbisccp=.false., + Lmeantbclrisccp=.false., + !- MISR + LclMISR=.false., + !- Use lidar and radar + Lclcalipso2=.false., + Lcltlidarradar=.false., + Lcloudsat_tcc=.false., + Lcloudsat_tcc2=.false., + !- These are provided for debugging or special purposes + Lfracout=.false., + LlidarBetaMol532=.false., + !- MODIS + Lcltmodis=.false., + Lclwmodis=.false., + Lclimodis=.false., + Lclhmodis=.false., + Lclmmodis=.false., + Lcllmodis=.false., + Ltautmodis=.false., + Ltauwmodis=.false., + Ltauimodis=.false., + Ltautlogmodis=.false., + Ltauwlogmodis=.false., + Ltauilogmodis=.false., + Lreffclwmodis=.false., + Lreffclimodis=.false., + Lpctmodis=.false., + Llwpmodis=.false., + Liwpmodis=.false., + Lclmodis=.false., + !- RTTOV + Lrttov_run=.true., ! Run RTTOV? + ! -CLOUDSAT precipitation frequency/occurence diagnostics + Lptradarflag0=.false., + Lptradarflag1=.false., + Lptradarflag2=.false., + Lptradarflag3=.false., + Lptradarflag4=.false., + Lptradarflag5=.false., + Lptradarflag6=.false., + Lptradarflag7=.false., + Lptradarflag8=.false., + Lptradarflag9=.false., + Lradarpia=.false., + !- CloudSat+MODIS joint diagnostics + Lwr_occfreq=.false., + Lcfodd=.false. +/ diff --git a/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val.txt b/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val.txt new file mode 100644 index 0000000000..2c9b2363ee --- /dev/null +++ b/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val.txt @@ -0,0 +1,76 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.false., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.false., + channel_filepath='rttov_channel_input_AIRS.csv' +! channel_filepath='rttov_channel_input_IASI_subset.csv', + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='rttov13pred101L/rtcoef_metop_2_iasi_7gas.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.true., + CO_data=.false., + CO2_data=.true., + CH4_data=.true., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=0.0, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at + rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1550,0, ! Swath width (km) +/ diff --git a/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val1.txt b/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val1.txt new file mode 100644 index 0000000000..4b285206a6 --- /dev/null +++ b/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val1.txt @@ -0,0 +1,76 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.false., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.false., + channel_filepath='rttov_channel_input_AIRS.csv' +! channel_filepath='rttov_channel_input_IASI_subset.csv', + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='rttov13pred101L/rtcoef_metop_2_iasi_7gas.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.true., + CO_data=.false., + CO2_data=.true., + CH4_data=.true., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=13.81, ! Satellite Zenith Angle, was 76.2 + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at + rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1550,0, ! Swath width (km) +/ diff --git a/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val2.txt b/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val2.txt new file mode 100644 index 0000000000..4153d0525a --- /dev/null +++ b/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val2.txt @@ -0,0 +1,76 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.false., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.false., + channel_filepath='rttov_channel_input_AIRS.csv' +! channel_filepath='rttov_channel_input_IASI_subset.csv', + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='rttov13pred101L/rtcoef_metop_2_iasi_7gas.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.true., + CO_data=.false., + CO2_data=.true., + CH4_data=.true., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=41.39, !48.6, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at + rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1550,0, ! Swath width (km) +/ diff --git a/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val3.txt b/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val3.txt new file mode 100644 index 0000000000..3dda4b9fff --- /dev/null +++ b/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val3.txt @@ -0,0 +1,76 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.false., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.false., + channel_filepath='rttov_channel_input_AIRS.csv' +! channel_filepath='rttov_channel_input_IASI_subset.csv', + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='rttov13pred101L/rtcoef_metop_2_iasi_7gas.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.true., + CO_data=.false., + CO2_data=.true., + CH4_data=.true., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=68.82, !64.98, !21.2, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at + rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1550,0, ! Swath width (km) +/ From a1c0ccb1092c033e7ab042a9068b55822b55d506 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 23 Apr 2024 14:41:28 -0600 Subject: [PATCH 115/159] Add true surface pressure field to input handling and RTTOV calls. --- build/Makefile.rttov | 7 +++-- driver/src/cosp2_io.f90 | 10 +++++-- driver/src/cosp2_test.F90 | 15 ++++++++-- src/cosp.F90 | 6 ++-- src/simulator/rttov/cosp_rttov_v13.F90 | 40 ++++++++++++++++++-------- 5 files changed, 56 insertions(+), 22 deletions(-) diff --git a/build/Makefile.rttov b/build/Makefile.rttov index 6bafefd813..7a5a22da2b 100644 --- a/build/Makefile.rttov +++ b/build/Makefile.rttov @@ -38,7 +38,9 @@ #LDFLAGS_ARCH=-fopenmp # Derecho with debug changes (01/23/2024) -RTTOVDIR=/glade/u/home/jonahshaw/w/RTTOV2 +# RTTOVDIR=/glade/u/home/jonahshaw/w/RTTOV2 +# Derecho with HDF +RTTOVDIR=/glade/u/home/jonahshaw/w/RTTOV2/hdf_build FC=ifort FFLAGS= -I$(RTTOVDIR)/mod -I$(RTTOVDIR)/include -fPIC -O3 -fopenmp LDFLAGS_ARCH=-fopenmp @@ -53,8 +55,7 @@ BINDIR=$(RTTOVDIR)/bin #### Do not edit beyond this line #### -# JKS - should this be $(RTTOVDIR)/build/Makefile.local ? -# include ../../build/Makefile.local +# JKS - Include settings used to build RTTOV include $(RTTOVDIR)/build/Makefile.local LIBDIR=$(RTTOVDIR)/lib diff --git a/driver/src/cosp2_io.f90 b/driver/src/cosp2_io.f90 index e9c4039807..9ca8f1cc47 100644 --- a/driver/src/cosp2_io.f90 +++ b/driver/src/cosp2_io.f90 @@ -2136,7 +2136,7 @@ end subroutine write_cosp2_output SUBROUTINE NC_READ_INPUT_FILE(fname,Npnts,Nl,Nhydro,lon,lat,p,ph,z,zh,T,qv,rh,tca,cca, & mr_lsliq,mr_lsice,mr_ccliq,mr_ccice,fl_lsrain,fl_lssnow, & fl_lsgrpl,fl_ccrain,fl_ccsnow,Reff,dtau_s,dtau_c,dem_s, & - dem_c,skt,landmask,mr_ozone,u_wind,v_wind,sunlit, & + dem_c,skt,psfc,landmask,mr_ozone,u_wind,v_wind,sunlit, & emsfc_lw,mode,Nlon,Nlat,surfelev,year,month,day, & hour,minute,seconds) @@ -2148,7 +2148,7 @@ SUBROUTINE NC_READ_INPUT_FILE(fname,Npnts,Nl,Nhydro,lon,lat,p,ph,z,zh,T,qv,rh,tc mr_lsliq,mr_lsice,mr_ccliq,mr_ccice,fl_lsrain,fl_lssnow,fl_lsgrpl, & fl_ccrain,fl_ccsnow,dtau_s,dtau_c,dem_s,dem_c,mr_ozone real(wp),dimension(Npnts,Nl,Nhydro),intent(out) :: Reff - real(wp),dimension(Npnts),intent(out) :: skt,landmask,u_wind,v_wind,sunlit,surfelev, & + real(wp),dimension(Npnts),intent(out) :: skt,psfc,landmask,u_wind,v_wind,sunlit,surfelev, & year,month,day,hour,minute,seconds real(wp),intent(out) :: emsfc_lw integer,intent(out) :: mode,Nlon,Nlat @@ -2460,6 +2460,12 @@ SUBROUTINE NC_READ_INPUT_FILE(fname,Npnts,Nl,Nhydro,lon,lat,p,ph,z,zh,T,qv,rh,tc else call map_ll_to_point(Na,Nb,Npoints,x2=x2,y1=skt) endif + case ('psfc') + if (Lpoint) then + psfc(1:Npoints) = x1(1:Npoints) + else + call map_ll_to_point(Na,Nb,Npoints,x2=x2,y1=psfc) + endif case ('orography') if (Lpoint) then surfelev(1:Npoints) = x1(1:Npoints) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 2d8d66f44a..f4a5241d9d 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -84,6 +84,7 @@ program cosp2_test lon, & ! Longitude (deg) lat, & ! Latitude (deg) skt, & ! Skin temperature (K) + psfc, & ! Surface Pressure (Pa) surfelev, & ! Surface Elevation (m) landmask, & ! Land/sea mask (0/1) u_wind, & ! U-component of wind (m/s) @@ -98,7 +99,7 @@ program cosp2_test seconds ! Second [0,60] real(wp),dimension(:,:),allocatable,target :: & p, & ! Model pressure levels (pa) - ph, & ! Moddel pressure @ half levels (pa) + ph, & ! Model pressure @ half levels (pa) zlev, & ! Model level height (m) zlev_half, & ! Model level height @ half-levels (m) T, & ! Temperature (K) @@ -380,7 +381,7 @@ program cosp2_test fl_lsgrpl(Npoints,Nlevels),fl_ccrain(Npoints,Nlevels), & fl_ccsnow(Npoints,Nlevels),Reff(Npoints,Nlevels,N_HYDRO), & dtau_s(Npoints,Nlevels),dtau_c(Npoints,Nlevels),dem_s(Npoints,Nlevels), & - dem_c(Npoints,Nlevels),skt(Npoints),landmask(Npoints), & + dem_c(Npoints,Nlevels),skt(Npoints),psfc(Npoints),landmask(Npoints), & mr_ozone(Npoints,Nlevels),u_wind(Npoints),v_wind(Npoints),sunlit(Npoints), & frac_out(Npoints,Ncolumns,Nlevels),surfelev(Npoints),year(Npoints), & month(Npoints),day(Npoints),hour(Npoints),minute(Npoints),seconds(Npoints)) @@ -397,7 +398,7 @@ program cosp2_test call nc_read_input_file(fileIN,Npoints,Nlevels,N_HYDRO,lon,lat,p,ph,zlev,zlev_half, & T,sh,rh,tca,cca,mr_lsliq,mr_lsice,mr_ccliq,mr_ccice,fl_lsrain, & fl_lssnow,fl_lsgrpl,fl_ccrain,fl_ccsnow,Reff,dtau_s,dtau_c, & - dem_s,dem_c,skt,landmask,mr_ozone,u_wind,v_wind,sunlit, & + dem_s,dem_c,skt,psfc,landmask,mr_ozone,u_wind,v_wind,sunlit, & emsfc_lw,geomode,Nlon,Nlat,surfelev,year,month,day,hour, & minute,seconds) call cpu_time(driver_time(2)) @@ -583,6 +584,12 @@ program cosp2_test ! Pressure at interface (nlevels+1). Set uppermost interface to 0. cospstateIN%phalf(:,2:Nlevels+1) = ph(start_idx:end_idx,Nlevels:1:-1) ! Pa cospstateIN%phalf(:,1) = 0._wp + ! Surface pressure + if (any(psfc(start_idx:end_idx) .lt. 0._wp)) then + print*,'Some of values of the surface pressure field are negative. Replacing all psfc values with the lowest boundary pressure.' + psfc(start_idx:end_idx) = cospstateIN%phalf(start_idx:end_idx,Nlevels+1) + end if + cospstateIN%psfc = psfc(start_idx:end_idx) ! Pa ! Height of bottom interfaces of model layers (nlevels). ! cospstateIN%hgt_matrix_half(:,1) contains the bottom of the top layer. ! cospstateIN%hgt_matrix_half(:,Nlevels) contains the bottom of the surface layer. @@ -1239,6 +1246,7 @@ subroutine construct_cospstateIN(npoints,nlevels,y) type(cosp_column_inputs),intent(out) :: y allocate(y%sunlit(npoints),y%skt(npoints),y%land(npoints),y%at(npoints,nlevels), & + y%psfc(npoints), & y%pfull(npoints,nlevels),y%phalf(npoints,nlevels+1),y%qv(npoints,nlevels), & y%o3(npoints,nlevels),y%hgt_matrix(npoints,nlevels),y%u_sfc(npoints), & y%v_sfc(npoints),y%lat(npoints),y%lon(nPoints),y%rttov_sfcmask(nPoints), & @@ -1669,6 +1677,7 @@ subroutine destroy_cospstateIN(y) if (allocated(y%sunlit)) deallocate(y%sunlit) if (allocated(y%skt)) deallocate(y%skt) + if (allocated(y%psfc)) deallocate(y%psfc) if (allocated(y%land)) deallocate(y%land) if (allocated(y%rttov_sfcmask)) deallocate(y%rttov_sfcmask) if (allocated(y%at)) deallocate(y%at) diff --git a/src/cosp.F90 b/src/cosp.F90 index 59b3ac6abe..b59e26fbb4 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -107,6 +107,7 @@ MODULE MOD_COSP real(wp),allocatable,dimension(:) :: & land, & ! Land/Sea mask (0 for ocean, 1 for land) skt, & ! Surface temperature (K) + psfc, & ! Surface pressure (Pa) surfelev, & ! Surface Elevation (m) rttov_sfcmask ! Mask for RTTOV surface types (0 for ocean, 1 for land, 2 for sea ice) ! Fields used ONLY by RTTOV @@ -1157,7 +1158,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (Lrttov_column) then rttovIN%nPoints => Npoints - rttovIN%nLevels => cospIN%nLevels + rttovIN%nLevels => cospIN%nLevels ! This is actually "nlayers" in the RTTOV sense rttovIN%nSubCols => cospIN%nColumns rttovIN%co2 => cospgridIN%co2 rttovIN%ch4 => cospgridIN%ch4 @@ -1167,7 +1168,8 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) rttovIN%u_surf => cospgridIN%u_sfc rttovIN%v_surf => cospgridIN%v_sfc rttovIN%t_skin => cospgridIN%skt - rttovIN%p_surf => cospgridIN%phalf(:,cospIN%Nlevels+1) + rttovIN%p_surf => cospgridIN%psfc ! Lower boundary of lowest layer may not be the surface. + ! rttovIN%p_surf => cospgridIN%phalf(:,cospIN%Nlevels+1) if (associated(cospIN%emis_grey)) rttovIN%emis_grey => cospIN%emis_grey ! rttovIN%surfem => cospgridIN%emis_in ! rttovIN%refl_in => cospgridIN%refl_in diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index c007448b76..1d53022ecb 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -576,6 +576,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & if (inst_swath_mask(i)) then ! only added masked columns to profiles j = j + 1 ! Increment first + ! Trace gas concentrations on levels (not layers!) ! Initialize trace gas concentrations from user input. if (Luser_tracegas) then if (Ldo_co2) inst_profiles(j)%co2(:) = inst_co2_mr @@ -595,9 +596,9 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & end if ! Initialize column pressure, temperature, and humidity - inst_profiles(j)%p(:) = rttovIN%p(i, :) * 1e-2 ! convert Pa to hPa - inst_profiles(j)%t(:) = rttovIN%t(i, :) - inst_profiles(j)%q(:) = rttovIN%q(i, :) + inst_profiles(j)%p(:) = rttovIN%p(i, :) * 1e-2 ! convert Pa to hPa. Pressure on levels. + inst_profiles(j)%t(:) = rttovIN%t(i, :) ! Temperature on levels. + inst_profiles(j)%q(:) = rttovIN%q(i, :) ! Water vapor concentration on levels. ! q coefficient limit is 0.1e-10 where(inst_profiles(j)%q(:) < 0.1e-10) @@ -669,14 +670,6 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & end if end do -! if (verbose) then -! print*,'inst_profiles(1)%p(:): ',inst_profiles(1)%p(:) -! print*,'inst_profiles(1)%t(:): ',inst_profiles(1)%t(:) -! print*,'inst_profiles(1)%q(:): ',inst_profiles(1)%q(:) -! print*,'inst_profiles(1)%co2(:): ',inst_profiles(1)%co2(:) -! print*,'inst_profiles(1)%skin%t: ',inst_profiles(1)%skin%t -! print*,'inst_profiles(1)%s2m%t: ',inst_profiles(1)%s2m%t -! end if ! JKS - nothing to check here, this will never trigger. call rttov_error('error in profile initialization' , lalloc = .false.) @@ -701,7 +694,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & if (inst_swath_mask(i)) then ! only added masked columns to profiles j = j + 1 ! Increment profile counter - ! Cloud scheme stuff + ! Cloud scheme stuff. Values are on layers, not levels like the gas concentrations. inst_profiles(j)%cfrac(:) = rttovIN%tca(i,:) ! Cloud fraction for each layer inst_profiles(j)%cloud(1,:) = rttovIN%cldLiq(i,:) ! Cloud water mixing ratio (all in the first type for Deff) inst_profiles(j)%cloud(6,:) = rttovIN%cldIce(i,:) ! Cloud ice mixing ratio (1 type). See pg 74. @@ -772,6 +765,29 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & ! print*,'inst_profiles(:))%azangle: ',inst_profiles(:)%azangle ! end if end if + + if (verbose) then + print*,'inst_profiles(1)%nlevels: ',inst_profiles(1)%nlevels + print*,'inst_profiles(1)%nlayers: ',inst_profiles(1)%nlayers + print*,'shape(rttovIN%t): ', shape(rttovIN%t) + print*,'shape(rttovIN%p): ', shape(rttovIN%p) + print*,'shape(rttovIN%ph): ', shape(rttovIN%ph) + print*,'shape(inst_profiles(1)%p(:)): ',shape(inst_profiles(1)%p(:)) + print*,'shape(inst_profiles(1)%t(:)): ',shape(inst_profiles(1)%t(:)) + print*,'shape(inst_profiles(1)%q(:)): ',shape(inst_profiles(1)%q(:)) + print*,'shape(inst_profiles(1)%cfrac(:)): ',shape(inst_profiles(1)%cfrac(:)) + print*,'shape(rttovIN%tca(1,:)): ',shape(rttovIN%tca(1,:)) + print*,'rttovIN%ph(1,:): ', rttovIN%ph(1,:) + print*,'rttovIN%p(1,:): ', rttovIN%p(1,:) + print*,'inst_profiles(1)%p(:): ',inst_profiles(1)%p(:) + print*,'inst_profiles(1)%t(:): ',inst_profiles(1)%t(:) + print*,'inst_profiles(1)%q(:): ',inst_profiles(1)%q(:) + print*,'inst_profiles(1)%cfrac: ',inst_profiles(1)%cfrac + ! print*,'inst_profiles(1)%co2(:): ',inst_profiles(1)%co2(:) + print*,'inst_profiles(1)%skin%t: ',inst_profiles(1)%skin%t + print*,'inst_profiles(1)%s2m%t: ',inst_profiles(1)%s2m%t + print*,'inst_profiles(1)%s2m%p: ',inst_profiles(1)%s2m%p + end if ! JKS - nothing to check here, this will never trigger. call rttov_error('error in aerosol profile initialization' , lalloc = .true.) From 1701995527ad3de16b606abc4812d9e897f88474 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 24 Apr 2024 11:07:31 -0600 Subject: [PATCH 116/159] Force RTTOV correctly with levels vs. layers. Some comment clean up should be done. --- src/cosp.F90 | 1 - src/simulator/rttov/cosp_rttov_v13.F90 | 217 +++++++++++++++++++------ 2 files changed, 164 insertions(+), 54 deletions(-) diff --git a/src/cosp.F90 b/src/cosp.F90 index b59e26fbb4..031255dc11 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -1169,7 +1169,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) rttovIN%v_surf => cospgridIN%v_sfc rttovIN%t_skin => cospgridIN%skt rttovIN%p_surf => cospgridIN%psfc ! Lower boundary of lowest layer may not be the surface. - ! rttovIN%p_surf => cospgridIN%phalf(:,cospIN%Nlevels+1) if (associated(cospIN%emis_grey)) rttovIN%emis_grey => cospIN%emis_grey ! rttovIN%surfem => cospgridIN%emis_in ! rttovIN%refl_in => cospgridIN%refl_in diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 1d53022ecb..8575e46a41 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -315,7 +315,8 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs, 1_jpim, & ! 1 => allocate inst_nprof, & inst_nchanprof, & - rttovIN%nLevels, & + rttovIN%nLevels+1, & ! "levels" means interfaces, not layers + ! rttovIN%nLevels, & inst_chanprof, & inst_opts, & inst_profiles, & @@ -463,8 +464,9 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, 1_jpim, & ! 1 => allocate inst_nprof, & inst_nchanprof, & - rttovIN%nLevels, & - inst_chanprof, & ! Make this instrument-specific? The rttov_config DDT would then be assigned to this value. Allocation difficulties? + rttovIN%nLevels+1, & ! "levels" means interfaces, not layers + ! rttovIN%nLevels, & + inst_chanprof, & inst_opts, & inst_profiles, & inst_coefs, & @@ -553,9 +555,9 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & debug ! Loop variables - integer(kind=jpim) :: i, j ! Use i to iterate over profile, j for swath_mask. + integer(kind=jpim) :: i, j, k ! Use i to iterate over profile, j for swath_mask, k for vertical interpolation logical :: verbose = .false. - + if (present(debug)) verbose = debug ! Store profile data from rttovIN in profile type. @@ -576,37 +578,123 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & if (inst_swath_mask(i)) then ! only added masked columns to profiles j = j + 1 ! Increment first - ! Trace gas concentrations on levels (not layers!) - ! Initialize trace gas concentrations from user input. - if (Luser_tracegas) then - if (Ldo_co2) inst_profiles(j)%co2(:) = inst_co2_mr - if (Ldo_n2o) inst_profiles(j)%n2o(:) = inst_n2o_mr - if (Ldo_co) inst_profiles(j)%co(:) = inst_co_mr - if (Ldo_ch4) inst_profiles(j)%ch4(:) = inst_ch4_mr - if (Ldo_so2) inst_profiles(j)%so2(:) = inst_so2_mr - if (Ldo_o3) inst_profiles(j)%o3(:) = rttovIN%o3(i, :) ! no O3 user input set up - else - ! For when trace gas columns are supplied by the model. Units must match (kg/kg over moist air) - if (Ldo_co2) inst_profiles(j)%co2(:) = rttovIN%co2(i,:) - if (Ldo_n2o) inst_profiles(j)%n2o(:) = rttovIN%n2o(i,:) - if (Ldo_co) inst_profiles(j)%co(:) = rttovIN%co(i,:) - if (Ldo_ch4) inst_profiles(j)%ch4(:) = rttovIN%ch4(i,:) - if (Ldo_so2) inst_profiles(j)%so2(:) = rttovIN%so2(i,:) - if (Ldo_o3) inst_profiles(j)%o3(:) = rttovIN%o3(i, :) - end if - ! Initialize column pressure, temperature, and humidity - inst_profiles(j)%p(:) = rttovIN%p(i, :) * 1e-2 ! convert Pa to hPa. Pressure on levels. - inst_profiles(j)%t(:) = rttovIN%t(i, :) ! Temperature on levels. - inst_profiles(j)%q(:) = rttovIN%q(i, :) ! Water vapor concentration on levels. + inst_profiles(j)%p(:) = rttovIN%ph(i, :) * 1e-2 ! convert Pa to hPa. Pressure on levels. + if (inst_profiles(j)%p(1) .le. 0) inst_profiles(j)%p(1) = 1 ! If the model top is set to zero make it one (like the COSPv2 driver) + ! inst_profiles(j)%p(:) = rttovIN%p(i, :) * 1e-2 ! convert Pa to hPa. Pressure on layers. Wrong + + ! Interpolate q and t to levels! + + ! Handle the top and bottom levels separately. + ! Top + call interpolate_logp(100*inst_profiles(j)%p(1),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%q(i,1),rttovIN%q(i,2),inst_profiles(j)%q(1)) + call interpolate_logp(100*inst_profiles(j)%p(1),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%t(i,1),rttovIN%t(i,2),inst_profiles(j)%t(1)) + ! Bottom + call interpolate_logp(100*inst_profiles(j)%p(rttovIN%nlevels+1),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%q(i,rttovIN%nlevels-1),rttovIN%q(i,rttovIN%nlevels),inst_profiles(j)%q(rttovIN%nlevels+1)) + call interpolate_logp(100*inst_profiles(j)%p(rttovIN%nlevels+1),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%t(i,rttovIN%nlevels-1),rttovIN%t(i,rttovIN%nlevels),inst_profiles(j)%t(rttovIN%nlevels+1)) + + ! if (verbose) then + ! print*,'k: ',k + ! print*,'inst_profiles(j)%p(1): ',inst_profiles(j)%p(1) + ! print*,'rttovIN%p(i,1): ',rttovIN%p(i,1) + ! print*,'rttovIN%p(i,2): ',rttovIN%p(i,2) + ! print*,'rttovIN%q(i,1): ',rttovIN%q(i,1) + ! print*,'rttovIN%q(i,2): ',rttovIN%q(i,2) + ! print*,'inst_profiles(j)%q(1): ',inst_profiles(j)%q(1) + ! end if + + do k=2,rttovIN%nlevels ! I should really rename the RTTOV one to nlayers!! + call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,k-1),rttovIN%p(i,k),rttovIN%q(i,k-1),rttovIN%q(i,k),inst_profiles(j)%q(k)) + call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,k-1),rttovIN%p(i,k),rttovIN%t(i,k-1),rttovIN%t(i,k),inst_profiles(j)%t(k)) + + ! if (verbose) then + ! print*,'k: ',k + ! print*,'inst_profiles(j)%p(k): ',inst_profiles(j)%p(k) + ! print*,'rttovIN%p(i,k-1): ',rttovIN%p(i,k-1) + ! print*,'rttovIN%p(i,k): ',rttovIN%p(i,k) + ! print*,'rttovIN%q(i,k-1): ',rttovIN%q(i,k-1) + ! print*,'rttovIN%q(i,k): ',rttovIN%q(i,k) + ! print*,'inst_profiles(j)%q(k): ',inst_profiles(j)%q(k) + ! end if + + end do + + ! inst_profiles(j)%t(:) = rttovIN%t(i, :) ! Temperature on levels. + ! inst_profiles(j)%q(:) = rttovIN%q(i, :) ! Water vapor concentration on levels. ! q coefficient limit is 0.1e-10 where(inst_profiles(j)%q(:) < 0.1e-10) inst_profiles(j)%q(:) = 0.11e-10 end where - ! Gas inst_profiles - inst_profiles(j)%o3 = rttovIN%o3(i, :) + ! Trace gas concentrations on levels (not layers!) + ! Initialize trace gas concentrations from user input. + if (Luser_tracegas) then + if (Ldo_co2) inst_profiles(j)%co2(:) = inst_co2_mr + if (Ldo_n2o) inst_profiles(j)%n2o(:) = inst_n2o_mr + if (Ldo_co) inst_profiles(j)%co(:) = inst_co_mr + if (Ldo_ch4) inst_profiles(j)%ch4(:) = inst_ch4_mr + if (Ldo_so2) inst_profiles(j)%so2(:) = inst_so2_mr + ! if (Ldo_o3) inst_profiles(j)%o3(:) = rttovIN%o3(i, :) + if (Ldo_o3) then ! no O3 user input set up + call interpolate_logp(100*inst_profiles(j)%p(1),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%o3(i,1),rttovIN%o3(i,2),inst_profiles(j)%o3(1)) + call interpolate_logp(100*inst_profiles(j)%p(rttovIN%nlevels+1),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%o3(i,rttovIN%nlevels-1),rttovIN%o3(i,rttovIN%nlevels),inst_profiles(j)%o3(rttovIN%nlevels+1)) + do k=2,rttovIN%nlevels + call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,k-1),rttovIN%p(i,k),rttovIN%o3(i,k-1),rttovIN%o3(i,k),inst_profiles(j)%o3(k)) + end do + end if + else ! For when trace gas columns are supplied by the model. Units must match (kg/kg over moist air) and concentration must be supplied on model levels (not layers), requiring interpolation. + if (Ldo_co2) then ! CO2 + call interpolate_logp(100*inst_profiles(j)%p(1),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%co2(i,1),rttovIN%co2(i,2),inst_profiles(j)%co2(1)) + call interpolate_logp(100*inst_profiles(j)%p(rttovIN%nlevels+1),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%co2(i,rttovIN%nlevels-1),rttovIN%co2(i,rttovIN%nlevels),inst_profiles(j)%co2(rttovIN%nlevels+1)) + do k=2,rttovIN%nlevels + call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,k-1),rttovIN%p(i,k),rttovIN%co2(i,k-1),rttovIN%co2(i,k),inst_profiles(j)%co2(k)) + end do + end if + if (Ldo_n2o) then ! N2O + call interpolate_logp(100*inst_profiles(j)%p(1),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%n2o(i,1),rttovIN%n2o(i,2),inst_profiles(j)%n2o(1)) + call interpolate_logp(100*inst_profiles(j)%p(rttovIN%nlevels+1),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%n2o(i,rttovIN%nlevels-1),rttovIN%n2o(i,rttovIN%nlevels),inst_profiles(j)%n2o(rttovIN%nlevels+1)) + do k=2,rttovIN%nlevels + call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,k-1),rttovIN%p(i,k),rttovIN%n2o(i,k-1),rttovIN%n2o(i,k),inst_profiles(j)%n2o(k)) + end do + end if + if (Ldo_co) then ! CO + call interpolate_logp(100*inst_profiles(j)%p(1),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%co(i,1),rttovIN%co(i,2),inst_profiles(j)%co(1)) + call interpolate_logp(100*inst_profiles(j)%p(rttovIN%nlevels+1),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%co(i,rttovIN%nlevels-1),rttovIN%co(i,rttovIN%nlevels),inst_profiles(j)%co(rttovIN%nlevels+1)) + do k=2,rttovIN%nlevels + call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,k-1),rttovIN%p(i,k),rttovIN%co(i,k-1),rttovIN%co(i,k),inst_profiles(j)%co(k)) + end do + end if + if (Ldo_ch4) then ! CH4 + call interpolate_logp(100*inst_profiles(j)%p(1),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%ch4(i,1),rttovIN%ch4(i,2),inst_profiles(j)%ch4(1)) + call interpolate_logp(100*inst_profiles(j)%p(rttovIN%nlevels+1),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%ch4(i,rttovIN%nlevels-1),rttovIN%ch4(i,rttovIN%nlevels),inst_profiles(j)%ch4(rttovIN%nlevels+1)) + do k=2,rttovIN%nlevels + call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,k-1),rttovIN%p(i,k),rttovIN%ch4(i,k-1),rttovIN%ch4(i,k),inst_profiles(j)%ch4(k)) + end do + end if + if (Ldo_so2) then ! SO2 + call interpolate_logp(100*inst_profiles(j)%p(1),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%so2(i,1),rttovIN%so2(i,2),inst_profiles(j)%so2(1)) + call interpolate_logp(100*inst_profiles(j)%p(rttovIN%nlevels+1),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%so2(i,rttovIN%nlevels-1),rttovIN%so2(i,rttovIN%nlevels),inst_profiles(j)%so2(rttovIN%nlevels+1)) + do k=2,rttovIN%nlevels + call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,k-1),rttovIN%p(i,k),rttovIN%so2(i,k-1),rttovIN%so2(i,k),inst_profiles(j)%so2(k)) + end do + end if + if (Ldo_o3) then ! Ozone + call interpolate_logp(100*inst_profiles(j)%p(1),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%o3(i,1),rttovIN%o3(i,2),inst_profiles(j)%o3(1)) + call interpolate_logp(100*inst_profiles(j)%p(rttovIN%nlevels+1),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%o3(i,rttovIN%nlevels-1),rttovIN%o3(i,rttovIN%nlevels),inst_profiles(j)%o3(rttovIN%nlevels+1)) + do k=2,rttovIN%nlevels + call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,k-1),rttovIN%p(i,k),rttovIN%o3(i,k-1),rttovIN%o3(i,k),inst_profiles(j)%o3(k)) + end do + end if + + ! Original non-interpolated code + ! if (Ldo_co2) inst_profiles(j)%co2(:) = rttovIN%co2(i,:) + ! if (Ldo_n2o) inst_profiles(j)%n2o(:) = rttovIN%n2o(i,:) + ! if (Ldo_co) inst_profiles(j)%co(:) = rttovIN%co(i,:) + ! if (Ldo_ch4) inst_profiles(j)%ch4(:) = rttovIN%ch4(i,:) + ! if (Ldo_so2) inst_profiles(j)%so2(:) = rttovIN%so2(i,:) + ! if (Ldo_o3) inst_profiles(j)%o3(:) = rttovIN%o3(i, :) + end if ! 2m parameters inst_profiles(j)%s2m%p = rttovIN%p_surf(i) * 1e-2 ! convert Pa to hPa @@ -766,28 +854,32 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & ! end if end if - if (verbose) then - print*,'inst_profiles(1)%nlevels: ',inst_profiles(1)%nlevels - print*,'inst_profiles(1)%nlayers: ',inst_profiles(1)%nlayers - print*,'shape(rttovIN%t): ', shape(rttovIN%t) - print*,'shape(rttovIN%p): ', shape(rttovIN%p) - print*,'shape(rttovIN%ph): ', shape(rttovIN%ph) - print*,'shape(inst_profiles(1)%p(:)): ',shape(inst_profiles(1)%p(:)) - print*,'shape(inst_profiles(1)%t(:)): ',shape(inst_profiles(1)%t(:)) - print*,'shape(inst_profiles(1)%q(:)): ',shape(inst_profiles(1)%q(:)) - print*,'shape(inst_profiles(1)%cfrac(:)): ',shape(inst_profiles(1)%cfrac(:)) - print*,'shape(rttovIN%tca(1,:)): ',shape(rttovIN%tca(1,:)) - print*,'rttovIN%ph(1,:): ', rttovIN%ph(1,:) - print*,'rttovIN%p(1,:): ', rttovIN%p(1,:) - print*,'inst_profiles(1)%p(:): ',inst_profiles(1)%p(:) - print*,'inst_profiles(1)%t(:): ',inst_profiles(1)%t(:) - print*,'inst_profiles(1)%q(:): ',inst_profiles(1)%q(:) - print*,'inst_profiles(1)%cfrac: ',inst_profiles(1)%cfrac - ! print*,'inst_profiles(1)%co2(:): ',inst_profiles(1)%co2(:) - print*,'inst_profiles(1)%skin%t: ',inst_profiles(1)%skin%t - print*,'inst_profiles(1)%s2m%t: ',inst_profiles(1)%s2m%t - print*,'inst_profiles(1)%s2m%p: ',inst_profiles(1)%s2m%p - end if + ! if (verbose) then + ! print*,'inst_profiles(1)%nlevels: ',inst_profiles(1)%nlevels + ! print*,'inst_profiles(1)%nlayers: ',inst_profiles(1)%nlayers + ! print*,'shape(rttovIN%t): ', shape(rttovIN%t) + ! print*,'shape(rttovIN%p): ', shape(rttovIN%p) + ! print*,'shape(rttovIN%ph): ', shape(rttovIN%ph) + ! print*,'shape(inst_profiles(1)%p(:)): ',shape(inst_profiles(1)%p(:)) + ! print*,'shape(inst_profiles(1)%t(:)): ',shape(inst_profiles(1)%t(:)) + ! print*,'shape(inst_profiles(1)%q(:)): ',shape(inst_profiles(1)%q(:)) + ! print*,'shape(inst_profiles(1)%cfrac(:)): ',shape(inst_profiles(1)%cfrac(:)) + ! print*,'shape(rttovIN%tca(1,:)): ',shape(rttovIN%tca(1,:)) + ! print*,'rttovIN%ph(1,:): ', rttovIN%ph(1,:) + ! print*,'rttovIN%p(1,:): ', rttovIN%p(1,:) + ! print*,'rttovIN%t(1,:): ', rttovIN%t(1,:) + ! print*,'rttovIN%q(1,:): ', rttovIN%q(1,:) + ! print*,'rttovIN%o3(1,:): ', rttovIN%o3(1,:) + ! print*,'inst_profiles(1)%p(:): ',inst_profiles(1)%p(:) + ! print*,'inst_profiles(1)%t(:): ',inst_profiles(1)%t(:) + ! print*,'inst_profiles(1)%q(:): ',inst_profiles(1)%q(:) + ! print*,'inst_profiles(1)%o3(:): ',inst_profiles(1)%o3(:) + ! print*,'inst_profiles(1)%cfrac: ',inst_profiles(1)%cfrac + ! print*,'inst_profiles(1)%co2(:): ',inst_profiles(1)%co2(:) + ! print*,'inst_profiles(1)%skin%t: ',inst_profiles(1)%skin%t + ! print*,'inst_profiles(1)%s2m%t: ',inst_profiles(1)%s2m%t + ! print*,'inst_profiles(1)%s2m%p: ',inst_profiles(1)%s2m%p + ! end if ! JKS - nothing to check here, this will never trigger. call rttov_error('error in aerosol profile initialization' , lalloc = .true.) @@ -1276,7 +1368,8 @@ subroutine cosp_rttov_deallocate_profiles(inst_nprof, & 0_jpim, & ! 0 => deallocate inst_nprof, & inst_nchanprof, & - nLevels, & + nLevels+1, & ! "levels" means interfaces, not layers + ! nLevels, & inst_chanprof, & inst_opts, & inst_profiles, & @@ -1347,7 +1440,8 @@ subroutine cosp_pc_rttov_deallocate_profiles(inst_nprof, & 0_jpim, & ! 0 => deallocate inst_nprof, & inst_nchanprof, & - nLevels, & + nLevels+1, & ! "levels" means interfaces, not layers + ! nLevels, & inst_chanprof, & inst_opts, & inst_profiles, & @@ -1375,6 +1469,23 @@ subroutine cosp_rttov_deallocate_coefs(inst_coefs) end subroutine cosp_rttov_deallocate_coefs + subroutine interpolate_logp(ptarget,p1,p2,z1,z2,ztarget) + + real(jprb),intent(in) :: ptarget + real(WP),intent(in) :: p1,p2,z1,z2 + real(jprb),intent(out) :: ztarget ! variable interpolated to the target pressure level + + ! Normal procedure where ptarget falls within [p1,p2] + if ((ptarget .gt. p1) .and. (ptarget .lt. p2)) then + ztarget = z1 + (z2-z1) * log(ptarget / p1) / log(p2 / p1) + elseif (ptarget .lt. p1) then ! Top of model level. ptarget may be zero... + ztarget = z1 ! Just set it to the layer value?? Not sure how to handle this if ptarget=0. I think that this is fine. We're basically out of range. + elseif (ptarget .gt. p2) then ! surface level + ztarget = z2 + (z2-z1) * log(ptarget / p2) / log(p2 / p1) + end if + + end subroutine interpolate_logp + !########################## ! Module End !########################## From 0737e96e64e279d9f39b337013ffdb20dfbbf0d9 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 8 May 2024 17:35:16 -0600 Subject: [PATCH 117/159] Add options for NLTE corrections and cloud water mixing ratio settings. Also set offline driver to assume unitary surface emissivity. --- driver/src/cosp2_test.F90 | 8 ++-- src/simulator/cosp_rttov_interface_v13.F90 | 49 ++++++++++++---------- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index f4a5241d9d..80b450bbd8 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -548,15 +548,15 @@ program cosp2_test ! Construct COSP input types !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if (iChunk .eq. 1) then -! call construct_cospIN(Nptsperit,nColumns,nLevels,rttov_Ninstruments,cospIN,emis_grey=0.2_wp) - call construct_cospIN(Nptsperit,nColumns,nLevels,rttov_Ninstruments,cospIN) + call construct_cospIN(Nptsperit,nColumns,nLevels,rttov_Ninstruments,cospIN,emis_grey=1.0_wp) + ! call construct_cospIN(Nptsperit,nColumns,nLevels,rttov_Ninstruments,cospIN) call construct_cospstateIN(Nptsperit,nLevels,cospstateIN) endif if (iChunk .eq. nChunks) then call destroy_cospIN(cospIN) call destroy_cospstateIN(cospstateIN) -! call construct_cospIN(Nptsperit,nColumns,nLevels,rttov_Ninstruments,cospIN,emis_grey=0.2_wp) - call construct_cospIN(Nptsperit,nColumns,nLevels,rttov_Ninstruments,cospIN) + call construct_cospIN(Nptsperit,nColumns,nLevels,rttov_Ninstruments,cospIN,emis_grey=1.0_wp) + ! call construct_cospIN(Nptsperit,nColumns,nLevels,rttov_Ninstruments,cospIN) call construct_cospstateIN(Nptsperit,nLevels,cospstateIN) endif call cpu_time(driver_time(4)) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index cb3ed2562b..8af811d89a 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -228,6 +228,8 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & logical :: Lrttov_aer logical :: Lrttov_cldparam logical :: Lrttov_aerparam + logical :: Lrttov_gridbox_cldmmr + logical :: Ldo_nlte_correction logical :: Lrttov_pc logical :: Lrttov_solar logical :: Lchannel_filepath @@ -270,29 +272,32 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & if (present(debug)) verbose = debug ! Init. variables to false. - rttov_Nlocaltime = 0 - Lrttov_bt = .false. - Lrttov_rad = .false. - Lrttov_refl = .false. - Lrttov_cld = .false. - Lrttov_aer = .false. - Lrttov_cldparam = .false. - Lrttov_aerparam = .false. - Lrttov_pc = .false. - Lrttov_solar = .false. - Lchannel_filepath = .false. - SO2_data = .false. - N2O_data = .false. - CO_data = .false. - CO2_data = .false. - CH4_data = .false. - ozone_data = .false. - clw_data = .false. - user_tracegas_input = .false. + rttov_Nlocaltime = 0 + Lrttov_bt = .false. + Lrttov_rad = .false. + Lrttov_refl = .false. + Lrttov_cld = .false. + Lrttov_aer = .false. + Lrttov_cldparam = .false. + Lrttov_aerparam = .false. + Lrttov_gridbox_cldmmr = .true. ! Assume gridbox average MMRs. Most common for GCMs. + Ldo_nlte_correction = .false. ! Correct for non-local thermal equilibrium effects? Default false. + Lrttov_pc = .false. + Lrttov_solar = .false. + Lchannel_filepath = .false. + SO2_data = .false. + N2O_data = .false. + CO_data = .false. + CO2_data = .false. + CH4_data = .false. + ozone_data = .false. + clw_data = .false. + user_tracegas_input = .false. ! Read RTTOV namelist fields namelist/RTTOV_INPUT/Lrttov_bt,Lrttov_rad,Lrttov_refl,Lrttov_cld, & ! Logicals for RTTOV configuration Lrttov_aer,Lrttov_cldparam,Lrttov_aerparam, & ! + Lrttov_gridbox_cldmmr,Ldo_nlte_correction, & ! Assume cloud water mixing ratios are gridbox average instead of in-cloud Lrttov_pc,Lrttov_solar,nchannels_rec,Lchannel_filepath, & channel_filepath,rttov_srcDir,rttov_coefDir, & OD_coef_filepath,aer_coef_filepath,cld_coef_filepath, & @@ -418,7 +423,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & rttov_config % opts % rt_ir % rayleigh_min_pressure = 0._wp ! 0 hPa rttov_config % opts % rt_ir % rayleigh_single_scatt = .true. rttov_config % opts % rt_ir % rayleigh_depol = .true. ! Default false, recommended true - rttov_config % opts % rt_ir % do_nlte_correction = .false. + rttov_config % opts % rt_ir % do_nlte_correction = Ldo_nlte_correction rttov_config % opts % rt_ir % solar_sea_brdf_model = 2 rttov_config % opts % rt_ir % ir_sea_emis_model = 2 @@ -431,7 +436,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & rttov_config % opts % rt_ir % user_aer_opt_param = Lrttov_aerparam ! User specifies the aerosol scattering optical parameters rttov_config % opts % rt_ir % user_cld_opt_param = Lrttov_cldparam ! User specifies the cloud scattering optical parameters - rttov_config % opts % rt_ir % grid_box_avg_cloud = .true. + rttov_config % opts % rt_ir % grid_box_avg_cloud = Lrttov_gridbox_cldmmr rttov_config % opts % rt_ir % cldcol_threshold = -1._wp rttov_config % opts % rt_ir % cloud_overlap = 1 ! Maximum-random overlap rttov_config % opts % rt_ir % cc_low_cloud_top = 750_wp ! 750 hPa. Only applies when cloud_overlap=2. @@ -598,6 +603,8 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & print*,'rttov_config % Lrttov_aer: ',rttov_config % Lrttov_aer print*,'rttov_config % Lrttov_pc: ',rttov_config % Lrttov_pc print*,'rttov_config % Lrttov_solar: ',rttov_config % Lrttov_solar + print*,'rttov_config % opts % rt_ir % grid_box_avg_cloud: ',rttov_config % opts % rt_ir % grid_box_avg_cloud + print*,'rttov_config % opts % rt_ir % do_nlte_correction: ',rttov_config % opts % rt_ir % do_nlte_correction print*,'rttov_config % rttov_Nlocaltime: ',rttov_config % rttov_Nlocaltime print*,'rttov_config % rttov_localtime: ',rttov_config % rttov_localtime print*,'rttov_config % rttov_localtime_width: ',rttov_config % rttov_localtime_width From 6879d1a36413ddbd0f8f5edafb0235ce976f3313 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 8 May 2024 17:36:16 -0600 Subject: [PATCH 118/159] Add lots of namelist files for validation against RRTMG and SARTA. --- .../cosp2_input_AIRS_L1C_validation_nl.txt | 110 +++++++++++++ driver/run/cosp2_input_iasi_nl.txt | 113 ------------- .../run/cosp2_input_rrtmg_validation_nl.txt | 113 +++++++++++++ driver/run/cosp2_input_rttov_nl.txt | 10 +- driver/run/cosp2_input_rttov_nl.um_global.txt | 2 +- driver/run/cosp2_output_AIRS_L1C_nl.txt | 152 ++++++++++++++++++ .../cosp2_rttov_AIRS_L1C_val1.txt | 75 +++++++++ .../cosp2_rttov_AIRS_L1C_val2.txt | 75 +++++++++ .../cosp2_rttov_AIRS_L1C_val3.txt | 77 +++++++++ .../cosp2_rttov_FORUM_CESM2_val1.txt | 75 +++++++++ .../cosp2_rttov_FORUM_CESM2_val2.txt | 75 +++++++++ .../cosp2_rttov_FORUM_CESM2_val3.txt | 75 +++++++++ .../cosp2_rttov_IASI_CESM2_val.txt | 2 + .../cosp2_rttov_IASI_CESM2_val1.txt | 4 +- .../cosp2_rttov_IASI_CESM2_val2.txt | 2 + .../cosp2_rttov_IASI_CESM2_val3.txt | 2 + .../cosp2_rttov_inst5_PREFIRE_CESM2.txt | 4 +- ...osp2_input_rrtmg_6stream_validation_nl.txt | 110 +++++++++++++ .../cosp2_rttov_FORUM_CESM2_vza1.txt | 77 +++++++++ .../cosp2_rttov_FORUM_CESM2_vza2.txt | 77 +++++++++ .../cosp2_rttov_FORUM_CESM2_vza3.txt | 77 +++++++++ .../cosp2_rttov_FORUM_CESM2_vza4.txt | 77 +++++++++ .../cosp2_rttov_FORUM_CESM2_vza5.txt | 77 +++++++++ .../cosp2_rttov_FORUM_CESM2_vza6.txt | 77 +++++++++ .../cosp2_rttov_IASI_CESM2_vza1.txt | 78 +++++++++ .../cosp2_rttov_IASI_CESM2_vza2.txt | 78 +++++++++ .../cosp2_rttov_IASI_CESM2_vza3.txt | 78 +++++++++ .../cosp2_rttov_IASI_CESM2_vza4.txt | 78 +++++++++ .../cosp2_rttov_IASI_CESM2_vza5.txt | 78 +++++++++ .../cosp2_rttov_IASI_CESM2_vza6.txt | 78 +++++++++ .../rttov_channel_input_AIRSL1C_subset.csv | 45 ++++++ .../run/rttov_channel_input_AIRS_subset.csv | 52 +++--- 32 files changed, 1955 insertions(+), 148 deletions(-) create mode 100644 driver/run/cosp2_input_AIRS_L1C_validation_nl.txt create mode 100644 driver/run/cosp2_input_rrtmg_validation_nl.txt create mode 100644 driver/run/cosp2_output_AIRS_L1C_nl.txt create mode 100644 driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val1.txt create mode 100644 driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val2.txt create mode 100644 driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val3.txt create mode 100644 driver/run/instrument_nls/cosp2_rttov_FORUM_CESM2_val1.txt create mode 100644 driver/run/instrument_nls/cosp2_rttov_FORUM_CESM2_val2.txt create mode 100644 driver/run/instrument_nls/cosp2_rttov_FORUM_CESM2_val3.txt create mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_input_rrtmg_6stream_validation_nl.txt create mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt create mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt create mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt create mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt create mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt create mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt create mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt create mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt create mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt create mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt create mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt create mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt create mode 100644 driver/run/rttov_channel_input_AIRSL1C_subset.csv diff --git a/driver/run/cosp2_input_AIRS_L1C_validation_nl.txt b/driver/run/cosp2_input_AIRS_L1C_validation_nl.txt new file mode 100644 index 0000000000..e78b5ef20b --- /dev/null +++ b/driver/run/cosp2_input_AIRS_L1C_validation_nl.txt @@ -0,0 +1,110 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&COSP_INPUT + NPOINTS=153,! Number of gridpoints 153,27840,7081,6912 + NPOINTS_IT=5000,! 50,5000, Max number of gridpoints to be processed in one iteration + NCOLUMNS=20, ! Number of subcolumns + NLEVELS=38, ! Number of model levels + USE_VGRID=.true., ! Use fixed vertical grid for outputs? (if .true. then you need to define number of levels with Nlr) + NLVGRID=40, ! Number of levels in statistical outputs (only used if USE_VGRID=.true.) + CSAT_VGRID=.true., ! CloudSat vertical grid? (if .true. then the CloudSat standard grid is used for the outputs. + ! USE_VGRID needs also be .true.) + DINPUT='./', ! Directory where the input files are located. Useful when processing multiple files. + ! Leave blank ('') if you are using the full path in FINPUT. + FINPUT='../data/inputs/UKMO/cosp_input_um_realisticO3.nc', ! List input NetCDF files + FOUTPUT='../data/outputs/UKMO/cosp2_output_um_AIRS_L1C_O3profile_emis1.nc', + !---------------------------------------------------------------------------------- + !--------------- Inputs related to radar simulations + !---------------------------------------------------------------------------------- + cloudsat_RADAR_FREQ=94.0, ! CloudSat radar frequency (GHz) + SURFACE_RADAR=0, ! surface=1, spaceborne=0 + cloudsat_use_gas_abs=1, ! include gaseous absorption? yes=1,no=0 + cloudsat_do_ray=0, ! calculate/output Rayleigh refl=1, not=0 + cloudsat_k2=-1, ! |K|^2, -1=use frequency dependent default + use_precipitation_fluxes=.true., ! True if precipitation fluxes are input to the algorithm + cloudsat_micro_scheme='MMF_v3_single_moment', !'MMF_v3.5_two_moment' + !---------------------------------------------------------------------------------- + !---------------- Inputs related to lidar simulations + !---------------------------------------------------------------------------------- + lidar_ice_type=0, ! Ice particle shape in lidar calculations (0=ice-spheres ; 1=ice-non-spherical) + OVERLAP=3, ! overlap assumption used by scops: 1=max, 2=rand, 3=max/rand + !---------------------------------------------------------------------------------- + !---------------- Inputs related to ISCCP simulator + !---------------------------------------------------------------------------------- + ISCCP_TOPHEIGHT=1, ! 1 = adjust top height using both a computed + ! infrared brightness temperature and the visible + ! optical depth to adjust cloud top pressure. Note + ! that this calculation is most appropriate to compare + ! to ISCCP data during sunlit hours. + ! 2 = do not adjust top height, that is cloud top + ! pressure is the actual cloud top pressure + ! in the model + ! 3 = adjust top height using only the computed + ! infrared brightness temperature. Note that this + ! calculation is most appropriate to compare to ISCCP + ! IR only algortihm (i.e. you can compare to nighttime + ! ISCCP data with this option) + ISCCP_TOPHEIGHT_DIRECTION=2, ! direction for finding atmosphere pressure level + ! with interpolated temperature equal to the radiance + ! determined cloud-top temperature + ! 1 = find the *lowest* altitude (highest pressure) level + ! with interpolated temperature equal to the radiance + ! determined cloud-top temperature + ! 2 = find the *highest* altitude (lowest pressure) level + ! with interpolated temperature equal to the radiance + ! determined cloud-top temperature. This is the + ! default value since V4.0 of the ISCCP simulator. + ! ONLY APPLICABLE IF top_height EQUALS 1 or 3 + !---------------------------------------------------------------------------------- + !-------------- RTTOV inputs + !---------------------------------------------------------------------------------- + ! Simulating three AIRS L1C instruments + rttov_Ninstruments=3, + rttov_instrument_namelists='instrument_nls/cosp2_rttov_AIRS_L1C_val1.txt','instrument_nls/cosp2_rttov_AIRS_L1C_val2.txt','instrument_nls/cosp2_rttov_AIRS_L1C_val3.txt', + rttov_verbose=.true. + !---------------------------------------------------------------------------------- + !-------------- Swathing inputs + !---------------------------------------------------------------------------------- + N_SWATHS_ISCCP=0, + SWATH_LOCALTIMES_ISCCP=0,0, + SWATH_WIDTHS_ISCCP=0,0, + N_SWATHS_MISR=0, + SWATH_LOCALTIMES_MISR=0,0, + SWATH_WIDTHS_MISR=0,0, + N_SWATHS_MODIS=0, + SWATH_LOCALTIMES_MODIS=0,0, + SWATH_WIDTHS_MODIS=0,0, + N_SWATHS_CSCAL=0, + SWATH_LOCALTIMES_CSCAL=0,0, + SWATH_WIDTHS_CSCAL=0,0, + N_SWATHS_PARASOL=0, + SWATH_LOCALTIMES_PARASOL=0,0, + SWATH_WIDTHS_PARASOL=0,0, + N_SWATHS_ATLID=0, + SWATH_LOCALTIMES_ATLID=0,0, + SWATH_WIDTHS_ATLID=0,0, +/ diff --git a/driver/run/cosp2_input_iasi_nl.txt b/driver/run/cosp2_input_iasi_nl.txt index c612af90f3..e69de29bb2 100644 --- a/driver/run/cosp2_input_iasi_nl.txt +++ b/driver/run/cosp2_input_iasi_nl.txt @@ -1,113 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&COSP_INPUT - NPOINTS=153,! Number of gridpoints 153,27840,7081,6912 - NPOINTS_IT=2,! 50,5000, Max number of gridpoints to be processed in one iteration - NCOLUMNS=20, ! Number of subcolumns - NLEVELS=38, ! Number of model levels - USE_VGRID=.true., ! Use fixed vertical grid for outputs? (if .true. then you need to define number of levels with Nlr) - NLVGRID=40, ! Number of levels in statistical outputs (only used if USE_VGRID=.true.) - CSAT_VGRID=.true., ! CloudSat vertical grid? (if .true. then the CloudSat standard grid is used for the outputs. - ! USE_VGRID needs also be .true.) - DINPUT='./', ! Directory where the input files are located. Useful when processing multiple files. - ! Leave blank ('') if you are using the full path in FINPUT. - FINPUT='../data/inputs/UKMO/cosp_input_um.nc', ! List input NetCDF files - FOUTPUT='../data/outputs/UKMO/cosp2_output_um_iasi.nc', - !---------------------------------------------------------------------------------- - !--------------- Inputs related to radar simulations - !---------------------------------------------------------------------------------- - cloudsat_RADAR_FREQ=94.0, ! CloudSat radar frequency (GHz) - SURFACE_RADAR=0, ! surface=1, spaceborne=0 - cloudsat_use_gas_abs=1, ! include gaseous absorption? yes=1,no=0 - cloudsat_do_ray=0, ! calculate/output Rayleigh refl=1, not=0 - cloudsat_k2=-1, ! |K|^2, -1=use frequency dependent default - use_precipitation_fluxes=.true., ! True if precipitation fluxes are input to the algorithm - cloudsat_micro_scheme='MMF_v3_single_moment', !'MMF_v3.5_two_moment' - !---------------------------------------------------------------------------------- - !---------------- Inputs related to lidar simulations - !---------------------------------------------------------------------------------- - lidar_ice_type=0, ! Ice particle shape in lidar calculations (0=ice-spheres ; 1=ice-non-spherical) - OVERLAP=3, ! overlap assumption used by scops: 1=max, 2=rand, 3=max/rand - !---------------------------------------------------------------------------------- - !---------------- Inputs related to ISCCP simulator - !---------------------------------------------------------------------------------- - ISCCP_TOPHEIGHT=1, ! 1 = adjust top height using both a computed - ! infrared brightness temperature and the visible - ! optical depth to adjust cloud top pressure. Note - ! that this calculation is most appropriate to compare - ! to ISCCP data during sunlit hours. - ! 2 = do not adjust top height, that is cloud top - ! pressure is the actual cloud top pressure - ! in the model - ! 3 = adjust top height using only the computed - ! infrared brightness temperature. Note that this - ! calculation is most appropriate to compare to ISCCP - ! IR only algortihm (i.e. you can compare to nighttime - ! ISCCP data with this option) - ISCCP_TOPHEIGHT_DIRECTION=2, ! direction for finding atmosphere pressure level - ! with interpolated temperature equal to the radiance - ! determined cloud-top temperature - ! 1 = find the *lowest* altitude (highest pressure) level - ! with interpolated temperature equal to the radiance - ! determined cloud-top temperature - ! 2 = find the *highest* altitude (lowest pressure) level - ! with interpolated temperature equal to the radiance - ! determined cloud-top temperature. This is the - ! default value since V4.0 of the ISCCP simulator. - ! ONLY APPLICABLE IF top_height EQUALS 1 or 3 - !---------------------------------------------------------------------------------- - !-------------- RTTOV inputs - !---------------------------------------------------------------------------------- - ! Simulating a single Nadir-viewing IASI instrument. - !rttov_Ninstruments=1, - !rttov_instrument_namelists='instrument_nls/cosp2_rttov_IASI_CESM2_val.txt', - ! Simulating three IASI instruments - rttov_Ninstruments=3, - rttov_instrument_namelists='instrument_nls/cosp2_rttov_IASI_CESM2_val1.txt','instrument_nls/cosp2_rttov_IASI_CESM2_val2.txt','instrument_nls/cosp2_rttov_IASI_CESM2_val3.txt', - rttov_verbose=.true. - !---------------------------------------------------------------------------------- - !-------------- Swathing inputs - !---------------------------------------------------------------------------------- - N_SWATHS_ISCCP=0, - SWATH_LOCALTIMES_ISCCP=0,0, - SWATH_WIDTHS_ISCCP=0,0, - N_SWATHS_MISR=0, - SWATH_LOCALTIMES_MISR=0,0, - SWATH_WIDTHS_MISR=0,0, - N_SWATHS_MODIS=0, - SWATH_LOCALTIMES_MODIS=0,0, - SWATH_WIDTHS_MODIS=0,0, - N_SWATHS_CSCAL=0, - SWATH_LOCALTIMES_CSCAL=0,0, - SWATH_WIDTHS_CSCAL=0,0, - N_SWATHS_PARASOL=0, - SWATH_LOCALTIMES_PARASOL=0,0, - SWATH_WIDTHS_PARASOL=0,0, - N_SWATHS_ATLID=0, - SWATH_LOCALTIMES_ATLID=0,0, - SWATH_WIDTHS_ATLID=0,0, -/ diff --git a/driver/run/cosp2_input_rrtmg_validation_nl.txt b/driver/run/cosp2_input_rrtmg_validation_nl.txt new file mode 100644 index 0000000000..0998ef33fc --- /dev/null +++ b/driver/run/cosp2_input_rrtmg_validation_nl.txt @@ -0,0 +1,113 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&COSP_INPUT + NPOINTS=153,! Number of gridpoints 153,27840,7081,6912 + NPOINTS_IT=2,! 50,5000, Max number of gridpoints to be processed in one iteration + NCOLUMNS=20, ! Number of subcolumns + NLEVELS=38, ! Number of model levels + USE_VGRID=.true., ! Use fixed vertical grid for outputs? (if .true. then you need to define number of levels with Nlr) + NLVGRID=40, ! Number of levels in statistical outputs (only used if USE_VGRID=.true.) + CSAT_VGRID=.true., ! CloudSat vertical grid? (if .true. then the CloudSat standard grid is used for the outputs. + ! USE_VGRID needs also be .true.) + DINPUT='./', ! Directory where the input files are located. Useful when processing multiple files. + ! Leave blank ('') if you are using the full path in FINPUT. + FINPUT='../data/inputs/UKMO/cosp_input_um.nc', ! List input NetCDF files + FOUTPUT='../data/outputs/UKMO/cosp2_output_um_iasi.nc', + !---------------------------------------------------------------------------------- + !--------------- Inputs related to radar simulations + !---------------------------------------------------------------------------------- + cloudsat_RADAR_FREQ=94.0, ! CloudSat radar frequency (GHz) + SURFACE_RADAR=0, ! surface=1, spaceborne=0 + cloudsat_use_gas_abs=1, ! include gaseous absorption? yes=1,no=0 + cloudsat_do_ray=0, ! calculate/output Rayleigh refl=1, not=0 + cloudsat_k2=-1, ! |K|^2, -1=use frequency dependent default + use_precipitation_fluxes=.true., ! True if precipitation fluxes are input to the algorithm + cloudsat_micro_scheme='MMF_v3_single_moment', !'MMF_v3.5_two_moment' + !---------------------------------------------------------------------------------- + !---------------- Inputs related to lidar simulations + !---------------------------------------------------------------------------------- + lidar_ice_type=0, ! Ice particle shape in lidar calculations (0=ice-spheres ; 1=ice-non-spherical) + OVERLAP=3, ! overlap assumption used by scops: 1=max, 2=rand, 3=max/rand + !---------------------------------------------------------------------------------- + !---------------- Inputs related to ISCCP simulator + !---------------------------------------------------------------------------------- + ISCCP_TOPHEIGHT=1, ! 1 = adjust top height using both a computed + ! infrared brightness temperature and the visible + ! optical depth to adjust cloud top pressure. Note + ! that this calculation is most appropriate to compare + ! to ISCCP data during sunlit hours. + ! 2 = do not adjust top height, that is cloud top + ! pressure is the actual cloud top pressure + ! in the model + ! 3 = adjust top height using only the computed + ! infrared brightness temperature. Note that this + ! calculation is most appropriate to compare to ISCCP + ! IR only algortihm (i.e. you can compare to nighttime + ! ISCCP data with this option) + ISCCP_TOPHEIGHT_DIRECTION=2, ! direction for finding atmosphere pressure level + ! with interpolated temperature equal to the radiance + ! determined cloud-top temperature + ! 1 = find the *lowest* altitude (highest pressure) level + ! with interpolated temperature equal to the radiance + ! determined cloud-top temperature + ! 2 = find the *highest* altitude (lowest pressure) level + ! with interpolated temperature equal to the radiance + ! determined cloud-top temperature. This is the + ! default value since V4.0 of the ISCCP simulator. + ! ONLY APPLICABLE IF top_height EQUALS 1 or 3 + !---------------------------------------------------------------------------------- + !-------------- RTTOV inputs + !---------------------------------------------------------------------------------- + ! Simulating a single Nadir-viewing IASI instrument. + !rttov_Ninstruments=1, + !rttov_instrument_namelists='instrument_nls/cosp2_rttov_IASI_CESM2_val.txt', + ! Simulating three IASI instruments and three FORUM instruments + rttov_Ninstruments=6, + rttov_instrument_namelists='instrument_nls/cosp2_rttov_IASI_CESM2_val1.txt','instrument_nls/cosp2_rttov_IASI_CESM2_val2.txt','instrument_nls/cosp2_rttov_IASI_CESM2_val3.txt','instrument_nls/cosp2_rttov_FORUM_CESM2_val1.txt','instrument_nls/cosp2_rttov_FORUM_CESM2_val2.txt','instrument_nls/cosp2_rttov_FORUM_CESM2_val3.txt', + rttov_verbose=.true. + !---------------------------------------------------------------------------------- + !-------------- Swathing inputs + !---------------------------------------------------------------------------------- + N_SWATHS_ISCCP=0, + SWATH_LOCALTIMES_ISCCP=0,0, + SWATH_WIDTHS_ISCCP=0,0, + N_SWATHS_MISR=0, + SWATH_LOCALTIMES_MISR=0,0, + SWATH_WIDTHS_MISR=0,0, + N_SWATHS_MODIS=0, + SWATH_LOCALTIMES_MODIS=0,0, + SWATH_WIDTHS_MODIS=0,0, + N_SWATHS_CSCAL=0, + SWATH_LOCALTIMES_CSCAL=0,0, + SWATH_WIDTHS_CSCAL=0,0, + N_SWATHS_PARASOL=0, + SWATH_LOCALTIMES_PARASOL=0,0, + SWATH_WIDTHS_PARASOL=0,0, + N_SWATHS_ATLID=0, + SWATH_LOCALTIMES_ATLID=0,0, + SWATH_WIDTHS_ATLID=0,0, +/ diff --git a/driver/run/cosp2_input_rttov_nl.txt b/driver/run/cosp2_input_rttov_nl.txt index cf4beecb88..78aff4e808 100644 --- a/driver/run/cosp2_input_rttov_nl.txt +++ b/driver/run/cosp2_input_rttov_nl.txt @@ -26,7 +26,7 @@ ! Namelist that sets up the main COSP options &COSP_INPUT NPOINTS=153,! Number of gridpoints 153,27840,7081,6912 - NPOINTS_IT=5000,! Max number of gridpoints to be processed in one iteration + NPOINTS_IT=5000,! 50,5000, Max number of gridpoints to be processed in one iteration NCOLUMNS=20, ! Number of subcolumns NLEVELS=38, ! Number of model levels USE_VGRID=.true., ! Use fixed vertical grid for outputs? (if .true. then you need to define number of levels with Nlr) @@ -82,10 +82,10 @@ !---------------------------------------------------------------------------------- !-------------- RTTOV inputs !---------------------------------------------------------------------------------- - rttov_Ninstruments=3, - rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt','instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt','instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt', -! rttov_Ninstruments=7, -! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt','instrument_nls/cosp2_rttov_inst4.txt','instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt','instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt','instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt', +! rttov_Ninstruments=3, +! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt','instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt','instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt', + rttov_Ninstruments=7, + rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt','instrument_nls/cosp2_rttov_inst4.txt','instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt','instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt','instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt', ! rttov_Ninstruments=4, ! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt','instrument_nls/cosp2_rttov_inst4.txt', ! rttov_Ninstruments=3, diff --git a/driver/run/cosp2_input_rttov_nl.um_global.txt b/driver/run/cosp2_input_rttov_nl.um_global.txt index f2a99159f4..3c1916b49a 100644 --- a/driver/run/cosp2_input_rttov_nl.um_global.txt +++ b/driver/run/cosp2_input_rttov_nl.um_global.txt @@ -26,7 +26,7 @@ ! Namelist that sets up the main COSP options &COSP_INPUT NPOINTS=1728, ! 1728,6912 - NPOINTS_IT=250,! 1000 Max number of gridpoints to be processed in one iteration + NPOINTS_IT=250,! 250,1000 Max number of gridpoints to be processed in one iteration NCOLUMNS=20, ! Number of subcolumns NLEVELS=54, ! Number of model levels USE_VGRID=.true., ! Use fixed vertical grid for outputs? (if .true. then you need to define number of levels with Nlr) diff --git a/driver/run/cosp2_output_AIRS_L1C_nl.txt b/driver/run/cosp2_output_AIRS_L1C_nl.txt new file mode 100644 index 0000000000..9726a5c6a7 --- /dev/null +++ b/driver/run/cosp2_output_AIRS_L1C_nl.txt @@ -0,0 +1,152 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +! Namelist that sets up output-related variables. It controls +! the instrument simulators to run and the list of variables +! to be written to file +&COSP_OUTPUT + !- CloudSat + Lcfaddbze94=.false., + Ldbze94=.false., + !- CALIPSO + Latb532=.false., + LcfadLidarsr532=.false., + Lclcalipso=.false., + Lclhcalipso=.false., + Lcllcalipso=.false., + Lclmcalipso=.false., + Lcltcalipso=.false., + LparasolRefl=.false., + ! CALIPSO phase diagnostics + Lclcalipsoliq=.false., + Lclcalipsoice=.false., + Lclcalipsoun=.false., + Lclcalipsotmp=.false., + Lclcalipsotmpliq=.false., + Lclcalipsotmpice=.false., + Lclcalipsotmpun=.false., + Lclhcalipsoliq=.false., + Lcllcalipsoliq=.false., + Lclmcalipsoliq=.false., + Lcltcalipsoliq=.false., + Lclhcalipsoice=.false., + Lcllcalipsoice=.false., + Lclmcalipsoice=.false., + Lcltcalipsoice=.false., + Lclhcalipsoun=.false., + Lcllcalipsoun=.false., + Lclmcalipsoun=.false., + Lcltcalipsoun=.false., + ! CALIPSO OPAQ diagnostics + Lclopaquecalipso=.false., + Lclthincalipso=.false., + Lclzopaquecalipso=.false., + Lclcalipsoopaque=.false., + Lclcalipsothin=.false., + Lclcalipsozopaque=.false., + Lclcalipsoopacity=.false., + Lclopaquetemp=.false., + Lclthintemp=.false., + Lclzopaquetemp=.false., + Lclopaquemeanz=.false., + Lclthinmeanz=.false., + Lclthinemis=.false., + Lclopaquemeanzse=.false., + Lclthinmeanzse=.false., + Lclzopaquecalipsose=.false., + ! GROUND LIDAR diagnostics + LlidarBetaMol532gr=.false., + LcfadLidarsr532gr=.false., + Latb532gr=.false., + LclgrLidar532=.false., + LclhgrLidar532=.false., + LcllgrLidar532=.false., + LclmgrLidar532=.false., + LcltgrLidar532=.false., + ! ATLID diagnostics + LlidarBetaMol355=.false., + LcfadLidarsr355=.false., + Latb355=.false., + Lclatlid=.false., + Lclhatlid=.false., + Lcllatlid=.false., + Lclmatlid=.false., + Lcltatlid=.false., + !- ISCCP + Lalbisccp=.false., + Lboxptopisccp=.false., + Lboxtauisccp=.false., + Lpctisccp=.false., + Lclisccp=.false., + Ltauisccp=.false., + Lcltisccp=.false., + Lmeantbisccp=.false., + Lmeantbclrisccp=.false., + !- MISR + LclMISR=.false., + !- Use lidar and radar + Lclcalipso2=.false., + Lcltlidarradar=.false., + Lcloudsat_tcc=.false., + Lcloudsat_tcc2=.false., + !- These are provided for debugging or special purposes + Lfracout=.false., + LlidarBetaMol532=.false., + !- MODIS + Lcltmodis=.false., + Lclwmodis=.false., + Lclimodis=.false., + Lclhmodis=.false., + Lclmmodis=.false., + Lcllmodis=.false., + Ltautmodis=.false., + Ltauwmodis=.false., + Ltauimodis=.false., + Ltautlogmodis=.false., + Ltauwlogmodis=.false., + Ltauilogmodis=.false., + Lreffclwmodis=.false., + Lreffclimodis=.false., + Lpctmodis=.false., + Llwpmodis=.false., + Liwpmodis=.false., + Lclmodis=.false., + !- RTTOV + Lrttov_run=.true., ! Run RTTOV? + ! -CLOUDSAT precipitation frequency/occurence diagnostics + Lptradarflag0=.false., + Lptradarflag1=.false., + Lptradarflag2=.false., + Lptradarflag3=.false., + Lptradarflag4=.false., + Lptradarflag5=.false., + Lptradarflag6=.false., + Lptradarflag7=.false., + Lptradarflag8=.false., + Lptradarflag9=.false., + Lradarpia=.false., + !- CloudSat+MODIS joint diagnostics + Lwr_occfreq=.false., + Lcfodd=.false. +/ diff --git a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val1.txt b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val1.txt new file mode 100644 index 0000000000..d27041cbf7 --- /dev/null +++ b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val1.txt @@ -0,0 +1,75 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.true., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=2645, ! 2645 for all AIRS L1C channels, could limit just to those that overlap RRTMG channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.false., + channel_filepath='rttov_channel_input_AIRS.csv' + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='AIRS_L1C/rtcoef_eos_2_airs_l1c_o3co2.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.false., + CO_data=.false., + CO2_data=.true., + CH4_data=.false., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.true., ! Have RTTOV use the trace gas concentrations below + CO2_mr=6.09e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=0.0, ! Satellite Zenith Angle, was 76.2 + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at + rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1550,0, ! Swath width (km) +/ diff --git a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val2.txt b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val2.txt new file mode 100644 index 0000000000..e1f76a9ecf --- /dev/null +++ b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val2.txt @@ -0,0 +1,75 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.true., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=2645, ! 2645 for all AIRS L1C channels, could limit just to those that overlap RRTMG channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.false., + channel_filepath='rttov_channel_input_AIRS.csv' + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='AIRS_L1C/rtcoef_eos_2_airs_l1c_o3co2.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.false., + CO_data=.false., + CO2_data=.true., + CH4_data=.false., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.true., ! Have RTTOV use the trace gas concentrations below + CO2_mr=6.09e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=20.0, ! Satellite Zenith Angle, was 76.2 + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at + rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1550,0, ! Swath width (km) +/ diff --git a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val3.txt b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val3.txt new file mode 100644 index 0000000000..1acb9aa797 --- /dev/null +++ b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val3.txt @@ -0,0 +1,77 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.true., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? + Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=2645, ! 2645 for all AIRS L1C channels, could limit just to those that overlap RRTMG channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.false., + channel_filepath='rttov_channel_input_AIRS.csv' + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='AIRS_L1C/rtcoef_eos_2_airs_l1c_o3co2.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.false., + CO_data=.false., + CO2_data=.true., + CH4_data=.false., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.true., ! Have RTTOV use the trace gas concentrations below + CO2_mr=6.09e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=45.0, ! Satellite Zenith Angle, was 76.2 + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at + rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1550,0, ! Swath width (km) +/ diff --git a/driver/run/instrument_nls/cosp2_rttov_FORUM_CESM2_val1.txt b/driver/run/instrument_nls/cosp2_rttov_FORUM_CESM2_val1.txt new file mode 100644 index 0000000000..5a065ec072 --- /dev/null +++ b/driver/run/instrument_nls/cosp2_rttov_FORUM_CESM2_val1.txt @@ -0,0 +1,75 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.false., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=5001, ! 5001 for all FORUM channels, could limit just to those that overlap RRTMG channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.false., + channel_filepath='rttov_channel_input_IASI_subset.csv', ! Doesn't matter if producing all channels + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='rttov13pred101L/rtcoef_forum_1_forum_7gas.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_forum_1_forum.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.true., + CO_data=.false., + CO2_data=.true., + CH4_data=.true., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=13.81, ! Satellite Zenith Angle, was 76.2 + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at + rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1550,0, ! Swath width (km) +/ diff --git a/driver/run/instrument_nls/cosp2_rttov_FORUM_CESM2_val2.txt b/driver/run/instrument_nls/cosp2_rttov_FORUM_CESM2_val2.txt new file mode 100644 index 0000000000..d2a11069a0 --- /dev/null +++ b/driver/run/instrument_nls/cosp2_rttov_FORUM_CESM2_val2.txt @@ -0,0 +1,75 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.false., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=5001, ! 5001 for all FORUM channels, could limit just to those that overlap RRTMG channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.false., + channel_filepath='rttov_channel_input_IASI_subset.csv', ! Doesn't matter if producing all channels + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='rttov13pred101L/rtcoef_forum_1_forum_7gas.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_forum_1_forum.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.true., + CO_data=.false., + CO2_data=.true., + CH4_data=.true., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=41.39, !48.6, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at + rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1550,0, ! Swath width (km) +/ diff --git a/driver/run/instrument_nls/cosp2_rttov_FORUM_CESM2_val3.txt b/driver/run/instrument_nls/cosp2_rttov_FORUM_CESM2_val3.txt new file mode 100644 index 0000000000..a429ae8c6c --- /dev/null +++ b/driver/run/instrument_nls/cosp2_rttov_FORUM_CESM2_val3.txt @@ -0,0 +1,75 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.false., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=5001, ! 5001 for all FORUM channels, could limit just to those that overlap RRTMG channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.false., + channel_filepath='rttov_channel_input_IASI_subset.csv', ! Doesn't matter if producing all channels + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='rttov13pred101L/rtcoef_forum_1_forum_7gas.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_forum_1_forum.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.true., + CO_data=.false., + CO2_data=.true., + CH4_data=.true., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=68.82, !64.98, !21.2, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at + rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1550,0, ! Swath width (km) +/ diff --git a/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val.txt b/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val.txt index 2c9b2363ee..0f1fb10b87 100644 --- a/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val.txt +++ b/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val.txt @@ -33,6 +33,8 @@ Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values Lrttov_cldparam=.false., ! Use user input cloud optical parameters Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? + Ldo_nlte_correction=.true., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. Lrttov_pc=.false., ! Run with PC-RTTOV !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels diff --git a/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val1.txt b/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val1.txt index 4b285206a6..26c944d10c 100644 --- a/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val1.txt +++ b/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val1.txt @@ -33,6 +33,8 @@ Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values Lrttov_cldparam=.false., ! Use user input cloud optical parameters Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? + Ldo_nlte_correction=.true., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. Lrttov_pc=.false., ! Run with PC-RTTOV !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels @@ -55,7 +57,7 @@ ! -------------- RTTOV Trace Gas Concentrations ! -------------- Specify units in RTTOV options set-up ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + user_tracegas_input=.true., ! have rttov use the trace gas concentrations below CO2_mr=5.241e-04, CH4_mr=9.139e-07, CO_mr=2.098e-07, diff --git a/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val2.txt b/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val2.txt index 4153d0525a..70fef75aa3 100644 --- a/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val2.txt +++ b/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val2.txt @@ -33,6 +33,8 @@ Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values Lrttov_cldparam=.false., ! Use user input cloud optical parameters Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? + Ldo_nlte_correction=.true., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. Lrttov_pc=.false., ! Run with PC-RTTOV !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels diff --git a/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val3.txt b/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val3.txt index 3dda4b9fff..9bc8481252 100644 --- a/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val3.txt +++ b/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val3.txt @@ -33,6 +33,8 @@ Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values Lrttov_cldparam=.false., ! Use user input cloud optical parameters Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? + Ldo_nlte_correction=.true., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. Lrttov_pc=.false., ! Run with PC-RTTOV !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels diff --git a/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt index 9ceb9fdcf9..1d7eafa40f 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt @@ -61,7 +61,7 @@ ! -------------- RTTOV Trace Gas Concentrations ! -------------- Specify units in RTTOV options set-up ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + user_tracegas_input=.true., ! Have RTTOV use the trace gas concentrations below CO2_mr=5.241e-04, CH4_mr=9.139e-07, CO_mr=2.098e-07, @@ -76,7 +76,7 @@ rttov_nthreads=1, rttov_ZenAng=0.0, ! Satellite Zenith Angle ! Set local time sampling with swath widths - rttov_Nlocaltime=2, ! Number of local times to sample at + rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=6.75,19.25, ! Local times to sample at in hrs [0,24] rttov_localtime_width=15000,2000, ! Swath width (km) / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_input_rrtmg_6stream_validation_nl.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_input_rrtmg_6stream_validation_nl.txt new file mode 100644 index 0000000000..b58f668e59 --- /dev/null +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_input_rrtmg_6stream_validation_nl.txt @@ -0,0 +1,110 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&COSP_INPUT + NPOINTS=153,! Number of gridpoints 153,27840,7081,6912 + NPOINTS_IT=2,! 50,5000, Max number of gridpoints to be processed in one iteration + NCOLUMNS=20, ! Number of subcolumns + NLEVELS=38, ! Number of model levels + USE_VGRID=.true., ! Use fixed vertical grid for outputs? (if .true. then you need to define number of levels with Nlr) + NLVGRID=40, ! Number of levels in statistical outputs (only used if USE_VGRID=.true.) + CSAT_VGRID=.true., ! CloudSat vertical grid? (if .true. then the CloudSat standard grid is used for the outputs. + ! USE_VGRID needs also be .true.) + DINPUT='./', ! Directory where the input files are located. Useful when processing multiple files. + ! Leave blank ('') if you are using the full path in FINPUT. + FINPUT='../data/inputs/UKMO/cosp_input_um.nc', ! List input NetCDF files + FOUTPUT='../data/outputs/UKMO/cosp2_output_um_iasi.nc', + !---------------------------------------------------------------------------------- + !--------------- Inputs related to radar simulations + !---------------------------------------------------------------------------------- + cloudsat_RADAR_FREQ=94.0, ! CloudSat radar frequency (GHz) + SURFACE_RADAR=0, ! surface=1, spaceborne=0 + cloudsat_use_gas_abs=1, ! include gaseous absorption? yes=1,no=0 + cloudsat_do_ray=0, ! calculate/output Rayleigh refl=1, not=0 + cloudsat_k2=-1, ! |K|^2, -1=use frequency dependent default + use_precipitation_fluxes=.true., ! True if precipitation fluxes are input to the algorithm + cloudsat_micro_scheme='MMF_v3_single_moment', !'MMF_v3.5_two_moment' + !---------------------------------------------------------------------------------- + !---------------- Inputs related to lidar simulations + !---------------------------------------------------------------------------------- + lidar_ice_type=0, ! Ice particle shape in lidar calculations (0=ice-spheres ; 1=ice-non-spherical) + OVERLAP=3, ! overlap assumption used by scops: 1=max, 2=rand, 3=max/rand + !---------------------------------------------------------------------------------- + !---------------- Inputs related to ISCCP simulator + !---------------------------------------------------------------------------------- + ISCCP_TOPHEIGHT=1, ! 1 = adjust top height using both a computed + ! infrared brightness temperature and the visible + ! optical depth to adjust cloud top pressure. Note + ! that this calculation is most appropriate to compare + ! to ISCCP data during sunlit hours. + ! 2 = do not adjust top height, that is cloud top + ! pressure is the actual cloud top pressure + ! in the model + ! 3 = adjust top height using only the computed + ! infrared brightness temperature. Note that this + ! calculation is most appropriate to compare to ISCCP + ! IR only algortihm (i.e. you can compare to nighttime + ! ISCCP data with this option) + ISCCP_TOPHEIGHT_DIRECTION=2, ! direction for finding atmosphere pressure level + ! with interpolated temperature equal to the radiance + ! determined cloud-top temperature + ! 1 = find the *lowest* altitude (highest pressure) level + ! with interpolated temperature equal to the radiance + ! determined cloud-top temperature + ! 2 = find the *highest* altitude (lowest pressure) level + ! with interpolated temperature equal to the radiance + ! determined cloud-top temperature. This is the + ! default value since V4.0 of the ISCCP simulator. + ! ONLY APPLICABLE IF top_height EQUALS 1 or 3 + !---------------------------------------------------------------------------------- + !-------------- RTTOV inputs + !---------------------------------------------------------------------------------- + ! Simulating six IASI instruments and six FORUM instruments + rttov_Ninstruments=12, + rttov_instrument_namelists='instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt','instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt','instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt','instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt','instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt','instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt','instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt','instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt','instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt','instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt','instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt','instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt', + rttov_verbose=.true. + !---------------------------------------------------------------------------------- + !-------------- Swathing inputs + !---------------------------------------------------------------------------------- + N_SWATHS_ISCCP=0, + SWATH_LOCALTIMES_ISCCP=0,0, + SWATH_WIDTHS_ISCCP=0,0, + N_SWATHS_MISR=0, + SWATH_LOCALTIMES_MISR=0,0, + SWATH_WIDTHS_MISR=0,0, + N_SWATHS_MODIS=0, + SWATH_LOCALTIMES_MODIS=0,0, + SWATH_WIDTHS_MODIS=0,0, + N_SWATHS_CSCAL=0, + SWATH_LOCALTIMES_CSCAL=0,0, + SWATH_WIDTHS_CSCAL=0,0, + N_SWATHS_PARASOL=0, + SWATH_LOCALTIMES_PARASOL=0,0, + SWATH_WIDTHS_PARASOL=0,0, + N_SWATHS_ATLID=0, + SWATH_LOCALTIMES_ATLID=0,0, + SWATH_WIDTHS_ATLID=0,0, +/ diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt new file mode 100644 index 0000000000..c36b29004f --- /dev/null +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt @@ -0,0 +1,77 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.false., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? + Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=5001, ! 5001 for all FORUM channels, could limit just to those that overlap RRTMG channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.false., + channel_filepath='rttov_channel_input_IASI_subset.csv', ! Doesn't matter if producing all channels + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='rttov13pred101L/rtcoef_forum_1_forum_7gas.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_forum_1_forum.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.true., + CO_data=.false., + CO2_data=.true., + CH4_data=.true., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=7.19, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at + rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1550,0, ! Swath width (km) +/ diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt new file mode 100644 index 0000000000..73f56c519c --- /dev/null +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt @@ -0,0 +1,77 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.false., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? + Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=5001, ! 5001 for all FORUM channels, could limit just to those that overlap RRTMG channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.false., + channel_filepath='rttov_channel_input_IASI_subset.csv', ! Doesn't matter if producing all channels + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='rttov13pred101L/rtcoef_forum_1_forum_7gas.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_forum_1_forum.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.true., + CO_data=.false., + CO2_data=.true., + CH4_data=.true., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=21.58, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at + rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1550,0, ! Swath width (km) +/ diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt new file mode 100644 index 0000000000..873c862710 --- /dev/null +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt @@ -0,0 +1,77 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.false., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? + Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=5001, ! 5001 for all FORUM channels, could limit just to those that overlap RRTMG channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.false., + channel_filepath='rttov_channel_input_IASI_subset.csv', ! Doesn't matter if producing all channels + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='rttov13pred101L/rtcoef_forum_1_forum_7gas.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_forum_1_forum.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.true., + CO_data=.false., + CO2_data=.true., + CH4_data=.true., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=35.97, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at + rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1550,0, ! Swath width (km) +/ diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt new file mode 100644 index 0000000000..d56c6a7123 --- /dev/null +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt @@ -0,0 +1,77 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.false., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? + Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=5001, ! 5001 for all FORUM channels, could limit just to those that overlap RRTMG channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.false., + channel_filepath='rttov_channel_input_IASI_subset.csv', ! Doesn't matter if producing all channels + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='rttov13pred101L/rtcoef_forum_1_forum_7gas.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_forum_1_forum.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.true., + CO_data=.false., + CO2_data=.true., + CH4_data=.true., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=50.34, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at + rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1550,0, ! Swath width (km) +/ diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt new file mode 100644 index 0000000000..7d0575e6d2 --- /dev/null +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt @@ -0,0 +1,77 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.false., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? + Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=5001, ! 5001 for all FORUM channels, could limit just to those that overlap RRTMG channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.false., + channel_filepath='rttov_channel_input_IASI_subset.csv', ! Doesn't matter if producing all channels + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='rttov13pred101L/rtcoef_forum_1_forum_7gas.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_forum_1_forum.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.true., + CO_data=.false., + CO2_data=.true., + CH4_data=.true., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=64.71, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at + rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1550,0, ! Swath width (km) +/ diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt new file mode 100644 index 0000000000..0d814dbd80 --- /dev/null +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt @@ -0,0 +1,77 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.false., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? + Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=5001, ! 5001 for all FORUM channels, could limit just to those that overlap RRTMG channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.false., + channel_filepath='rttov_channel_input_IASI_subset.csv', ! Doesn't matter if producing all channels + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='rttov13pred101L/rtcoef_forum_1_forum_7gas.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_forum_1_forum.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.true., + CO_data=.false., + CO2_data=.true., + CH4_data=.true., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=78.98, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at + rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1550,0, ! Swath width (km) +/ diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt new file mode 100644 index 0000000000..2cee6cd06e --- /dev/null +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt @@ -0,0 +1,78 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.false., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? + Ldo_nlte_correction=.true., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.false., + channel_filepath='rttov_channel_input_AIRS.csv' +! channel_filepath='rttov_channel_input_IASI_subset.csv', + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='rttov13pred101L/rtcoef_metop_2_iasi_7gas.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.true., + CO_data=.false., + CO2_data=.true., + CH4_data=.true., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=7.19, ! Satellite Zenith Angle, was 76.2 + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at + rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1550,0, ! Swath width (km) +/ diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt new file mode 100644 index 0000000000..03bf66b00e --- /dev/null +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt @@ -0,0 +1,78 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.false., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? + Ldo_nlte_correction=.true., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.false., + channel_filepath='rttov_channel_input_AIRS.csv' +! channel_filepath='rttov_channel_input_IASI_subset.csv', + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='rttov13pred101L/rtcoef_metop_2_iasi_7gas.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.true., + CO_data=.false., + CO2_data=.true., + CH4_data=.true., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=21.58, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at + rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1550,0, ! Swath width (km) +/ diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt new file mode 100644 index 0000000000..27b2a6e728 --- /dev/null +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt @@ -0,0 +1,78 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.false., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? + Ldo_nlte_correction=.true., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.false., + channel_filepath='rttov_channel_input_AIRS.csv' +! channel_filepath='rttov_channel_input_IASI_subset.csv', + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='rttov13pred101L/rtcoef_metop_2_iasi_7gas.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.true., + CO_data=.false., + CO2_data=.true., + CH4_data=.true., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=35.97, ! Satellite Zenith Angle, was 76.2 + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at + rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1550,0, ! Swath width (km) +/ diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt new file mode 100644 index 0000000000..40204fd666 --- /dev/null +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt @@ -0,0 +1,78 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.false., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? + Ldo_nlte_correction=.true., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.false., + channel_filepath='rttov_channel_input_AIRS.csv' +! channel_filepath='rttov_channel_input_IASI_subset.csv', + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='rttov13pred101L/rtcoef_metop_2_iasi_7gas.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.true., + CO_data=.false., + CO2_data=.true., + CH4_data=.true., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=50.34, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at + rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1550,0, ! Swath width (km) +/ diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt new file mode 100644 index 0000000000..ff9144aa6a --- /dev/null +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt @@ -0,0 +1,78 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.false., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? + Ldo_nlte_correction=.true., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.false., + channel_filepath='rttov_channel_input_AIRS.csv' +! channel_filepath='rttov_channel_input_IASI_subset.csv', + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='rttov13pred101L/rtcoef_metop_2_iasi_7gas.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.true., + CO_data=.false., + CO2_data=.true., + CH4_data=.true., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=64.71, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at + rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1550,0, ! Swath width (km) +/ diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt new file mode 100644 index 0000000000..ca3fb681b0 --- /dev/null +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt @@ -0,0 +1,78 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.false., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? + Ldo_nlte_correction=.true., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.false., + channel_filepath='rttov_channel_input_AIRS.csv' +! channel_filepath='rttov_channel_input_IASI_subset.csv', + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='rttov13pred101L/rtcoef_metop_2_iasi_7gas.H5', + cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.true., + CO_data=.false., + CO2_data=.true., + CH4_data=.true., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=5.241e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=78.98, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at + rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1550,0, ! Swath width (km) +/ diff --git a/driver/run/rttov_channel_input_AIRSL1C_subset.csv b/driver/run/rttov_channel_input_AIRSL1C_subset.csv new file mode 100644 index 0000000000..766ddd33ed --- /dev/null +++ b/driver/run/rttov_channel_input_AIRSL1C_subset.csv @@ -0,0 +1,45 @@ + 41 ,1 ,0 + 54 ,1 ,0 + 72 ,1 ,0 + 202 ,1 ,0 + 234 ,1 ,0 + 294 ,1 ,0 + 336 ,1 ,0 + 378 ,1 ,0 + 485 ,1 ,0 + 489 ,1 ,0 + 572 ,1 ,0 + 794 ,1 ,0 + 960 ,1 ,0 + 961 ,1 ,0 + 967 ,1 ,0 +1055 ,1 ,0 +1075 ,1 ,0 +1089 ,1 ,0 +1110 ,1 ,0 +1130 ,1 ,0 +1158 ,1 ,0 +1325 ,1 ,0 +1511 ,1 ,0 +1520 ,1 ,0 +1697 ,1 ,0 +1723 ,1 ,0 +1805 ,1 ,0 +1852 ,1 ,0 +1862 ,1 ,0 +1866 ,1 ,0 +1937 ,1 ,0 +2088 ,1 ,0 +2138 ,1 ,0 +2164 ,1 ,0 +2165 ,1 ,0 +2166 ,1 ,0 +2176 ,1 ,0 +2186 ,1 ,0 +2383 ,1 ,0 +2411 ,1 ,0 +2588 ,1 ,0 +2592 ,1 ,0 +2600 ,1 ,0 +2606 ,1 ,0 +2620 ,1 ,0 \ No newline at end of file diff --git a/driver/run/rttov_channel_input_AIRS_subset.csv b/driver/run/rttov_channel_input_AIRS_subset.csv index f019e78967..3e56351ca9 100644 --- a/driver/run/rttov_channel_input_AIRS_subset.csv +++ b/driver/run/rttov_channel_input_AIRS_subset.csv @@ -1,26 +1,26 @@ -71,1,0 -127,1,0 -212,1,0 -214,1,0 -313,1,0 -468,1,0 -584,1,0 -842,1,0 -881,1,0 -909,1,0 -998,1,0 -1077,1,0 -1130,1,0 -1262,1,0 -1287,1,0 -1375,1,0 -1496,1,0 -1507,1,0 -1592,1,0 -1636,1,0 -1839,1,0 -1865,1,0 -1901,1,0 -2095,1,0 -2131,1,0 -2332,1,0 \ No newline at end of file + 71 ,1 ,0 + 127 ,1 ,0 + 212 ,1 ,0 + 214 ,1 ,0 + 313 ,1 ,0 + 468 ,1 ,0 + 584 ,1 ,0 + 842 ,1 ,0 + 881 ,1 ,0 + 909 ,1 ,0 + 998 ,1 ,0 +1077 ,1 ,0 +1130 ,1 ,0 +1262 ,1 ,0 +1287 ,1 ,0 +1375 ,1 ,0 +1496 ,1 ,0 +1507 ,1 ,0 +1592 ,1 ,0 +1636 ,1 ,0 +1839 ,1 ,0 +1865 ,1 ,0 +1901 ,1 ,0 +2095 ,1 ,0 +2131 ,1 ,0 +2332 ,1 ,0 \ No newline at end of file From 4c1d159596dbcceb87dce24d50166fbb46b5a99f Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Fri, 10 May 2024 14:09:41 -0600 Subject: [PATCH 119/159] Add CAM-like addition of over-model layer for RTTOV. --- src/simulator/cosp_rttov_interface_v13.F90 | 17 +- src/simulator/rttov/cosp_rttov_v13.F90 | 238 +++++++++++---------- 2 files changed, 138 insertions(+), 117 deletions(-) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 8af811d89a..d2d0aa5a6c 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -101,6 +101,7 @@ MODULE MOD_COSP_RTTOV_INTERFACE nchan_out, & nchannels_rec, & rttov_Nlocaltime, & + rttov_extendatmos, & nprof real(wp) :: & CO2_mr, & @@ -257,7 +258,8 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & ! JKS for orbital swathing integer(kind=jpim) :: & - rttov_Nlocaltime ! Number of orbits + rttov_Nlocaltime, & ! Number of orbits + rttov_extendatmos real(wp),dimension(20) :: & ! Reasonable but arbitrary limit at 10 local time orbits rttov_localtime, & ! RTTOV subsetting by local time in hours [0,24] rttov_localtime_width ! Width of satellite swath (km). @@ -293,6 +295,8 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & ozone_data = .false. clw_data = .false. user_tracegas_input = .false. + rttov_Nlocaltime = 0 ! Default: zero swath masking + rttov_extendatmos = 0 ! 0: do not extend above supplied pressure levels. 1: Simply top layer. 2: Not yet implemented. ! Read RTTOV namelist fields namelist/RTTOV_INPUT/Lrttov_bt,Lrttov_rad,Lrttov_refl,Lrttov_cld, & ! Logicals for RTTOV configuration @@ -308,7 +312,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & CO2_mr,CH4_mr,CO_mr,N2O_mr,SO2_mr, & ! Mixing ratios ipcbnd,ipcreg,npcscores, & ! PC-RTTOV config values rttov_nthreads,rttov_ZenAng,rttov_Nlocaltime, & - rttov_localtime,rttov_localtime_width + rttov_localtime,rttov_localtime_width,rttov_extendatmos !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Read in namelists @@ -345,7 +349,10 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & rttov_config%rttov_Nlocaltime = rttov_Nlocaltime rttov_config%rttov_localtime(:) = rttov_localtime(1:rttov_Nlocaltime) rttov_config%rttov_localtime_width(:) = rttov_localtime_width(1:rttov_Nlocaltime) - + + ! Extend atmosphere setting. If user-supplied values end too low, channels sounding the upper atmosphere will be bad. + rttov_config%rttov_extendatmos = rttov_extendatmos + ! Set logicals for RTTOV config rttov_config%Lrttov_bt = Lrttov_bt rttov_config%Lrttov_rad = Lrttov_rad @@ -772,6 +779,7 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig, rttovConfig % nchanprof, & rttovConfig % nprof, & rttovConfig % swath_mask, & + rttovConfig % rttov_extendatmos, & transmission, & radiance, & calcemis, & @@ -802,6 +810,7 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig, rttovConfig % ZenAng, & rttovConfig % nprof, & rttovConfig % swath_mask, & + rttovConfig % rttov_extendatmos, & verbose) call cpu_time(driver_time(3)) @@ -932,6 +941,7 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig, rttovConfig % nprof, & rttovConfig % iChannel_out, & rttovConfig % swath_mask, & + rttovConfig % rttov_extendatmos, & transmission, & radiance, & calcemis, & @@ -961,6 +971,7 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig, rttovConfig % ZenAng, & rttovConfig % nprof, & rttovConfig % swath_mask, & + rttovConfig % rttov_extendatmos, & verbose) call cpu_time(driver_time(3)) call cosp_pc_rttov_setup_emissivity(calcemis, & diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 8575e46a41..c906d8a13d 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -246,6 +246,7 @@ end subroutine cosp_rttov_swath subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs, & inst_profiles, inst_iChannel, inst_chanprof, & inst_nchanprof,inst_nprof,inst_swath_mask, & + inst_extend_atmos, & inst_transmission,inst_radiance,inst_calcemis, & inst_emissivity,inst_calcrefl,inst_reflectance, & debug) @@ -270,6 +271,8 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs, inst_nprof ! Now accounting for orbits logical(jplm),dimension(rttovIN % nPoints),intent(inout) :: & inst_swath_mask + integer(kind=jpim),intent(in) :: & + inst_extend_atmos type(rttov_transmission),intent(out) :: & inst_transmission type(rttov_radiance),intent(out) :: & @@ -287,12 +290,16 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs, !---- Local variables ----! ! Loop variables - integer(kind=jpim) :: j, jch, nch + integer(kind=jpim) :: j, jch, nch, nlevels_rttov logical :: verbose = .false. if (present(debug)) verbose = debug + + if (inst_extend_atmos .eq. 0) nlevels_rttov = rttovIN%nLevels+1 ! Just use pressure levels that are supplied. + if (inst_extend_atmos .eq. 1) nlevels_rttov = rttovIN%nLevels+2 ! Simplying extend the atmosphere with a single top layer. CAM6-like. + ! To-do: implement a SARTA-like interpolation to a standard atmosphere. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 3. Allocate RTTOV input and output structures @@ -315,8 +322,7 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs, 1_jpim, & ! 1 => allocate inst_nprof, & inst_nchanprof, & - rttovIN%nLevels+1, & ! "levels" means interfaces, not layers - ! rttovIN%nLevels, & + nlevels_rttov, & ! "levels" means interfaces, not layers inst_chanprof, & inst_opts, & inst_profiles, & @@ -355,12 +361,12 @@ end subroutine cosp_rttov_allocate ! 4. Build the list of profile/channel indices in chanprof ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, & - inst_coefs,inst_opts,inst_profiles, & - inst_nchannels_rec,inst_iChannel_in,inst_chanprof, & - inst_nchanprof,inst_nprof,inst_iChannel_out, & - inst_swath_mask,inst_transmission,inst_radiance, & - inst_calcemis,inst_emissivity,inst_pccomp, & + subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, & + inst_coefs,inst_opts,inst_profiles, & + inst_nchannels_rec,inst_iChannel_in,inst_chanprof, & + inst_nchanprof,inst_nprof,inst_iChannel_out, & + inst_swath_mask,inst_extend_atmos,inst_transmission, & + inst_radiance, inst_calcemis,inst_emissivity,inst_pccomp, & inst_predictindex,debug) type(rttov_in),intent(in) :: & @@ -387,6 +393,8 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, inst_iChannel_out(:) ! Passing out the channel indices logical(jplm),dimension(rttovIN % nPoints),intent(inout) :: & inst_swath_mask + integer(kind=jpim),intent(in) :: & + inst_extend_atmos type(rttov_transmission),intent(out) :: & inst_transmission type(rttov_radiance),intent(out) :: & @@ -403,7 +411,7 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, debug ! Loop variables - integer(kind=jpim) :: j, jch, nch + integer(kind=jpim) :: j, jch, nch, nlevels_rttov integer(kind=jpim) :: lo, hi ! Local variables @@ -413,6 +421,10 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, if (present(debug)) verbose = debug + if (inst_extend_atmos .eq. 0) nlevels_rttov = rttovIN%nLevels+1 ! Just use pressure levels that are supplied. + if (inst_extend_atmos .eq. 1) nlevels_rttov = rttovIN%nLevels+2 ! Simplying extend the atmosphere with a single top layer. CAM6-like. + ! To-do: implement a SARTA-like interpolation to a standard atmosphere. + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 3. Allocate RTTOV input and output structures ! ------------------------------------------------------ @@ -428,11 +440,11 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, inst_npred_pc = SIZE(inst_predictindex) inst_nchanprof = inst_npred_pc * inst_nprof ! Size of chanprof array is total number of predictors over all profiles - if (verbose) then - print*,'inst_nprof: ',inst_nprof - print*,'inst_nChannels_rec: ',inst_nChannels_rec - print*,'inst_nchanprof: ',inst_nchanprof - end if + ! if (verbose) then + ! print*,'inst_nprof: ',inst_nprof + ! print*,'inst_nChannels_rec: ',inst_nChannels_rec + ! print*,'inst_nchanprof: ',inst_nchanprof + ! end if ! Determine the number of reconstructed radiances per profile (nchannels_rec) if (allocated(inst_iChannel_out)) deallocate(inst_iChannel_out) ! Reset because this variable is internal and used by multiple instruments. @@ -464,8 +476,7 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, 1_jpim, & ! 1 => allocate inst_nprof, & inst_nchanprof, & - rttovIN%nLevels+1, & ! "levels" means interfaces, not layers - ! rttovIN%nLevels, & + nlevels_rttov, & ! "levels" means interfaces, not layers inst_chanprof, & inst_opts, & inst_profiles, & @@ -523,6 +534,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & inst_zenang, & inst_nprof, & inst_swath_mask,& + inst_extend_atmos,& debug) type(rttov_in),intent(in) :: & @@ -548,14 +560,16 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & inst_so2_mr, & inst_zenang integer(kind=jpim),intent(in) :: & - inst_nprof + inst_nprof, & + inst_extend_atmos logical(kind=jplm),dimension(rttovIN % nPoints),intent(in) :: & inst_swath_mask logical,intent(in),optional :: & debug ! Loop variables - integer(kind=jpim) :: i, j, k ! Use i to iterate over profile, j for swath_mask, k for vertical interpolation + integer(kind=jpim) :: i, j, k, kk ! Use i to iterate over profile, j for swath_mask, k for vertical interpolation, kk to move from profile vertical coord to rttovIN coord + integer(kind=jpim) :: modeltop_index logical :: verbose = .false. if (present(debug)) verbose = debug @@ -577,56 +591,36 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & if (inst_swath_mask(i)) then ! only added masked columns to profiles j = j + 1 ! Increment first - - ! Initialize column pressure, temperature, and humidity - inst_profiles(j)%p(:) = rttovIN%ph(i, :) * 1e-2 ! convert Pa to hPa. Pressure on levels. - if (inst_profiles(j)%p(1) .le. 0) inst_profiles(j)%p(1) = 1 ! If the model top is set to zero make it one (like the COSPv2 driver) - ! inst_profiles(j)%p(:) = rttovIN%p(i, :) * 1e-2 ! convert Pa to hPa. Pressure on layers. Wrong - ! Interpolate q and t to levels! + ! To imitate CAM6-RRTMG, set a model top index. If inst_extend_atmos==1 then just increment that index by one and retroactively apply it to the top layer. + ! This will be the same index that the vertical interpolation operates over so it will fix that too! + + ! top layer thickness + if (inst_extend_atmos == 0) then + inst_profiles(j)%p(:) = rttovIN%ph(i, :) * 1e-2 ! convert Pa to hPa. Pressure on levels. + if (inst_profiles(j)%p(1) .le. 0) inst_profiles(j)%p(1) = 2.25 ! If the model top is set to zero (like the COSPv2 driver and CAM6) make it 2.25mb. CAM-like correction + modeltop_index = 1 + else if (inst_extend_atmos==1) then + modeltop_index = 2 + inst_profiles(j)%p(1) = 1e-4 + inst_profiles(j)%p(2) = 2.25 + inst_profiles(j)%p(3:inst_profiles(j)%nlevels) = rttovIN%ph(i, 2:rttovIN%nlevels) * 1e-2 ! JKS confirm correct indices. + end if ! Handle the top and bottom levels separately. - ! Top - call interpolate_logp(100*inst_profiles(j)%p(1),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%q(i,1),rttovIN%q(i,2),inst_profiles(j)%q(1)) - call interpolate_logp(100*inst_profiles(j)%p(1),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%t(i,1),rttovIN%t(i,2),inst_profiles(j)%t(1)) + ! Top interface supplied by the input. + call interpolate_logp(100*inst_profiles(j)%p(modeltop_index),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%q(i,1),rttovIN%q(i,2),inst_profiles(j)%q(modeltop_index)) + call interpolate_logp(100*inst_profiles(j)%p(modeltop_index),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%t(i,1),rttovIN%t(i,2),inst_profiles(j)%t(modeltop_index)) ! Bottom - call interpolate_logp(100*inst_profiles(j)%p(rttovIN%nlevels+1),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%q(i,rttovIN%nlevels-1),rttovIN%q(i,rttovIN%nlevels),inst_profiles(j)%q(rttovIN%nlevels+1)) - call interpolate_logp(100*inst_profiles(j)%p(rttovIN%nlevels+1),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%t(i,rttovIN%nlevels-1),rttovIN%t(i,rttovIN%nlevels),inst_profiles(j)%t(rttovIN%nlevels+1)) - - ! if (verbose) then - ! print*,'k: ',k - ! print*,'inst_profiles(j)%p(1): ',inst_profiles(j)%p(1) - ! print*,'rttovIN%p(i,1): ',rttovIN%p(i,1) - ! print*,'rttovIN%p(i,2): ',rttovIN%p(i,2) - ! print*,'rttovIN%q(i,1): ',rttovIN%q(i,1) - ! print*,'rttovIN%q(i,2): ',rttovIN%q(i,2) - ! print*,'inst_profiles(j)%q(1): ',inst_profiles(j)%q(1) - ! end if - - do k=2,rttovIN%nlevels ! I should really rename the RTTOV one to nlayers!! - call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,k-1),rttovIN%p(i,k),rttovIN%q(i,k-1),rttovIN%q(i,k),inst_profiles(j)%q(k)) - call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,k-1),rttovIN%p(i,k),rttovIN%t(i,k-1),rttovIN%t(i,k),inst_profiles(j)%t(k)) - - ! if (verbose) then - ! print*,'k: ',k - ! print*,'inst_profiles(j)%p(k): ',inst_profiles(j)%p(k) - ! print*,'rttovIN%p(i,k-1): ',rttovIN%p(i,k-1) - ! print*,'rttovIN%p(i,k): ',rttovIN%p(i,k) - ! print*,'rttovIN%q(i,k-1): ',rttovIN%q(i,k-1) - ! print*,'rttovIN%q(i,k): ',rttovIN%q(i,k) - ! print*,'inst_profiles(j)%q(k): ',inst_profiles(j)%q(k) - ! end if + call interpolate_logp(100*inst_profiles(j)%p(inst_profiles(j)%nlevels),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%q(i,rttovIN%nlevels-1),rttovIN%q(i,rttovIN%nlevels),inst_profiles(j)%q(inst_profiles(j)%nlevels)) + call interpolate_logp(100*inst_profiles(j)%p(inst_profiles(j)%nlevels),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%t(i,rttovIN%nlevels-1),rttovIN%t(i,rttovIN%nlevels),inst_profiles(j)%t(inst_profiles(j)%nlevels)) + do k=modeltop_index+1,inst_profiles(j)%nlevels-1 ! Iterate from the layer directly below the first supplied model layer (top of model) to the layer above the last supplied model layer (surface) + kk = k + 1 - modeltop_index + call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,kk-1),rttovIN%p(i,kk),rttovIN%q(i,kk-1),rttovIN%q(i,kk),inst_profiles(j)%q(k)) + call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,kk-1),rttovIN%p(i,kk),rttovIN%t(i,kk-1),rttovIN%t(i,kk),inst_profiles(j)%t(k)) end do - ! inst_profiles(j)%t(:) = rttovIN%t(i, :) ! Temperature on levels. - ! inst_profiles(j)%q(:) = rttovIN%q(i, :) ! Water vapor concentration on levels. - - ! q coefficient limit is 0.1e-10 - where(inst_profiles(j)%q(:) < 0.1e-10) - inst_profiles(j)%q(:) = 0.11e-10 - end where - ! Trace gas concentrations on levels (not layers!) ! Initialize trace gas concentrations from user input. if (Luser_tracegas) then @@ -637,64 +631,80 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & if (Ldo_so2) inst_profiles(j)%so2(:) = inst_so2_mr ! if (Ldo_o3) inst_profiles(j)%o3(:) = rttovIN%o3(i, :) if (Ldo_o3) then ! no O3 user input set up - call interpolate_logp(100*inst_profiles(j)%p(1),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%o3(i,1),rttovIN%o3(i,2),inst_profiles(j)%o3(1)) - call interpolate_logp(100*inst_profiles(j)%p(rttovIN%nlevels+1),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%o3(i,rttovIN%nlevels-1),rttovIN%o3(i,rttovIN%nlevels),inst_profiles(j)%o3(rttovIN%nlevels+1)) - do k=2,rttovIN%nlevels - call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,k-1),rttovIN%p(i,k),rttovIN%o3(i,k-1),rttovIN%o3(i,k),inst_profiles(j)%o3(k)) + call interpolate_logp(100*inst_profiles(j)%p(modeltop_index),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%o3(i,1),rttovIN%o3(i,2),inst_profiles(j)%o3(modeltop_index)) + call interpolate_logp(100*inst_profiles(j)%p(inst_profiles(j)%nlevels),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%o3(i,rttovIN%nlevels-1),rttovIN%o3(i,rttovIN%nlevels),inst_profiles(j)%o3(inst_profiles(j)%nlevels)) + do k=modeltop_index+1,inst_profiles(j)%nlevels-1 + kk = k + 1 - modeltop_index + call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,kk-1),rttovIN%p(i,kk),rttovIN%o3(i,kk-1),rttovIN%o3(i,kk),inst_profiles(j)%o3(k)) end do end if else ! For when trace gas columns are supplied by the model. Units must match (kg/kg over moist air) and concentration must be supplied on model levels (not layers), requiring interpolation. if (Ldo_co2) then ! CO2 - call interpolate_logp(100*inst_profiles(j)%p(1),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%co2(i,1),rttovIN%co2(i,2),inst_profiles(j)%co2(1)) - call interpolate_logp(100*inst_profiles(j)%p(rttovIN%nlevels+1),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%co2(i,rttovIN%nlevels-1),rttovIN%co2(i,rttovIN%nlevels),inst_profiles(j)%co2(rttovIN%nlevels+1)) - do k=2,rttovIN%nlevels - call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,k-1),rttovIN%p(i,k),rttovIN%co2(i,k-1),rttovIN%co2(i,k),inst_profiles(j)%co2(k)) + call interpolate_logp(100*inst_profiles(j)%p(modeltop_index),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%co2(i,1),rttovIN%co2(i,2),inst_profiles(j)%co2(modeltop_index)) + call interpolate_logp(100*inst_profiles(j)%p(inst_profiles(j)%nlevels),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%co2(i,rttovIN%nlevels-1),rttovIN%co2(i,rttovIN%nlevels),inst_profiles(j)%co2(inst_profiles(j)%nlevels)) + do k=modeltop_index+1,inst_profiles(j)%nlevels-1 + kk = k + 1 - modeltop_index + call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,kk-1),rttovIN%p(i,kk),rttovIN%co2(i,kk-1),rttovIN%co2(i,kk),inst_profiles(j)%co2(k)) end do end if if (Ldo_n2o) then ! N2O - call interpolate_logp(100*inst_profiles(j)%p(1),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%n2o(i,1),rttovIN%n2o(i,2),inst_profiles(j)%n2o(1)) - call interpolate_logp(100*inst_profiles(j)%p(rttovIN%nlevels+1),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%n2o(i,rttovIN%nlevels-1),rttovIN%n2o(i,rttovIN%nlevels),inst_profiles(j)%n2o(rttovIN%nlevels+1)) - do k=2,rttovIN%nlevels - call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,k-1),rttovIN%p(i,k),rttovIN%n2o(i,k-1),rttovIN%n2o(i,k),inst_profiles(j)%n2o(k)) + call interpolate_logp(100*inst_profiles(j)%p(modeltop_index),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%n2o(i,1),rttovIN%n2o(i,2),inst_profiles(j)%n2o(modeltop_index)) + call interpolate_logp(100*inst_profiles(j)%p(inst_profiles(j)%nlevels),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%n2o(i,rttovIN%nlevels-1),rttovIN%n2o(i,rttovIN%nlevels),inst_profiles(j)%n2o(inst_profiles(j)%nlevels)) + do k=modeltop_index+1,inst_profiles(j)%nlevels-1 + kk = k + 1 - modeltop_index + call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,kk-1),rttovIN%p(i,kk),rttovIN%n2o(i,kk-1),rttovIN%n2o(i,kk),inst_profiles(j)%n2o(k)) end do end if if (Ldo_co) then ! CO - call interpolate_logp(100*inst_profiles(j)%p(1),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%co(i,1),rttovIN%co(i,2),inst_profiles(j)%co(1)) - call interpolate_logp(100*inst_profiles(j)%p(rttovIN%nlevels+1),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%co(i,rttovIN%nlevels-1),rttovIN%co(i,rttovIN%nlevels),inst_profiles(j)%co(rttovIN%nlevels+1)) - do k=2,rttovIN%nlevels - call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,k-1),rttovIN%p(i,k),rttovIN%co(i,k-1),rttovIN%co(i,k),inst_profiles(j)%co(k)) + call interpolate_logp(100*inst_profiles(j)%p(modeltop_index),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%co(i,1),rttovIN%co(i,2),inst_profiles(j)%co(modeltop_index)) + call interpolate_logp(100*inst_profiles(j)%p(inst_profiles(j)%nlevels),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%co(i,rttovIN%nlevels-1),rttovIN%co(i,rttovIN%nlevels),inst_profiles(j)%co(inst_profiles(j)%nlevels)) + do k=modeltop_index+1,inst_profiles(j)%nlevels-1 + kk = k + 1 - modeltop_index + call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,kk-1),rttovIN%p(i,kk),rttovIN%co(i,kk-1),rttovIN%co(i,kk),inst_profiles(j)%co(k)) end do end if if (Ldo_ch4) then ! CH4 - call interpolate_logp(100*inst_profiles(j)%p(1),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%ch4(i,1),rttovIN%ch4(i,2),inst_profiles(j)%ch4(1)) - call interpolate_logp(100*inst_profiles(j)%p(rttovIN%nlevels+1),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%ch4(i,rttovIN%nlevels-1),rttovIN%ch4(i,rttovIN%nlevels),inst_profiles(j)%ch4(rttovIN%nlevels+1)) - do k=2,rttovIN%nlevels - call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,k-1),rttovIN%p(i,k),rttovIN%ch4(i,k-1),rttovIN%ch4(i,k),inst_profiles(j)%ch4(k)) + call interpolate_logp(100*inst_profiles(j)%p(modeltop_index),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%ch4(i,1),rttovIN%ch4(i,2),inst_profiles(j)%ch4(modeltop_index)) + call interpolate_logp(100*inst_profiles(j)%p(inst_profiles(j)%nlevels),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%ch4(i,rttovIN%nlevels-1),rttovIN%ch4(i,rttovIN%nlevels),inst_profiles(j)%ch4(inst_profiles(j)%nlevels)) + do k=modeltop_index+1,inst_profiles(j)%nlevels-1 + kk = k + 1 - modeltop_index + call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,kk-1),rttovIN%p(i,kk),rttovIN%ch4(i,kk-1),rttovIN%ch4(i,kk),inst_profiles(j)%ch4(k)) end do end if if (Ldo_so2) then ! SO2 - call interpolate_logp(100*inst_profiles(j)%p(1),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%so2(i,1),rttovIN%so2(i,2),inst_profiles(j)%so2(1)) - call interpolate_logp(100*inst_profiles(j)%p(rttovIN%nlevels+1),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%so2(i,rttovIN%nlevels-1),rttovIN%so2(i,rttovIN%nlevels),inst_profiles(j)%so2(rttovIN%nlevels+1)) - do k=2,rttovIN%nlevels - call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,k-1),rttovIN%p(i,k),rttovIN%so2(i,k-1),rttovIN%so2(i,k),inst_profiles(j)%so2(k)) + call interpolate_logp(100*inst_profiles(j)%p(modeltop_index),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%so2(i,1),rttovIN%so2(i,2),inst_profiles(j)%so2(modeltop_index)) + call interpolate_logp(100*inst_profiles(j)%p(inst_profiles(j)%nlevels),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%so2(i,rttovIN%nlevels-1),rttovIN%so2(i,rttovIN%nlevels),inst_profiles(j)%so2(inst_profiles(j)%nlevels)) + do k=modeltop_index+1,inst_profiles(j)%nlevels-1 + kk = k + 1 - modeltop_index + call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,kk-1),rttovIN%p(i,kk),rttovIN%so2(i,kk-1),rttovIN%so2(i,kk),inst_profiles(j)%so2(k)) end do end if if (Ldo_o3) then ! Ozone - call interpolate_logp(100*inst_profiles(j)%p(1),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%o3(i,1),rttovIN%o3(i,2),inst_profiles(j)%o3(1)) - call interpolate_logp(100*inst_profiles(j)%p(rttovIN%nlevels+1),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%o3(i,rttovIN%nlevels-1),rttovIN%o3(i,rttovIN%nlevels),inst_profiles(j)%o3(rttovIN%nlevels+1)) - do k=2,rttovIN%nlevels - call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,k-1),rttovIN%p(i,k),rttovIN%o3(i,k-1),rttovIN%o3(i,k),inst_profiles(j)%o3(k)) + call interpolate_logp(100*inst_profiles(j)%p(modeltop_index),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%o3(i,1),rttovIN%o3(i,2),inst_profiles(j)%o3(modeltop_index)) + call interpolate_logp(100*inst_profiles(j)%p(inst_profiles(j)%nlevels),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%o3(i,rttovIN%nlevels-1),rttovIN%o3(i,rttovIN%nlevels),inst_profiles(j)%o3(inst_profiles(j)%nlevels)) + do k=modeltop_index+1,inst_profiles(j)%nlevels-1 + kk = k + 1 - modeltop_index + call interpolate_logp(100*inst_profiles(j)%p(k),rttovIN%p(i,kk-1),rttovIN%p(i,kk),rttovIN%o3(i,kk-1),rttovIN%o3(i,kk),inst_profiles(j)%o3(k)) end do end if + end if - ! Original non-interpolated code - ! if (Ldo_co2) inst_profiles(j)%co2(:) = rttovIN%co2(i,:) - ! if (Ldo_n2o) inst_profiles(j)%n2o(:) = rttovIN%n2o(i,:) - ! if (Ldo_co) inst_profiles(j)%co(:) = rttovIN%co(i,:) - ! if (Ldo_ch4) inst_profiles(j)%ch4(:) = rttovIN%ch4(i,:) - ! if (Ldo_so2) inst_profiles(j)%so2(:) = rttovIN%so2(i,:) - ! if (Ldo_o3) inst_profiles(j)%o3(:) = rttovIN%o3(i, :) + ! If adding CAM-like model top layer, copy temperature and trace gas values to the new top level. + if (inst_extend_atmos==1) then + inst_profiles(j)%t(1) = inst_profiles(j)%t(modeltop_index) + inst_profiles(j)%q(1) = inst_profiles(j)%q(modeltop_index) + if (Ldo_co2) inst_profiles(j)%co2(1) = inst_profiles(j)%co2(modeltop_index) + if (Ldo_n2o) inst_profiles(j)%n2o(1) = inst_profiles(j)%n2o(modeltop_index) + if (Ldo_co) inst_profiles(j)%co(1) = inst_profiles(j)%co(modeltop_index) + if (Ldo_ch4) inst_profiles(j)%ch4(1) = inst_profiles(j)%ch4(modeltop_index) + if (Ldo_so2) inst_profiles(j)%so2(1) = inst_profiles(j)%so2(modeltop_index) + if (Ldo_o3) inst_profiles(j)%o3(1) = inst_profiles(j)%o3(modeltop_index) end if + + ! q coefficient limit is 0.1e-10 + where(inst_profiles(j)%q(:) < 0.1e-10) + inst_profiles(j)%q(:) = 0.11e-10 + end where ! 2m parameters inst_profiles(j)%s2m%p = rttovIN%p_surf(i) * 1e-2 ! convert Pa to hPa @@ -783,12 +793,12 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & j = j + 1 ! Increment profile counter ! Cloud scheme stuff. Values are on layers, not levels like the gas concentrations. - inst_profiles(j)%cfrac(:) = rttovIN%tca(i,:) ! Cloud fraction for each layer - inst_profiles(j)%cloud(1,:) = rttovIN%cldLiq(i,:) ! Cloud water mixing ratio (all in the first type for Deff) - inst_profiles(j)%cloud(6,:) = rttovIN%cldIce(i,:) ! Cloud ice mixing ratio (1 type). See pg 74. + inst_profiles(j)%cfrac(modeltop_index:inst_profiles(j)%nlevels) = rttovIN%tca(i,:) ! Cloud fraction for each layer + inst_profiles(j)%cloud(1,modeltop_index:inst_profiles(j)%nlevels) = rttovIN%cldLiq(i,:) ! Cloud water mixing ratio (all in the first type for Deff) + inst_profiles(j)%cloud(6,modeltop_index:inst_profiles(j)%nlevels) = rttovIN%cldIce(i,:) ! Cloud ice mixing ratio (1 type). See pg 74. - inst_profiles(j)%clwde = rttovIN%DeffLiq(i,:) ! Cloud water effective diameter (um) - inst_profiles(j)%icede = rttovIN%DeffIce(i,:) ! Cloud ice effective diameter (um) + inst_profiles(j)%clwde(modeltop_index:inst_profiles(j)%nlevels) = rttovIN%DeffLiq(i,:) ! Cloud water effective diameter (um) + inst_profiles(j)%icede(modeltop_index:inst_profiles(j)%nlevels) = rttovIN%DeffIce(i,:) ! Cloud ice effective diameter (um) ! Example UKMO input has effective radii for multiple cloud types, making identification of a single ! liquid droplet or ice crystal effective diameter difficult. @@ -855,8 +865,8 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & end if ! if (verbose) then - ! print*,'inst_profiles(1)%nlevels: ',inst_profiles(1)%nlevels - ! print*,'inst_profiles(1)%nlayers: ',inst_profiles(1)%nlayers + ! print*,'inst_profiles(1)%nlevels: ',inst_profiles(1)%nlevels + ! print*,'inst_profiles(1)%nlayers: ',inst_profiles(1)%nlayers ! print*,'shape(rttovIN%t): ', shape(rttovIN%t) ! print*,'shape(rttovIN%p): ', shape(rttovIN%p) ! print*,'shape(rttovIN%ph): ', shape(rttovIN%ph) @@ -865,16 +875,16 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & ! print*,'shape(inst_profiles(1)%q(:)): ',shape(inst_profiles(1)%q(:)) ! print*,'shape(inst_profiles(1)%cfrac(:)): ',shape(inst_profiles(1)%cfrac(:)) ! print*,'shape(rttovIN%tca(1,:)): ',shape(rttovIN%tca(1,:)) - ! print*,'rttovIN%ph(1,:): ', rttovIN%ph(1,:) - ! print*,'rttovIN%p(1,:): ', rttovIN%p(1,:) - ! print*,'rttovIN%t(1,:): ', rttovIN%t(1,:) - ! print*,'rttovIN%q(1,:): ', rttovIN%q(1,:) - ! print*,'rttovIN%o3(1,:): ', rttovIN%o3(1,:) - ! print*,'inst_profiles(1)%p(:): ',inst_profiles(1)%p(:) - ! print*,'inst_profiles(1)%t(:): ',inst_profiles(1)%t(:) - ! print*,'inst_profiles(1)%q(:): ',inst_profiles(1)%q(:) - ! print*,'inst_profiles(1)%o3(:): ',inst_profiles(1)%o3(:) - ! print*,'inst_profiles(1)%cfrac: ',inst_profiles(1)%cfrac + ! print*,'rttovIN%ph(1,:): ', rttovIN%ph(1,:) + ! print*,'rttovIN%p(1,:): ', rttovIN%p(1,:) + ! print*,'rttovIN%t(1,:): ', rttovIN%t(1,:) + ! print*,'rttovIN%q(1,:): ', rttovIN%q(1,:) + ! print*,'rttovIN%o3(1,:): ', rttovIN%o3(1,:) + ! print*,'inst_profiles(1)%p(:): ',inst_profiles(1)%p(:) + ! print*,'inst_profiles(1)%t(:): ',inst_profiles(1)%t(:) + ! print*,'inst_profiles(1)%q(:): ',inst_profiles(1)%q(:) + ! print*,'inst_profiles(1)%o3(:): ',inst_profiles(1)%o3(:) + ! print*,'inst_profiles(1)%cfrac: ',inst_profiles(1)%cfrac ! print*,'inst_profiles(1)%co2(:): ',inst_profiles(1)%co2(:) ! print*,'inst_profiles(1)%skin%t: ',inst_profiles(1)%skin%t ! print*,'inst_profiles(1)%s2m%t: ',inst_profiles(1)%s2m%t From 52eeeddf8f32b402fa68725b638d145773d22784 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Sat, 11 May 2024 18:09:51 -0600 Subject: [PATCH 120/159] Correction to cloud fields by layer instead of level. --- src/simulator/rttov/cosp_rttov_v13.F90 | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index c906d8a13d..e23abfcd4a 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -588,7 +588,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & ! Iterate over all columns j = 0 ! Initialize input do i = 1, rttovIN%nPoints - + if (i .gt. rttovIN%nPoints) exit if (inst_swath_mask(i)) then ! only added masked columns to profiles j = j + 1 ! Increment first @@ -788,17 +788,17 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & j = 0 ! Initialize input do i = 1,rttovIN%nPoints - + if (i .g.t rttovIN%nPoints) exit if (inst_swath_mask(i)) then ! only added masked columns to profiles j = j + 1 ! Increment profile counter ! Cloud scheme stuff. Values are on layers, not levels like the gas concentrations. - inst_profiles(j)%cfrac(modeltop_index:inst_profiles(j)%nlevels) = rttovIN%tca(i,:) ! Cloud fraction for each layer - inst_profiles(j)%cloud(1,modeltop_index:inst_profiles(j)%nlevels) = rttovIN%cldLiq(i,:) ! Cloud water mixing ratio (all in the first type for Deff) - inst_profiles(j)%cloud(6,modeltop_index:inst_profiles(j)%nlevels) = rttovIN%cldIce(i,:) ! Cloud ice mixing ratio (1 type). See pg 74. + inst_profiles(j)%cfrac(modeltop_index:inst_profiles(j)%nlayers) = rttovIN%tca(i,:) ! Cloud fraction for each layer + inst_profiles(j)%cloud(1,modeltop_index:inst_profiles(j)%nlayers) = rttovIN%cldLiq(i,:) ! Cloud water mixing ratio (all in the first type for Deff) + inst_profiles(j)%cloud(6,modeltop_index:inst_profiles(j)%nlayers) = rttovIN%cldIce(i,:) ! Cloud ice mixing ratio (1 type). See pg 74. - inst_profiles(j)%clwde(modeltop_index:inst_profiles(j)%nlevels) = rttovIN%DeffLiq(i,:) ! Cloud water effective diameter (um) - inst_profiles(j)%icede(modeltop_index:inst_profiles(j)%nlevels) = rttovIN%DeffIce(i,:) ! Cloud ice effective diameter (um) + inst_profiles(j)%clwde(modeltop_index:inst_profiles(j)%nlayers) = rttovIN%DeffLiq(i,:) ! Cloud water effective diameter (um) + inst_profiles(j)%icede(modeltop_index:inst_profiles(j)%nlayers) = rttovIN%DeffIce(i,:) ! Cloud ice effective diameter (um) ! Example UKMO input has effective radii for multiple cloud types, making identification of a single ! liquid droplet or ice crystal effective diameter difficult. @@ -832,6 +832,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & ! Read in aerosol profiles ! j = 0 ! Initialize input ! do i = 1,rttovIN%nPoints +! if (i .gt. rttovIN%nPoints) ! if (inst_swath_mask(i)) then ! only added masked columns to profiles ! j = j + 1 ! Increment profile counter ! inst_profiles(j)%aerosols(naertyp,nlayers) = rttovIN%aerosols ! Aerosols in different modes (see User Guide pg 80) @@ -845,6 +846,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & ! Read in aerosol profiles j = 0 ! Initialize input do i = 1,rttovIN%nPoints + if (i .gt. rttovIN%nPoints) exit if (inst_swath_mask(i)) then ! only added masked columns to profiles j = j + 1 ! Increment profile counter inst_profiles(j)%date(:) = rttovIN%rttov_date(i,:) @@ -1222,6 +1224,7 @@ subroutine cosp_rttov_save_output(nPoints,inst_nchan_out,inst_swath_mask, & else ! If swathing is occurring, assign the outputs appropriately j = 0 do i=1,nPoints + if (i .gt. nPoints) exit if (inst_swath_mask(i)) then ! only added masked columns to profiles if (Lrttov_bt) then bt_total(i, 1:inst_nchan_out) = inst_radiance%bt(1 + (j * inst_nchan_out):(j+1) * inst_nchan_out) @@ -1313,6 +1316,7 @@ subroutine cosp_pc_rttov_save_output(nPoints, & else ! If swathing is occurring, assign the outputs appropriately j = 0 do i=1,nPoints + if (i .gt. nPoints) exit if (inst_swath_mask(i)) then ! only added masked columns to profiles if (Lrttov_bt) then bt_clear(i, 1:inst_nchannels_rec) = inst_pccomp%bt_pccomp(1 + (j * inst_nchannels_rec):(j+1) * inst_nchannels_rec) From 802d0cf0afa23f01802bdeaa52492259110fac43 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Sat, 11 May 2024 19:07:04 -0600 Subject: [PATCH 121/159] Syntax correction and namelist updates. --- .../cosp2_input_AIRS_L1C_validation_nl.txt | 6 +- .../cosp2_rttov_AIRS_L1C_CESM2.txt | 79 +++++++++++++++++++ .../cosp2_rttov_AIRS_L1C_val1.txt | 4 +- .../cosp2_rttov_AIRS_L1C_val2.txt | 4 +- .../cosp2_rttov_AIRS_L1C_val3.txt | 8 +- .../cosp2_rttov_inst5_PREFIRE_CESM2.txt | 4 +- .../cosp2_rttov_FORUM_CESM2_vza1.txt | 2 + .../cosp2_rttov_FORUM_CESM2_vza2.txt | 2 + .../cosp2_rttov_FORUM_CESM2_vza3.txt | 4 +- .../cosp2_rttov_FORUM_CESM2_vza4.txt | 4 +- .../cosp2_rttov_FORUM_CESM2_vza5.txt | 4 +- .../cosp2_rttov_FORUM_CESM2_vza6.txt | 4 +- .../cosp2_rttov_IASI_CESM2_vza1.txt | 4 +- .../cosp2_rttov_IASI_CESM2_vza2.txt | 4 +- .../cosp2_rttov_IASI_CESM2_vza3.txt | 4 +- .../cosp2_rttov_IASI_CESM2_vza4.txt | 4 +- .../cosp2_rttov_IASI_CESM2_vza5.txt | 4 +- .../cosp2_rttov_IASI_CESM2_vza6.txt | 4 +- src/simulator/rttov/cosp_rttov_v13.F90 | 6 +- 19 files changed, 131 insertions(+), 24 deletions(-) create mode 100644 driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2.txt diff --git a/driver/run/cosp2_input_AIRS_L1C_validation_nl.txt b/driver/run/cosp2_input_AIRS_L1C_validation_nl.txt index e78b5ef20b..356f17e48a 100644 --- a/driver/run/cosp2_input_AIRS_L1C_validation_nl.txt +++ b/driver/run/cosp2_input_AIRS_L1C_validation_nl.txt @@ -25,8 +25,8 @@ ! Namelist that sets up the main COSP options &COSP_INPUT - NPOINTS=153,! Number of gridpoints 153,27840,7081,6912 - NPOINTS_IT=5000,! 50,5000, Max number of gridpoints to be processed in one iteration + NPOINTS=1,! Number of gridpoints 153,27840,7081,6912 + NPOINTS_IT=10,! 50,5000, Max number of gridpoints to be processed in one iteration NCOLUMNS=20, ! Number of subcolumns NLEVELS=38, ! Number of model levels USE_VGRID=.true., ! Use fixed vertical grid for outputs? (if .true. then you need to define number of levels with Nlr) @@ -84,7 +84,7 @@ !---------------------------------------------------------------------------------- ! Simulating three AIRS L1C instruments rttov_Ninstruments=3, - rttov_instrument_namelists='instrument_nls/cosp2_rttov_AIRS_L1C_val1.txt','instrument_nls/cosp2_rttov_AIRS_L1C_val2.txt','instrument_nls/cosp2_rttov_AIRS_L1C_val3.txt', + rttov_instrument_namelists='instrument_nls/cosp2_rttov_AIRS_L1C_val1.txt','instrument_nls/cosp2_rttov_AIRS_L1C_val2.txt','instrument_nls/cosp2_rttov_AIRS_L1C_val3.txt','instrument_nls/cosp2_rttov_AIRS_L1C_CESM2.txt', rttov_verbose=.true. !---------------------------------------------------------------------------------- !-------------- Swathing inputs diff --git a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2.txt new file mode 100644 index 0000000000..6c54320f6e --- /dev/null +++ b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2.txt @@ -0,0 +1,79 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.true., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? + Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=45, ! 2645 for all AIRS L1C channels, 45 channel subset mostly from Sergio + !-------------- RTTOV Filepaths + Lchannel_filepath=.true., + channel_filepath='rttov_channel_input_AIRSL1C_subset.csv' + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='AIRS_L1C/rtcoef_eos_2_airs_l1c_o3co2.H5', + cld_coef_filepath='AIRS_L1C/sccldcoef_eos_2_airs_l1c.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.false., + CO_data=.false., + CO2_data=.true., + CH4_data=.false., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=6.09e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=0.0, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at + rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. + rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. +/ diff --git a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val1.txt b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val1.txt index d27041cbf7..8c3500f101 100644 --- a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val1.txt +++ b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val1.txt @@ -29,7 +29,7 @@ Lrttov_bt=.true., ! Calculate RTTOV brightness temps Lrttov_rad=.true., ! Calculate RTTOV radiances Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values Lrttov_cldparam=.false., ! Use user input cloud optical parameters Lrttov_aerparam=.false., ! Use user input aerosol optical parameters @@ -42,7 +42,7 @@ rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', rttov_coefDir='rtcoef_rttov13/', OD_coef_filepath='AIRS_L1C/rtcoef_eos_2_airs_l1c_o3co2.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', + cld_coef_filepath='AIRS_L1C/sccldcoef_eos_2_airs_l1c.H5', !-------------- RTTOV Trace Gas Logicals (must match coefficient files) SO2_data=.false., N2O_data=.false., diff --git a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val2.txt b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val2.txt index e1f76a9ecf..05c090cc5b 100644 --- a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val2.txt +++ b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val2.txt @@ -29,7 +29,7 @@ Lrttov_bt=.true., ! Calculate RTTOV brightness temps Lrttov_rad=.true., ! Calculate RTTOV radiances Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values Lrttov_cldparam=.false., ! Use user input cloud optical parameters Lrttov_aerparam=.false., ! Use user input aerosol optical parameters @@ -42,7 +42,7 @@ rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', rttov_coefDir='rtcoef_rttov13/', OD_coef_filepath='AIRS_L1C/rtcoef_eos_2_airs_l1c_o3co2.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', + cld_coef_filepath='AIRS_L1C/sccldcoef_eos_2_airs_l1c.H5', !-------------- RTTOV Trace Gas Logicals (must match coefficient files) SO2_data=.false., N2O_data=.false., diff --git a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val3.txt b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val3.txt index 1acb9aa797..1d167989f5 100644 --- a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val3.txt +++ b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val3.txt @@ -29,7 +29,7 @@ Lrttov_bt=.true., ! Calculate RTTOV brightness temps Lrttov_rad=.true., ! Calculate RTTOV radiances Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values Lrttov_cldparam=.false., ! Use user input cloud optical parameters Lrttov_aerparam=.false., ! Use user input aerosol optical parameters @@ -44,7 +44,7 @@ rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', rttov_coefDir='rtcoef_rttov13/', OD_coef_filepath='AIRS_L1C/rtcoef_eos_2_airs_l1c_o3co2.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', + cld_coef_filepath='AIRS_L1C/sccldcoef_eos_2_airs_l1c.H5', !-------------- RTTOV Trace Gas Logicals (must match coefficient files) SO2_data=.false., N2O_data=.false., @@ -73,5 +73,7 @@ ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) + rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. + rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt index 1d7eafa40f..f0901a1d1e 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt @@ -61,7 +61,7 @@ ! -------------- RTTOV Trace Gas Concentrations ! -------------- Specify units in RTTOV options set-up ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.true., ! Have RTTOV use the trace gas concentrations below + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below CO2_mr=5.241e-04, CH4_mr=9.139e-07, CO_mr=2.098e-07, @@ -79,4 +79,6 @@ rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=6.75,19.25, ! Local times to sample at in hrs [0,24] rttov_localtime_width=15000,2000, ! Swath width (km) + ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. + rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt index c36b29004f..56424a039f 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt @@ -74,4 +74,6 @@ rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. + rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt index 73f56c519c..0db55f1c5c 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt @@ -74,4 +74,6 @@ rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. + rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt index 873c862710..9c5b63f935 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt @@ -73,5 +73,7 @@ ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) + rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. + rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt index d56c6a7123..7a1c0c83d5 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt @@ -73,5 +73,7 @@ ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) + rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. + rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt index 7d0575e6d2..4eac7347e0 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt @@ -73,5 +73,7 @@ ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) + rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. + rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt index 0d814dbd80..668eca1d50 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt @@ -73,5 +73,7 @@ ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) + rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. + rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt index 2cee6cd06e..8e757353f5 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt @@ -74,5 +74,7 @@ ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) + rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. + rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt index 03bf66b00e..0a480745ff 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt @@ -74,5 +74,7 @@ ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) + rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. + rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt index 27b2a6e728..0652b59663 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt @@ -74,5 +74,7 @@ ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) + rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. + rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt index 40204fd666..e1134c1327 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt @@ -74,5 +74,7 @@ ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) + rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. + rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt index ff9144aa6a..e9b3f110d0 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt @@ -74,5 +74,7 @@ ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) + rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. + rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt index ca3fb681b0..afb73b9c16 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt @@ -74,5 +74,7 @@ ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) + rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. + rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index e23abfcd4a..64c2cc7e60 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -788,7 +788,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & j = 0 ! Initialize input do i = 1,rttovIN%nPoints - if (i .g.t rttovIN%nPoints) exit + if (i .gt. rttovIN%nPoints) exit if (inst_swath_mask(i)) then ! only added masked columns to profiles j = j + 1 ! Increment profile counter @@ -1224,7 +1224,7 @@ subroutine cosp_rttov_save_output(nPoints,inst_nchan_out,inst_swath_mask, & else ! If swathing is occurring, assign the outputs appropriately j = 0 do i=1,nPoints - if (i .gt. nPoints) exit + ! if (i .gt. nPoints) exit if (inst_swath_mask(i)) then ! only added masked columns to profiles if (Lrttov_bt) then bt_total(i, 1:inst_nchan_out) = inst_radiance%bt(1 + (j * inst_nchan_out):(j+1) * inst_nchan_out) @@ -1316,7 +1316,7 @@ subroutine cosp_pc_rttov_save_output(nPoints, & else ! If swathing is occurring, assign the outputs appropriately j = 0 do i=1,nPoints - if (i .gt. nPoints) exit + ! if (i .gt. nPoints) exit if (inst_swath_mask(i)) then ! only added masked columns to profiles if (Lrttov_bt) then bt_clear(i, 1:inst_nchannels_rec) = inst_pccomp%bt_pccomp(1 + (j * inst_nchannels_rec):(j+1) * inst_nchannels_rec) From 151644c05d65e01df8041e4978512f9e8e44c1f1 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 14 Aug 2024 14:08:19 -0600 Subject: [PATCH 122/159] Add simple daily offsets to swath local times in order to avoid striping from hourly radiative transfer calls. --- src/cosp.F90 | 4 +-- src/simulator/cosp_rttov_interface_v13.F90 | 2 +- src/simulator/rttov/cosp_rttov_v13.F90 | 41 ++++++++++++++++++++-- 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/cosp.F90 b/src/cosp.F90 index 031255dc11..b04405f4b1 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -4533,7 +4533,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, end do end if endif - if (any(cospgridIN%rttov_date(:,1) .lt. 0)) then ! rttov_date(1), year on [0,60] + if (any(cospgridIN%rttov_date(:,1) .lt. 0)) then ! rttov_date(1), year on [0,inf] nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospIN%rttov_date(1) contains values out of range' Lrttov_column = .false. @@ -4571,7 +4571,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, end do end if endif - if (any(cospgridIN%rttov_date(:,3) .lt. 0 .OR. cospgridIN%rttov_date(:,3) .gt. 366)) then ! rttov_date(3), day on [0,366] + if (any(cospgridIN%rttov_date(:,3) .lt. 1 .OR. cospgridIN%rttov_date(:,3) .gt. 31)) then ! rttov_date(3), day on [1,31] nError=nError+1 errorMessage(nError) = 'ERROR: COSP input variable: cospIN%rttov_date(3) contains values out of range' Lrttov_column = .false. diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index d2d0aa5a6c..70555afc27 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -715,7 +715,7 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,error, error,verbose) endif else - if (verbose) print*,'empty chunk' + if (verbose) print*,'empty chunk' endif END SUBROUTINE COSP_RTTOV_SIMULATE diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 64c2cc7e60..07b6e3e7ab 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -206,10 +206,20 @@ subroutine cosp_rttov_swath(rttovIN,rttov_Nlocaltime, & logical(kind=jplm), dimension(rttovIN % nPoints,rttov_Nlocaltime) :: & swath_mask_all ! Mask of logicals over all local times - + + integer, dimension(rttovIN % nPoints) :: & + rttov_DOY ! Array of day of year values + real(kind=jprb), dimension(rttovIN % nPoints) :: & + localtime_offsets ! Offset values to avoid striping with hourly RT calls. [hours] logical :: verbose = .false. - if (present(debug)) verbose = debug + if (present(debug)) verbose = debug + + ! Compute the day of the year and determine the localtime offset + do j=1,rttovIN%nPoints + call get_DOY(int(rttovIN%rttov_date(j,2)), int(rttovIN%rttov_date(j,3)), rttov_DOY(j)) + end do + localtime_offsets = (mod(rttov_DOY(:), 5) - 2) / 5.0 ! Need to cast to real ! Handle swathing here. Initial code from Genevieve with implementation changes. swath_mask_all = .false. @@ -217,7 +227,7 @@ subroutine cosp_rttov_swath(rttovIN,rttov_Nlocaltime, & ! Iterate over local times do j=1,rttov_Nlocaltime ! Calculate the central longitude for each gridcell and orbit - sat_lon(:,j) = 15.0 * (rttov_localtime(j) - (rttovIN%rttov_time(:,1) + rttovIN%rttov_time(:,2) / 60)) + sat_lon(:,j) = 15.0 * (rttov_localtime(j) + localtime_offsets(:) - (rttovIN%rttov_time(:,1) + rttovIN%rttov_time(:,2) / 60)) ! Calculate distance (in degrees) from each grid cell to the satellite central long dlon(:,j) = mod((rttovIN%longitude - sat_lon(:,j) + 180.0), 360.0) - 180.0 ! calculate distance to satellite in km. Remember to convert to radians for cos/sine calls @@ -1500,6 +1510,31 @@ subroutine interpolate_logp(ptarget,p1,p2,z1,z2,ztarget) end subroutine interpolate_logp + subroutine get_DOY(month, day, DOY) + + integer,intent(in) :: & + month, & + day + integer,intent(out) :: & + DOY + + ! This subroutine does not handle leap years because it is not relevant to the purpose. + ! Simple look-up table for DOY. + if (month .eq. 1) DOY = day + if (month .eq. 2) DOY = 31 + day + if (month .eq. 3) DOY = 59 + day + if (month .eq. 4) DOY = 90 + day + if (month .eq. 5) DOY = 120 + day + if (month .eq. 6) DOY = 151 + day + if (month .eq. 7) DOY = 181 + day + if (month .eq. 8) DOY = 212 + day + if (month .eq. 9) DOY = 243 + day + if (month .eq. 10) DOY = 273 + day + if (month .eq. 11) DOY = 304 + day + if (month .eq. 12) DOY = 334 + day + + end subroutine get_DOY + !########################## ! Module End !########################## From a2a11417593452465f793779d08c7368844c6b52 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 14 Aug 2024 16:01:41 -0600 Subject: [PATCH 123/159] Applying swath striping fix to standard COSP2 outputs. --- src/cosp.F90 | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/src/cosp.F90 b/src/cosp.F90 index b04405f4b1..e2797a6961 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -790,6 +790,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospIN % cospswathsIN(1) % inst_localtimes, & cospIN % cospswathsIN(1) % inst_localtime_widths, & cospgridIN%lat, cospgridIN%lon, & + cospgridIN%rttov_date(:,2), cospgridIN%rttov_date(:,3), & ! Time fields: month, dayofmonth cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute ISCCP_SWATH_MASK,N_ISCCP_SWATHED) ! Output: logical mask array isccpIN%Npoints => N_ISCCP_SWATHED @@ -852,6 +853,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospIN % cospswathsIN(2) % inst_localtimes, & cospIN % cospswathsIN(2) % inst_localtime_widths, & cospgridIN%lat, cospgridIN%lon, & + cospgridIN%rttov_date(:,2), cospgridIN%rttov_date(:,3), & ! Time fields: month, dayofmonth cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute MISR_SWATH_MASK,N_MISR_SWATHED) ! Output: logical mask array misrIN%Npoints => N_MISR_SWATHED @@ -897,6 +899,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospIN % cospswathsIN(3) % inst_localtimes, & cospIN % cospswathsIN(3) % inst_localtime_widths, & cospgridIN%lat, cospgridIN%lon, & + cospgridIN%rttov_date(:,2), cospgridIN%rttov_date(:,3), & ! Time fields: month, dayofmonth cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute CSCAL_SWATH_MASK, N_CSCAL_SWATHED) ! Output: logical mask array calipsoIN%Npoints => N_CSCAL_SWATHED @@ -967,6 +970,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospIN % cospswathsIN(4) % inst_localtimes, & cospIN % cospswathsIN(4) % inst_localtime_widths, & cospgridIN%lat, cospgridIN%lon, & + cospgridIN%rttov_date(:,2), cospgridIN%rttov_date(:,3), & ! Time fields: month, dayofmonth cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute ATLID_SWATH_MASK, N_ATLID_SWATHED) ! Output: logical mask array atlidIN%Npoints => N_ATLID_SWATHED @@ -1011,6 +1015,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospIN % cospswathsIN(5) % inst_localtimes, & cospIN % cospswathsIN(5) % inst_localtime_widths, & cospgridIN%lat, cospgridIN%lon, & + cospgridIN%rttov_date(:,2), cospgridIN%rttov_date(:,3), & ! Time fields: month, dayofmonth cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute PARASOL_SWATH_MASK, N_PARASOL_SWATHED) ! Output: logical mask array parasolIN%Npoints => N_PARASOL_SWATHED @@ -1050,6 +1055,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospIN % cospswathsIN(3) % inst_localtimes, & cospIN % cospswathsIN(3) % inst_localtime_widths, & cospgridIN%lat, cospgridIN%lon, & + cospgridIN%rttov_date(:,2), cospgridIN%rttov_date(:,3), & ! Time fields: month, dayofmonth cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute CSCAL_SWATH_MASK, N_CSCAL_SWATHED) ! Output: logical mask array cloudsatIN%Npoints => N_CSCAL_SWATHED @@ -1101,6 +1107,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospIN % cospswathsIN(6) % inst_localtimes, & cospIN % cospswathsIN(6) % inst_localtime_widths, & cospgridIN%lat, cospgridIN%lon, & + cospgridIN%rttov_date(:,2), cospgridIN%rttov_date(:,3), & ! Time fields: month, dayofmonth cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute MODIS_SWATH_MASK, N_MODIS_SWATHED) ! Output: logical mask array @@ -2931,7 +2938,7 @@ end subroutine cosp_cleanUp ! SUBROUTINE compute_orbitmasks !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% subroutine compute_orbitmasks(Npoints,Nlocaltimes,localtimes,localtime_widths, & - lat,lon,hour,minute,swath_mask_out,Nswathed_out) + lat,lon,month,day,hour,minute,swath_mask_out,Nswathed_out) ! Inputs integer,intent(in) :: & @@ -2945,6 +2952,8 @@ subroutine compute_orbitmasks(Npoints,Nlocaltimes,localtimes,localtime_widths, real(wp),dimension(Npoints),intent(in) :: & lat, & lon, & + month, & + day, & hour, & minute @@ -2969,11 +2978,21 @@ subroutine compute_orbitmasks(Npoints,Nlocaltimes,localtimes,localtime_widths, logical,dimension(Npoints,Nlocaltimes) :: & swath_mask_all ! Mask of logicals over all local times, gridcells + integer, dimension(Npoints) :: & + rttov_DOY ! Array of day of year values + real(wp), dimension(Npoints) :: & + localtime_offsets ! Offset values to avoid striping with hourly RT calls. [hours] + ! Compute the day of the year and determine the localtime offset + do i=1,Npoints + call get_DOY(int(month(i)), int(day(i)), rttov_DOY(i)) + end do + localtime_offsets = (mod(rttov_DOY(:), 5) - 2) / 5.0 ! Need to cast to real + ! Iterate over local times swath_mask_all(:,:) = .false. do i=1,Nlocaltimes ! Calculate the central longitude for each gridcell and orbit - sat_lon(:,i) = 15.0 * (localtimes(i) - (hour + minute / 60)) + sat_lon(:,i) = 15.0 * (localtimes(i) + localtime_offsets - (hour + minute / 60)) ! Calculate distance (in degrees) from each grid cell to the satellite central long dlon(:,i) = mod((lon - sat_lon(:,i) + 180.0), 360.0) - 180.0 ! calculate distance to satellite in km. Remember to convert to radians for cos/sine calls @@ -2993,6 +3012,31 @@ subroutine compute_orbitmasks(Npoints,Nlocaltimes,localtimes,localtime_widths, end subroutine compute_orbitmasks + subroutine get_DOY(month, day, DOY) + + integer,intent(in) :: & + month, & + day + integer,intent(out) :: & + DOY + + ! This subroutine does not handle leap years because it is not relevant to the purpose. + ! Simple look-up table for DOY. + if (month .eq. 1) DOY = day + if (month .eq. 2) DOY = 31 + day + if (month .eq. 3) DOY = 59 + day + if (month .eq. 4) DOY = 90 + day + if (month .eq. 5) DOY = 120 + day + if (month .eq. 6) DOY = 151 + day + if (month .eq. 7) DOY = 181 + day + if (month .eq. 8) DOY = 212 + day + if (month .eq. 9) DOY = 243 + day + if (month .eq. 10) DOY = 273 + day + if (month .eq. 11) DOY = 304 + day + if (month .eq. 12) DOY = 334 + day + + end subroutine get_DOY + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_errorCheck !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From 9ab32b95085b47fabf31b7ee86124beefa03ed5a Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 27 Aug 2024 17:41:20 -0600 Subject: [PATCH 124/159] Flexibly handle gas units, specifically MMR over dry air as in CESM2. --- src/cosp_constants.F90 | 3 +- src/simulator/cosp_rttov_interface_v13.F90 | 15 +++++-- src/simulator/rttov/cosp_rttov_v13.F90 | 46 ++++++++++++++++------ 3 files changed, 48 insertions(+), 16 deletions(-) diff --git a/src/cosp_constants.F90 b/src/cosp_constants.F90 index 8fbdba50f5..31c2b46227 100755 --- a/src/cosp_constants.F90 +++ b/src/cosp_constants.F90 @@ -54,7 +54,8 @@ MODULE cosp_phys_constants amCO2 = 44.0096_wp, & ! CO2 [g/mol] amCH4 = 16.0426_wp, & ! Methane [g/mol] amN2O = 44.0129_wp, & ! N2O [g/mol] - amCO = 28.0102_wp ! CO [g/mol] + amCO = 28.0102_wp, & ! CO [g/mol] + amSO2 = 64.0640_wp ! SO2 [g/mol] ! WMO/SI value REAL(wp), PARAMETER :: & diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 70555afc27..ac5bdc6821 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -101,6 +101,7 @@ MODULE MOD_COSP_RTTOV_INTERFACE nchan_out, & nchannels_rec, & rttov_Nlocaltime, & + gas_units, & rttov_extendatmos, & nprof real(wp) :: & @@ -259,6 +260,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & ! JKS for orbital swathing integer(kind=jpim) :: & rttov_Nlocaltime, & ! Number of orbits + rttov_gas_units, & ! RTTOV units for trace gases: 0 ppmv over dry air, 1 kg/kg over moist air, 2 ppmv over moist air, 3 kg/kg over dry air rttov_extendatmos real(wp),dimension(20) :: & ! Reasonable but arbitrary limit at 10 local time orbits rttov_localtime, & ! RTTOV subsetting by local time in hours [0,24] @@ -296,6 +298,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & clw_data = .false. user_tracegas_input = .false. rttov_Nlocaltime = 0 ! Default: zero swath masking + rttov_gas_units = 1 ! Default: kg/kg over moist air (should be updated!) rttov_extendatmos = 0 ! 0: do not extend above supplied pressure levels. 1: Simply top layer. 2: Not yet implemented. ! Read RTTOV namelist fields @@ -312,7 +315,8 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & CO2_mr,CH4_mr,CO_mr,N2O_mr,SO2_mr, & ! Mixing ratios ipcbnd,ipcreg,npcscores, & ! PC-RTTOV config values rttov_nthreads,rttov_ZenAng,rttov_Nlocaltime, & - rttov_localtime,rttov_localtime_width,rttov_extendatmos + rttov_localtime,rttov_localtime_width, & + rttov_gas_units,rttov_extendatmos !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Read in namelists @@ -374,7 +378,8 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & ! Set to false in namelist if model supplies trace profiles rttov_config%user_tracegas_input = user_tracegas_input - + rttov_config%gas_units = rttov_gas_units + rttov_config%SO2_mr = SO2_mr rttov_config%N2O_mr = N2O_mr rttov_config%CO_mr = CO_mr @@ -614,7 +619,9 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & print*,'rttov_config % opts % rt_ir % do_nlte_correction: ',rttov_config % opts % rt_ir % do_nlte_correction print*,'rttov_config % rttov_Nlocaltime: ',rttov_config % rttov_Nlocaltime print*,'rttov_config % rttov_localtime: ',rttov_config % rttov_localtime - print*,'rttov_config % rttov_localtime_width: ',rttov_config % rttov_localtime_width + print*,'rttov_config % rttov_localtime_width: ',rttov_config % rttov_localtime_width + print*,'rttov_config % rttov_extendatmos: ',rttov_config % rttov_extendatmos + print*,'rttov_config % gas_units: ',rttov_config % gas_units end if ! subsub routines @@ -810,6 +817,7 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig, rttovConfig % ZenAng, & rttovConfig % nprof, & rttovConfig % swath_mask, & + rttovConfig % gas_units, & rttovConfig % rttov_extendatmos, & verbose) @@ -971,6 +979,7 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig, rttovConfig % ZenAng, & rttovConfig % nprof, & rttovConfig % swath_mask, & + rttovConfig % gas_units, & rttovConfig % rttov_extendatmos, & verbose) call cpu_time(driver_time(3)) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 07b6e3e7ab..1d00abd5b7 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -46,8 +46,9 @@ module mod_cosp_rttov use rttov_unix_env, only : rttov_exit use cosp_kinds, only : wp use mod_cosp_config, only : N_HYDRO - use cosp_phys_constants, only : mdry=>amd,mO3=>amO3,mco2=>amCO2,mCH4=>amCH4, & - mn2o=>amN2O,mco=>amCO + use cosp_phys_constants, only : mdry=>amd,mH2O=>amw,mO3=>amO3,mCO2=>amCO2, & + mCH4=>amCH4,mN2O=>amN2O,mCO=>amCO,mSO2=>amSO2 + ! The rttov_emis_atlas_data type must be imported separately use mod_rttov_emis_atlas, ONLY : & @@ -544,6 +545,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & inst_zenang, & inst_nprof, & inst_swath_mask,& + inst_gas_units, & inst_extend_atmos,& debug) @@ -571,6 +573,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & inst_zenang integer(kind=jpim),intent(in) :: & inst_nprof, & + inst_gas_units, & inst_extend_atmos logical(kind=jplm),dimension(rttovIN % nPoints),intent(in) :: & inst_swath_mask @@ -592,8 +595,6 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & ! If you are not able to provide ozone, CO2, etc profiles the flags ! ozone_data, co2_data and so on in the options structure should be ! set to false." - - inst_profiles(:)%gas_units = 1 ! kg/kg over moist air (default) ! Iterate over all columns j = 0 ! Initialize input @@ -641,7 +642,11 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & if (Ldo_so2) inst_profiles(j)%so2(:) = inst_so2_mr ! if (Ldo_o3) inst_profiles(j)%o3(:) = rttovIN%o3(i, :) if (Ldo_o3) then ! no O3 user input set up - call interpolate_logp(100*inst_profiles(j)%p(modeltop_index),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%o3(i,1),rttovIN%o3(i,2),inst_profiles(j)%o3(modeltop_index)) + if (inst_extend_atmos) then ! CAM sets the top layer O3 to a linear interpolation between the highest layer and zero O3 at 50 Pa. (see rrtmg_state.F90) + call interpolate_logp(100*inst_profiles(j)%p(modeltop_index),50._wp,rttovIN%p(i,1),0.0_wp,rttovIN%o3(i,1),inst_profiles(j)%o3(modeltop_index)) + else + call interpolate_logp(100*inst_profiles(j)%p(modeltop_index),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%o3(i,1),rttovIN%o3(i,2),inst_profiles(j)%o3(modeltop_index)) + end if call interpolate_logp(100*inst_profiles(j)%p(inst_profiles(j)%nlevels),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%o3(i,rttovIN%nlevels-1),rttovIN%o3(i,rttovIN%nlevels),inst_profiles(j)%o3(inst_profiles(j)%nlevels)) do k=modeltop_index+1,inst_profiles(j)%nlevels-1 kk = k + 1 - modeltop_index @@ -711,10 +716,12 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & if (Ldo_o3) inst_profiles(j)%o3(1) = inst_profiles(j)%o3(modeltop_index) end if - ! q coefficient limit is 0.1e-10 - where(inst_profiles(j)%q(:) < 0.1e-10) - inst_profiles(j)%q(:) = 0.11e-10 - end where + ! q coefficient limit is 0.1e-10 for MMRs over moist air + if (inst_profiles(j)%gas_units .eq. 1) then + where(inst_profiles(j)%q(:) < 0.1e-10) + inst_profiles(j)%q(:) = 0.11e-10 + end where + end if ! 2m parameters inst_profiles(j)%s2m%p = rttovIN%p_surf(i) * 1e-2 ! convert Pa to hPa @@ -775,10 +782,25 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & inst_profiles(j)%skin%watertype = 1 !inst_profiles(j) %idg = 0. ! Depreciated? !inst_profiles(j) %ish = 0. ! Depreciated? + + ! Correct units if dry mass mixing ratios in ppmv were supplied + if (inst_gas_units .eq. 3) then + inst_profiles(j)%s2m%q = inst_profiles(j)%s2m%q * mdry / mH2O * 1.e6 + inst_profiles(j)%q(:) = inst_profiles(j)%q(:) * mdry / mH2O * 1.e6 + inst_profiles(j)%o3(:) = inst_profiles(j)%o3(:) * mdry / mH2O * 1.e6 + inst_profiles(j)%co2(:) = inst_profiles(j)%co2(:) * mdry / mH2O * 1.e6 + inst_profiles(j)%ch4(:) = inst_profiles(j)%ch4(:) * mdry / mH2O * 1.e6 + inst_profiles(j)%n2o(:) = inst_profiles(j)%n2o(:) * mdry / mH2O * 1.e6 + inst_profiles(j)%co(:) = inst_profiles(j)%co(:) * mdry / mH2O * 1.e6 + inst_profiles(j)%so2(:) = inst_profiles(j)%so2(:) * mdry / mH2O * 1.e6 + inst_profiles(j)%gas_units = 0 ! ppmv over dry air + else + inst_profiles(j)%gas_units = inst_gas_units + end if + end if - end do - - + end do + ! JKS - nothing to check here, this will never trigger. call rttov_error('error in profile initialization' , lalloc = .false.) From 451c0249990a4663a17dc2295f32996a5c25e9c7 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 28 Aug 2024 08:37:52 -0600 Subject: [PATCH 125/159] Update instrument namelists for CESM2 with correct trace gas units values. --- driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2.txt | 8 +++++--- .../instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt | 1 + .../run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2.txt | 1 + .../instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt | 1 + .../run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt | 1 + .../point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt | 1 + .../point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt | 1 + .../point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt | 1 + .../point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt | 1 + .../point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt | 1 + .../point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt | 1 + .../point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt | 3 ++- .../point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt | 3 ++- .../point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt | 3 ++- .../point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt | 3 ++- .../point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt | 3 ++- .../point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt | 3 ++- 17 files changed, 27 insertions(+), 9 deletions(-) diff --git a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2.txt index 6c54320f6e..165a737823 100644 --- a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2.txt +++ b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2.txt @@ -43,14 +43,15 @@ channel_filepath='rttov_channel_input_AIRSL1C_subset.csv' rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='AIRS_L1C/rtcoef_eos_2_airs_l1c_o3co2.H5', + ! OD_coef_filepath='AIRS_L1C/rtcoef_eos_2_airs_l1c_o3co2.H5', + OD_coef_filepath='AIRS_L1C/rtcoef_eos_2_airs_l1c_7gas.H5', ! Full version with N20 and CH4 cld_coef_filepath='AIRS_L1C/sccldcoef_eos_2_airs_l1c.H5', !-------------- RTTOV Trace Gas Logicals (must match coefficient files) SO2_data=.false., - N2O_data=.false., + N2O_data=.true., ! .true. for 7gas CO_data=.false., CO2_data=.true., - CH4_data=.false., + CH4_data=.true., ! .true. for 7gas ozone_data=.true., clw_data=.false., ! Only used for MW calculations ! -------------- RTTOV Trace Gas Concentrations @@ -69,6 +70,7 @@ !-------------- RTTOV Other --------------- ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel rttov_nthreads=1, + rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air rttov_ZenAng=0.0, ! Satellite Zenith Angle ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at diff --git a/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt index f0901a1d1e..bd562ac017 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt @@ -74,6 +74,7 @@ !-------------- RTTOV Other --------------- ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel rttov_nthreads=1, + rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air rttov_ZenAng=0.0, ! Satellite Zenith Angle ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at diff --git a/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2.txt index 2f7a579f43..a4d347f29a 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2.txt @@ -71,6 +71,7 @@ !-------------- RTTOV Other --------------- ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel rttov_nthreads=1, + rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air rttov_ZenAng=0.0, ! Satellite Zenith Angle ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at diff --git a/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt b/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt index fa9f3c14e6..148097210e 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt @@ -69,6 +69,7 @@ !-------------- RTTOV Other --------------- ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel rttov_nthreads=1, + rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air rttov_ZenAng=0.0, ! Satellite Zenith Angle ! Set local time sampling with swath widths rttov_Nlocaltime=2, ! Number of local times to sample at diff --git a/driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt index 8c2589361c..8089c3dc66 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt @@ -72,6 +72,7 @@ !-------------- RTTOV Other --------------- ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel rttov_nthreads=1, + rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air rttov_ZenAng=0.0, ! Satellite Zenith Angle ! Set local time sampling with swath widths rttov_Nlocaltime=2, ! Number of local times to sample at diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt index 56424a039f..9a2b9b61cd 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt @@ -69,6 +69,7 @@ !-------------- RTTOV Other --------------- ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel rttov_nthreads=1, + rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air rttov_ZenAng=7.19, ! Satellite Zenith Angle ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt index 0db55f1c5c..ace969aa52 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt @@ -69,6 +69,7 @@ !-------------- RTTOV Other --------------- ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel rttov_nthreads=1, + rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air rttov_ZenAng=21.58, ! Satellite Zenith Angle ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt index 9c5b63f935..91c3310d7f 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt @@ -69,6 +69,7 @@ !-------------- RTTOV Other --------------- ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel rttov_nthreads=1, + rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air rttov_ZenAng=35.97, ! Satellite Zenith Angle ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt index 7a1c0c83d5..d288ce6e08 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt @@ -69,6 +69,7 @@ !-------------- RTTOV Other --------------- ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel rttov_nthreads=1, + rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air rttov_ZenAng=50.34, ! Satellite Zenith Angle ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt index 4eac7347e0..7f8510ad0c 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt @@ -69,6 +69,7 @@ !-------------- RTTOV Other --------------- ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel rttov_nthreads=1, + rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air rttov_ZenAng=64.71, ! Satellite Zenith Angle ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt index 668eca1d50..402e2ba43f 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt @@ -69,6 +69,7 @@ !-------------- RTTOV Other --------------- ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel rttov_nthreads=1, + rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air rttov_ZenAng=78.98, ! Satellite Zenith Angle ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt index 8e757353f5..dd742bd937 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt @@ -34,7 +34,7 @@ Lrttov_cldparam=.false., ! Use user input cloud optical parameters Lrttov_aerparam=.false., ! Use user input aerosol optical parameters Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.true., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. + Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. Lrttov_pc=.false., ! Run with PC-RTTOV !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels @@ -70,6 +70,7 @@ !-------------- RTTOV Other --------------- ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel rttov_nthreads=1, + rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air rttov_ZenAng=7.19, ! Satellite Zenith Angle, was 76.2 ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt index 0a480745ff..ebf624d292 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt @@ -34,7 +34,7 @@ Lrttov_cldparam=.false., ! Use user input cloud optical parameters Lrttov_aerparam=.false., ! Use user input aerosol optical parameters Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.true., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. + Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. Lrttov_pc=.false., ! Run with PC-RTTOV !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels @@ -70,6 +70,7 @@ !-------------- RTTOV Other --------------- ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel rttov_nthreads=1, + rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air rttov_ZenAng=21.58, ! Satellite Zenith Angle ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt index 0652b59663..5ac9623187 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt @@ -34,7 +34,7 @@ Lrttov_cldparam=.false., ! Use user input cloud optical parameters Lrttov_aerparam=.false., ! Use user input aerosol optical parameters Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.true., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. + Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. Lrttov_pc=.false., ! Run with PC-RTTOV !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels @@ -70,6 +70,7 @@ !-------------- RTTOV Other --------------- ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel rttov_nthreads=1, + rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air rttov_ZenAng=35.97, ! Satellite Zenith Angle, was 76.2 ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt index e1134c1327..22db1936cd 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt @@ -34,7 +34,7 @@ Lrttov_cldparam=.false., ! Use user input cloud optical parameters Lrttov_aerparam=.false., ! Use user input aerosol optical parameters Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.true., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. + Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. Lrttov_pc=.false., ! Run with PC-RTTOV !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels @@ -70,6 +70,7 @@ !-------------- RTTOV Other --------------- ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel rttov_nthreads=1, + rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air rttov_ZenAng=50.34, ! Satellite Zenith Angle ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt index e9b3f110d0..2519e4fc20 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt @@ -34,7 +34,7 @@ Lrttov_cldparam=.false., ! Use user input cloud optical parameters Lrttov_aerparam=.false., ! Use user input aerosol optical parameters Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.true., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. + Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. Lrttov_pc=.false., ! Run with PC-RTTOV !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels @@ -70,6 +70,7 @@ !-------------- RTTOV Other --------------- ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel rttov_nthreads=1, + rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air rttov_ZenAng=64.71, ! Satellite Zenith Angle ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt index afb73b9c16..3d613d33e3 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt @@ -34,7 +34,7 @@ Lrttov_cldparam=.false., ! Use user input cloud optical parameters Lrttov_aerparam=.false., ! Use user input aerosol optical parameters Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.true., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. + Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. Lrttov_pc=.false., ! Run with PC-RTTOV !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels @@ -70,6 +70,7 @@ !-------------- RTTOV Other --------------- ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel rttov_nthreads=1, + rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air rttov_ZenAng=78.98, ! Satellite Zenith Angle ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at From 15e782482ca702a52135fd7ae8d006498b2c5bf4 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Sun, 22 Sep 2024 12:11:38 -0600 Subject: [PATCH 126/159] Apply other CAM-like details when extend_atmos = 1 --- src/simulator/rttov/cosp_rttov_v13.F90 | 71 +++++++++++++++++++------- 1 file changed, 52 insertions(+), 19 deletions(-) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 1d00abd5b7..5288e6e30c 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -641,12 +641,8 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & if (Ldo_ch4) inst_profiles(j)%ch4(:) = inst_ch4_mr if (Ldo_so2) inst_profiles(j)%so2(:) = inst_so2_mr ! if (Ldo_o3) inst_profiles(j)%o3(:) = rttovIN%o3(i, :) - if (Ldo_o3) then ! no O3 user input set up - if (inst_extend_atmos) then ! CAM sets the top layer O3 to a linear interpolation between the highest layer and zero O3 at 50 Pa. (see rrtmg_state.F90) - call interpolate_logp(100*inst_profiles(j)%p(modeltop_index),50._wp,rttovIN%p(i,1),0.0_wp,rttovIN%o3(i,1),inst_profiles(j)%o3(modeltop_index)) - else - call interpolate_logp(100*inst_profiles(j)%p(modeltop_index),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%o3(i,1),rttovIN%o3(i,2),inst_profiles(j)%o3(modeltop_index)) - end if + if (Ldo_o3) then ! no O3 user input set up + call interpolate_logp(100*inst_profiles(j)%p(modeltop_index),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%o3(i,1),rttovIN%o3(i,2),inst_profiles(j)%o3(modeltop_index)) call interpolate_logp(100*inst_profiles(j)%p(inst_profiles(j)%nlevels),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%o3(i,rttovIN%nlevels-1),rttovIN%o3(i,rttovIN%nlevels),inst_profiles(j)%o3(inst_profiles(j)%nlevels)) do k=modeltop_index+1,inst_profiles(j)%nlevels-1 kk = k + 1 - modeltop_index @@ -705,27 +701,37 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & end if ! If adding CAM-like model top layer, copy temperature and trace gas values to the new top level. - if (inst_extend_atmos==1) then + if (inst_extend_atmos==1) then ! Replicate RRTMG-LW operations in CAM6 inst_profiles(j)%t(1) = inst_profiles(j)%t(modeltop_index) + inst_profiles(j)%t(inst_profiles(j)%nlevels) = rttovIN%t_skin(i) ! RRTMG sets the lowest atmospheric temperature equal to the surface skin temperature inst_profiles(j)%q(1) = inst_profiles(j)%q(modeltop_index) if (Ldo_co2) inst_profiles(j)%co2(1) = inst_profiles(j)%co2(modeltop_index) if (Ldo_n2o) inst_profiles(j)%n2o(1) = inst_profiles(j)%n2o(modeltop_index) if (Ldo_co) inst_profiles(j)%co(1) = inst_profiles(j)%co(modeltop_index) if (Ldo_ch4) inst_profiles(j)%ch4(1) = inst_profiles(j)%ch4(modeltop_index) if (Ldo_so2) inst_profiles(j)%so2(1) = inst_profiles(j)%so2(modeltop_index) - if (Ldo_o3) inst_profiles(j)%o3(1) = inst_profiles(j)%o3(modeltop_index) + if (Ldo_o3) inst_profiles(j)%o3(1) = 0.0 + ! CAM sets the top layer O3 to a linear interpolation between the highest layer and zero O3 at 50 Pa. So the top interface should just be zero then (see rrtmg_state.F90) + ! if (Ldo_o3) call interpolate_logp(100*inst_profiles(j)%p(1),50._wp,rttovIN%p(i,1),0.0_wp,rttovIN%o3(i,1),inst_profiles(j)%o3(1)) end if - ! q coefficient limit is 0.1e-10 for MMRs over moist air + ! q and o3 coefficient limit is 0.1e-10 for MMRs over moist air if (inst_profiles(j)%gas_units .eq. 1) then where(inst_profiles(j)%q(:) < 0.1e-10) inst_profiles(j)%q(:) = 0.11e-10 end where + where(inst_profiles(j)%o3(:) < 0.1e-10) + inst_profiles(j)%o3(:) = 0.11e-10 + end where end if ! 2m parameters inst_profiles(j)%s2m%p = rttovIN%p_surf(i) * 1e-2 ! convert Pa to hPa - inst_profiles(j)%s2m%t = rttovIN%t2m(i) + if (inst_extend_atmos==1) then + inst_profiles(j)%s2m%t = rttovIN%t_skin(i) + else + inst_profiles(j)%s2m%t = rttovIN%t2m(i) + end if inst_profiles(j)%s2m%q = rttovIN%q2m(i) ! Should be the same as gas units (kg/kg) inst_profiles(j)%s2m%u = rttovIN%u_surf(i) inst_profiles(j)%s2m%v = rttovIN%v_surf(i) @@ -784,16 +790,30 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & !inst_profiles(j) %ish = 0. ! Depreciated? ! Correct units if dry mass mixing ratios in ppmv were supplied + ! Units for gas abundances: (must be the same for all profiles) + ! 2 => ppmv over moist air + ! 1=> kg/kg over moist air (default) + ! 0 (or less) => ppmv over dry air + ! JKS added 3 => kg/kg over dry air, which requires conversion. if (inst_gas_units .eq. 3) then - inst_profiles(j)%s2m%q = inst_profiles(j)%s2m%q * mdry / mH2O * 1.e6 - inst_profiles(j)%q(:) = inst_profiles(j)%q(:) * mdry / mH2O * 1.e6 - inst_profiles(j)%o3(:) = inst_profiles(j)%o3(:) * mdry / mH2O * 1.e6 - inst_profiles(j)%co2(:) = inst_profiles(j)%co2(:) * mdry / mH2O * 1.e6 - inst_profiles(j)%ch4(:) = inst_profiles(j)%ch4(:) * mdry / mH2O * 1.e6 - inst_profiles(j)%n2o(:) = inst_profiles(j)%n2o(:) * mdry / mH2O * 1.e6 - inst_profiles(j)%co(:) = inst_profiles(j)%co(:) * mdry / mH2O * 1.e6 - inst_profiles(j)%so2(:) = inst_profiles(j)%so2(:) * mdry / mH2O * 1.e6 - inst_profiles(j)%gas_units = 0 ! ppmv over dry air + ! Convert to ppmv over dry air + inst_profiles(j)%s2m%q = (inst_profiles(j)%s2m%q / (1.0 - inst_profiles(j)%s2m%q)) * mdry / mH2O * 1.e6 + inst_profiles(j)%q(:) = (inst_profiles(j)%q(:) / (1.0 - inst_profiles(j)%q(:))) * mdry / mH2O * 1.e6 + inst_profiles(j)%o3(:) = inst_profiles(j)%o3(:) * mdry / mO3 * 1.e6 + inst_profiles(j)%co2(:) = inst_profiles(j)%co2(:) * mdry / mCO2 * 1.e6 + inst_profiles(j)%ch4(:) = inst_profiles(j)%ch4(:) * mdry / mCH4 * 1.e6 + inst_profiles(j)%n2o(:) = inst_profiles(j)%n2o(:) * mdry / mN2O * 1.e6 + inst_profiles(j)%co(:) = inst_profiles(j)%co(:) * mdry / mCO * 1.e6 + inst_profiles(j)%so2(:) = inst_profiles(j)%so2(:) * mdry / mSO2 * 1.e6 + inst_profiles(j)%gas_units = 0 + ! Alternately, convert kg/kg/ over dry air to kg/kg over moist air + ! inst_profiles(j)%o3(:) = inst_profiles(j)%o3(:) * (1.0 - inst_profiles(j)%q(:)) + ! inst_profiles(j)%co2(:) = inst_profiles(j)%co2(:) * (1.0 - inst_profiles(j)%q(:)) + ! inst_profiles(j)%ch4(:) = inst_profiles(j)%ch4(:) * (1.0 - inst_profiles(j)%q(:)) + ! inst_profiles(j)%n2o(:) = inst_profiles(j)%n2o(:) * (1.0 - inst_profiles(j)%q(:)) + ! inst_profiles(j)%co(:) = inst_profiles(j)%co(:) * (1.0 - inst_profiles(j)%q(:)) + ! inst_profiles(j)%so2(:) = inst_profiles(j)%so2(:) * (1.0 - inst_profiles(j)%q(:)) + ! inst_profiles(j)%gas_units = 1 else inst_profiles(j)%gas_units = inst_gas_units end if @@ -898,6 +918,19 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & ! end if end if + ! if (verbose) then ! JKS remove at some point + ! print*,"inst_profiles(1)%gas_units: ",inst_profiles(1)%gas_units + ! print*,'inst_profiles(1)%skin%t: ',inst_profiles(1)%skin%t + ! print*,"inst_profiles(1)%s2m%t: ",inst_profiles(1)%s2m%t + ! print*,'inst_profiles(1)%p(:): ',inst_profiles(1)%p(:) + ! print*,'inst_profiles(1)%t(:): ',inst_profiles(1)%t(:) + ! print*,'inst_profiles(1)%q(:): ',inst_profiles(1)%q(:) + ! print*,'inst_profiles(1)%co2(:): ',inst_profiles(1)%co2(:) + ! print*,'inst_profiles(1)%ch4(:): ',inst_profiles(1)%ch4(:) + ! print*,'inst_profiles(1)%o3(:): ',inst_profiles(1)%o3(:) + ! print*,'inst_profiles(1)%n2o(:): ',inst_profiles(1)%n2o(:) + ! end if + ! if (verbose) then ! print*,'inst_profiles(1)%nlevels: ',inst_profiles(1)%nlevels ! print*,'inst_profiles(1)%nlayers: ',inst_profiles(1)%nlayers From 2f3aa9ebaa7b1f88e4c3ffdde434feefd1cd6f98 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Sun, 22 Sep 2024 12:12:25 -0600 Subject: [PATCH 127/159] Update RTTOV instrument namelists with CAM-like extend_atmos --- driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt | 2 +- driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2.txt | 4 +++- .../run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt | 4 +++- driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt | 4 +++- .../point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt | 2 +- .../point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt | 2 +- .../point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt | 2 +- .../point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt | 2 +- .../point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt | 2 +- .../point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt | 2 +- .../point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt | 2 +- .../point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt | 2 +- .../point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt | 2 +- .../point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt | 2 +- .../point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt | 2 +- .../point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt | 2 +- 16 files changed, 22 insertions(+), 16 deletions(-) diff --git a/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt index bd562ac017..c6d2e7d40b 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt @@ -81,5 +81,5 @@ rttov_localtime=6.75,19.25, ! Local times to sample at in hrs [0,24] rttov_localtime_width=15000,2000, ! Swath width (km) ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. + rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2.txt index a4d347f29a..65f7d2ce65 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2.txt @@ -76,5 +76,7 @@ ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at ! rttov_localtime=0.75,13.5, ! Local times to sample at in hrs [0,24] -! rttov_localtime_width=2.e3,5.6e3, ! Swath width (km) +! rttov_localtime_width=2.e3,5.6e3, ! Swath width (km) + ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. + rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt b/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt index 148097210e..ee26bd5fdb 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt @@ -74,5 +74,7 @@ ! Set local time sampling with swath widths rttov_Nlocaltime=2, ! Number of local times to sample at rttov_localtime=5.75,13.5, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=2000,2000, ! Swath width (km) + rttov_localtime_width=2000,2000, ! Swath width (km) + ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. + rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt index 8089c3dc66..1e2dcae9d5 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt @@ -77,5 +77,7 @@ ! Set local time sampling with swath widths rttov_Nlocaltime=2, ! Number of local times to sample at rttov_localtime=5.75,13.5, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=2000,2000, ! Swath width (km) + rttov_localtime_width=2000,2000, ! Swath width (km) + ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. + rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt index 9a2b9b61cd..74ad8d90b2 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt @@ -76,5 +76,5 @@ rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] rttov_localtime_width=1550,0, ! Swath width (km) ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. + rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt index ace969aa52..9a4dc0f5f8 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt @@ -76,5 +76,5 @@ rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] rttov_localtime_width=1550,0, ! Swath width (km) ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. + rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt index 91c3310d7f..26144a9cfd 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt @@ -76,5 +76,5 @@ rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] rttov_localtime_width=1550,0, ! Swath width (km) ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. + rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt index d288ce6e08..487f3a0756 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt @@ -76,5 +76,5 @@ rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] rttov_localtime_width=1550,0, ! Swath width (km) ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. + rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt index 7f8510ad0c..ba32033f7e 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt @@ -76,5 +76,5 @@ rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] rttov_localtime_width=1550,0, ! Swath width (km) ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. + rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt index 402e2ba43f..d84b8f7359 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt @@ -76,5 +76,5 @@ rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] rttov_localtime_width=1550,0, ! Swath width (km) ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. + rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt index dd742bd937..ab646ac524 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt @@ -77,5 +77,5 @@ rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] rttov_localtime_width=1550,0, ! Swath width (km) ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. + rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt index ebf624d292..491d946c92 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt @@ -77,5 +77,5 @@ rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] rttov_localtime_width=1550,0, ! Swath width (km) ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. + rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt index 5ac9623187..fff0ab0332 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt @@ -77,5 +77,5 @@ rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] rttov_localtime_width=1550,0, ! Swath width (km) ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. + rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt index 22db1936cd..26c620d4f8 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt @@ -77,5 +77,5 @@ rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] rttov_localtime_width=1550,0, ! Swath width (km) ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. + rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt index 2519e4fc20..affb9cdc10 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt @@ -77,5 +77,5 @@ rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] rttov_localtime_width=1550,0, ! Swath width (km) ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. + rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt index 3d613d33e3..4ce395d1b2 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt @@ -77,5 +77,5 @@ rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] rttov_localtime_width=1550,0, ! Swath width (km) ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. + rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / From 283dd1f16c46785edb276951454ff49c6003af79 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Sun, 22 Sep 2024 13:35:04 -0600 Subject: [PATCH 128/159] Enable user input to determine cloud optics schemes used by RTTOV --- src/simulator/cosp_rttov_interface_v13.F90 | 43 ++++++++++++- src/simulator/rttov/cosp_rttov_v13.F90 | 70 +++++++++++++--------- 2 files changed, 83 insertions(+), 30 deletions(-) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index ac5bdc6821..2a52ac46eb 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -102,6 +102,9 @@ MODULE MOD_COSP_RTTOV_INTERFACE nchannels_rec, & rttov_Nlocaltime, & gas_units, & + clw_scheme, & + ice_scheme, & + icede_param, & rttov_extendatmos, & nprof real(wp) :: & @@ -117,6 +120,7 @@ MODULE MOD_COSP_RTTOV_INTERFACE real(kind=jprb), allocatable :: & emisChannel(:), & ! RTTOV channel emissivity reflChannel(:), & ! RTTOV channel reflectivity + wavenumChannel(:), & ! RTTOV channel wavenumber rttov_localtime(:), & rttov_localtime_width(:) type(rttov_options) :: & @@ -207,6 +211,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & ! Local variables character(len=256),target :: & channel_filepath, & + wavenum_filepath, & rttov_srcDir, & rttov_coefDir, & OD_coef_filepath, & @@ -235,6 +240,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & logical :: Lrttov_pc logical :: Lrttov_solar logical :: Lchannel_filepath + logical :: Lwavenum_filepath logical :: user_tracegas_input logical :: SO2_data logical :: N2O_data @@ -261,6 +267,9 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & integer(kind=jpim) :: & rttov_Nlocaltime, & ! Number of orbits rttov_gas_units, & ! RTTOV units for trace gases: 0 ppmv over dry air, 1 kg/kg over moist air, 2 ppmv over moist air, 3 kg/kg over dry air + rttov_clw_scheme, & ! Scheme for determining cloud water optical properties. + rttov_ice_scheme, & ! Scheme for determining cloud ice optical properties. + rttov_icede_param, & ! Scheme for how cloud ice deff is parameterized rttov_extendatmos real(wp),dimension(20) :: & ! Reasonable but arbitrary limit at 10 local time orbits rttov_localtime, & ! RTTOV subsetting by local time in hours [0,24] @@ -289,6 +298,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & Lrttov_pc = .false. Lrttov_solar = .false. Lchannel_filepath = .false. + Lwavenum_filepath = .false. SO2_data = .false. N2O_data = .false. CO_data = .false. @@ -298,7 +308,10 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & clw_data = .false. user_tracegas_input = .false. rttov_Nlocaltime = 0 ! Default: zero swath masking - rttov_gas_units = 1 ! Default: kg/kg over moist air (should be updated!) + rttov_gas_units = 1 ! Default: kg/kg over moist air (should be updated by user!) + rttov_clw_scheme = 1 ! 1: OPAC, 2: Deff + rttov_ice_scheme = 1 ! 0: Ice radii used, 1: Baum, 2: Baran (2014), 3: Baran (2018) + rttov_icede_param = 0 ! 0: Indicates that Deff is supplied but is rejected by RTTOV. 1: Ou and Liou, 2: Wyser(recommended), 3: Boudala, 4: McFarquhar. rttov_extendatmos = 0 ! 0: do not extend above supplied pressure levels. 1: Simply top layer. 2: Not yet implemented. ! Read RTTOV namelist fields @@ -306,7 +319,8 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & Lrttov_aer,Lrttov_cldparam,Lrttov_aerparam, & ! Lrttov_gridbox_cldmmr,Ldo_nlte_correction, & ! Assume cloud water mixing ratios are gridbox average instead of in-cloud Lrttov_pc,Lrttov_solar,nchannels_rec,Lchannel_filepath, & - channel_filepath,rttov_srcDir,rttov_coefDir, & + channel_filepath,Lwavenum_filepath,wavenum_filepath, & + rttov_srcDir,rttov_coefDir, & OD_coef_filepath,aer_coef_filepath,cld_coef_filepath, & PC_coef_filepath, & CO2_data,CH4_data,CO_data,N2O_data,SO2_data,ozone_data, & ! Use trace gases for radiative transfer? @@ -316,7 +330,8 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & ipcbnd,ipcreg,npcscores, & ! PC-RTTOV config values rttov_nthreads,rttov_ZenAng,rttov_Nlocaltime, & rttov_localtime,rttov_localtime_width, & - rttov_gas_units,rttov_extendatmos + rttov_gas_units,rttov_clw_scheme,rttov_ice_scheme, & + rttov_icede_param,rttov_extendatmos !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Read in namelists @@ -380,6 +395,11 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & rttov_config%user_tracegas_input = user_tracegas_input rttov_config%gas_units = rttov_gas_units + ! Parametrization of cloud optical properties. + rttov_config%clw_scheme = rttov_clw_scheme + rttov_config%ice_scheme = rttov_ice_scheme + rttov_config%icede_param = rttov_icede_param + rttov_config%SO2_mr = SO2_mr rttov_config%N2O_mr = N2O_mr rttov_config%CO_mr = CO_mr @@ -591,6 +611,14 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & allocate(rttov_config % iChannel(rttov_config % nchan_out)) ! There is a need for these variables to be separate somewhere... allocate(rttov_config % iChannel_out(rttov_config % nchan_out)) + if (Lwavenum_filepath) then + allocate(rttov_config % wavenumChannel(rttov_config % nchan_out)) + open(18,file=wavenum_filepath,access='sequential',form="formatted") + do i = 1, rttov_config % nchan_out + read(18,*) rttov_config % wavenumChannel(i) + end do + close(18) + end if if (Lchannel_filepath) then allocate(rttov_config % emisChannel(rttov_config % nchan_out)) allocate(rttov_config % reflChannel(rttov_config % nchan_out)) @@ -622,6 +650,9 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & print*,'rttov_config % rttov_localtime_width: ',rttov_config % rttov_localtime_width print*,'rttov_config % rttov_extendatmos: ',rttov_config % rttov_extendatmos print*,'rttov_config % gas_units: ',rttov_config % gas_units + print*,'rttov_config % clw_scheme: ',rttov_config % clw_scheme + print*,'rttov_config % ice_scheme: ',rttov_config % ice_scheme + print*,'rttov_config % icede_param: ',rttov_config % icede_param end if ! subsub routines @@ -818,6 +849,9 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig, rttovConfig % nprof, & rttovConfig % swath_mask, & rttovConfig % gas_units, & + rttovConfig % clw_scheme, & + rttovConfig % ice_scheme, & + rttovConfig % icede_param, & rttovConfig % rttov_extendatmos, & verbose) @@ -980,6 +1014,9 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig, rttovConfig % nprof, & rttovConfig % swath_mask, & rttovConfig % gas_units, & + rttovConfig % clw_scheme, & + rttovConfig % ice_scheme, & + rttovConfig % icede_param, & rttovConfig % rttov_extendatmos, & verbose) call cpu_time(driver_time(3)) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 5288e6e30c..3d8e33a9e7 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -525,28 +525,31 @@ end subroutine cosp_pc_rttov_allocate ! Largely from cosp_rttov_v11.F90 file. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_rttov_construct_profiles(rttovIN, & - inst_profiles, & - Lrttov_cld, & - Lrttov_aer, & - Lrttov_solar, & - Luser_tracegas, & - Ldo_co2, & - Ldo_ch4, & - Ldo_co, & - Ldo_n2o, & - Ldo_so2, & - Ldo_o3, & - inst_co2_mr, & - inst_ch4_mr, & - inst_co_mr, & - inst_n2o_mr, & - inst_so2_mr, & - inst_zenang, & - inst_nprof, & - inst_swath_mask,& - inst_gas_units, & - inst_extend_atmos,& + subroutine cosp_rttov_construct_profiles(rttovIN, & + inst_profiles, & + Lrttov_cld, & + Lrttov_aer, & + Lrttov_solar, & + Luser_tracegas, & + Ldo_co2, & + Ldo_ch4, & + Ldo_co, & + Ldo_n2o, & + Ldo_so2, & + Ldo_o3, & + inst_co2_mr, & + inst_ch4_mr, & + inst_co_mr, & + inst_n2o_mr, & + inst_so2_mr, & + inst_zenang, & + inst_nprof, & + inst_swath_mask, & + inst_gas_units, & + inst_clw_scheme, & + inst_ice_scheme, & + inst_icede_param, & + inst_extend_atmos, & debug) type(rttov_in),intent(in) :: & @@ -574,6 +577,9 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & integer(kind=jpim),intent(in) :: & inst_nprof, & inst_gas_units, & + inst_clw_scheme, & + inst_ice_scheme, & + inst_icede_param, & inst_extend_atmos logical(kind=jplm),dimension(rttovIN % nPoints),intent(in) :: & inst_swath_mask @@ -833,10 +839,18 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & ! Set cloud mass mixing ratio units inst_profiles(:)%mmr_cldaer = .true. ! kg/kg for cloud and aerosol (default) - inst_profiles(:)%clw_scheme = 2 ! Deff scheme avoids cloud types but requires an effective diameter value - ! inst_profiles(:)%clwde_scheme = 1. ! Scheme for cloud liquid water cotent to effective diameter. User guide says do not change. - inst_profiles(:)%ice_scheme = 1 !1:Baum 2:Baran(2014) 3:Baran(2018) - inst_profiles(:)%icede_param = 2 ! 2:Wyser(recommended). Only used if ice effective diameter not input + ! See RTTOV documentation page 75 for details. + inst_profiles(:)%clw_scheme = inst_clw_scheme ! 1: OPAC 2: Deff + inst_profiles(:)%ice_scheme = inst_ice_scheme ! 1:Baum 2:Baran(2014) 3:Baran(2018) + if (inst_icede_param .eq. 0) then ! Need a filler even if icede is suppled + inst_profiles(:)%icede_param = 2 + else ! Only use the model diameters if icede_param supplied on [1:4] + inst_profiles(:)%icede_param = inst_icede_param ! 1: Ou and Liou, 2: Wyser(recommended), 3: Boudala, 4: McFarquhar. Only used if ice effective diameter not input + end if + ! inst_profiles(:)%clw_scheme = 2 ! Deff scheme avoids cloud types but requires an effective diameter value + ! ! inst_profiles(:)%clwde_scheme = 1. ! Scheme for cloud liquid water cotent to effective diameter. User guide says do not change. + ! inst_profiles(:)%ice_scheme = 1 !1:Baum 2:Baran(2014) 3:Baran(2018) + ! inst_profiles(:)%icede_param = 2 ! 2:Wyser(recommended). Only used if ice effective diameter not input j = 0 ! Initialize input do i = 1,rttovIN%nPoints @@ -850,7 +864,9 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & inst_profiles(j)%cloud(6,modeltop_index:inst_profiles(j)%nlayers) = rttovIN%cldIce(i,:) ! Cloud ice mixing ratio (1 type). See pg 74. inst_profiles(j)%clwde(modeltop_index:inst_profiles(j)%nlayers) = rttovIN%DeffLiq(i,:) ! Cloud water effective diameter (um) - inst_profiles(j)%icede(modeltop_index:inst_profiles(j)%nlayers) = rttovIN%DeffIce(i,:) ! Cloud ice effective diameter (um) + if (inst_icede_param .eq. 0) then ! Only use the model diameters if icede_param supplied + inst_profiles(j)%icede(modeltop_index:inst_profiles(j)%nlayers) = rttovIN%DeffIce(i,:) ! Cloud ice effective diameter (um) + end if ! Example UKMO input has effective radii for multiple cloud types, making identification of a single ! liquid droplet or ice crystal effective diameter difficult. From f082a89100f3672ee43b1be81b1b42b60d77e3ee Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 24 Sep 2024 12:11:54 -0600 Subject: [PATCH 129/159] Update namelists with the best cloud optics schemes for SCAM agreement (clw_scheme=2, ice_scheme=1, icede_param=4). --- driver/run/instrument_nls/cosp2_rttov_inst1.txt | 6 ++++++ .../run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt | 4 ++++ driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2.txt | 4 ++++ .../run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt | 4 ++++ driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt | 6 +++++- .../point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt | 6 +++++- .../point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt | 6 +++++- .../point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt | 4 ++++ .../point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt | 4 ++++ .../point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt | 4 ++++ .../point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt | 4 ++++ .../point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt | 4 ++++ .../point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt | 4 ++++ .../point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt | 4 ++++ .../point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt | 4 ++++ .../point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt | 4 ++++ .../point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt | 4 ++++ src/simulator/cosp_rttov_interface_v13.F90 | 4 ++-- 18 files changed, 75 insertions(+), 5 deletions(-) diff --git a/driver/run/instrument_nls/cosp2_rttov_inst1.txt b/driver/run/instrument_nls/cosp2_rttov_inst1.txt index d012d34407..2b8dd9afe9 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst1.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst1.txt @@ -76,4 +76,10 @@ rttov_ZenAng=0.0, ! Satellite Zenith Angle ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at + ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) + rttov_clw_scheme=2, + rttov_ice_scheme=2, + rttov_icede_param=2, + ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. + rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt index c6d2e7d40b..0826cfaae8 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt @@ -80,6 +80,10 @@ rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=6.75,19.25, ! Local times to sample at in hrs [0,24] rttov_localtime_width=15000,2000, ! Swath width (km) + ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) + rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. + rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. + rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2.txt index 65f7d2ce65..cd247daf05 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2.txt @@ -77,6 +77,10 @@ rttov_Nlocaltime=0, ! Number of local times to sample at ! rttov_localtime=0.75,13.5, ! Local times to sample at in hrs [0,24] ! rttov_localtime_width=2.e3,5.6e3, ! Swath width (km) + ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) + rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. + rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. + rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt b/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt index ee26bd5fdb..1e3970eba9 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt @@ -75,6 +75,10 @@ rttov_Nlocaltime=2, ! Number of local times to sample at rttov_localtime=5.75,13.5, ! Local times to sample at in hrs [0,24] rttov_localtime_width=2000,2000, ! Swath width (km) + ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) + rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. + rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. + rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt index 1e2dcae9d5..0ee8381032 100644 --- a/driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt +++ b/driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt @@ -75,9 +75,13 @@ rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air rttov_ZenAng=0.0, ! Satellite Zenith Angle ! Set local time sampling with swath widths - rttov_Nlocaltime=2, ! Number of local times to sample at + rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=5.75,13.5, ! Local times to sample at in hrs [0,24] rttov_localtime_width=2000,2000, ! Swath width (km) + ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) + rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. + rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. + rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt index 74ad8d90b2..59ac2ba8bb 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt @@ -74,7 +74,11 @@ ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) + rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) + rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. + rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. + rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt index 9a4dc0f5f8..f9ce5e772b 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt @@ -74,7 +74,11 @@ ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) + rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) + rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. + rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. + rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt index 26144a9cfd..9dcbe9f23f 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt @@ -75,6 +75,10 @@ rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) + rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. + rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. + rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt index 487f3a0756..bd8953f7bc 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt @@ -75,6 +75,10 @@ rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) + rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. + rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. + rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt index ba32033f7e..63a30d0ca2 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt @@ -75,6 +75,10 @@ rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) + rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. + rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. + rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt index d84b8f7359..6f6ea7ed43 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt @@ -75,6 +75,10 @@ rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) + rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. + rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. + rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt index ab646ac524..ef0acdaac2 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt @@ -76,6 +76,10 @@ rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) + rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. + rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. + rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt index 491d946c92..fdda705a9c 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt @@ -76,6 +76,10 @@ rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) + rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. + rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. + rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt index fff0ab0332..913b14b2f3 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt @@ -76,6 +76,10 @@ rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) + rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. + rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. + rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt index 26c620d4f8..3e03847cd5 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt @@ -76,6 +76,10 @@ rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) + rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. + rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. + rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt index affb9cdc10..c2ff405125 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt @@ -76,6 +76,10 @@ rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) + rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. + rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. + rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt index 4ce395d1b2..48f02f3e30 100644 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt +++ b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt @@ -76,6 +76,10 @@ rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) + rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. + rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. + rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 2a52ac46eb..7c59ddb886 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -309,8 +309,8 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & user_tracegas_input = .false. rttov_Nlocaltime = 0 ! Default: zero swath masking rttov_gas_units = 1 ! Default: kg/kg over moist air (should be updated by user!) - rttov_clw_scheme = 1 ! 1: OPAC, 2: Deff - rttov_ice_scheme = 1 ! 0: Ice radii used, 1: Baum, 2: Baran (2014), 3: Baran (2018) + rttov_clw_scheme = 2 ! 1: OPAC, 2: Deff + rttov_ice_scheme = 1 ! 1: Baum, 2: Baran (2014), 3: Baran (2018) rttov_icede_param = 0 ! 0: Indicates that Deff is supplied but is rejected by RTTOV. 1: Ou and Liou, 2: Wyser(recommended), 3: Boudala, 4: McFarquhar. rttov_extendatmos = 0 ! 0: do not extend above supplied pressure levels. 1: Simply top layer. 2: Not yet implemented. From 136064c41ada3aa93a21aae4ac6d70fb46cf7615 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 15 Oct 2024 17:09:46 -0600 Subject: [PATCH 130/159] Minor changes before hunting for a memory leak --- src/simulator/cosp_rttov_interface_v13.F90 | 4 +++- src/simulator/rttov/cosp_rttov_v13.F90 | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 7c59ddb886..846ec37025 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -364,6 +364,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & endif ! Set swath arrays correctly. + ! if (verbose) print*,"allocating rttov_config%rttov_localtime and rttov_config%rttov_localtime_width" allocate(rttov_config%rttov_localtime(rttov_Nlocaltime),rttov_config%rttov_localtime_width(rttov_Nlocaltime)) rttov_config%rttov_Nlocaltime = rttov_Nlocaltime rttov_config%rttov_localtime(:) = rttov_localtime(1:rttov_Nlocaltime) @@ -737,6 +738,7 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,error, rttovConfig % rttov_localtime_width, & rttovConfig % swath_mask, & debug) + ! rttovConfig % swath_mask(:) = .true. ! JKS - for now, just set everything to true rttovConfig % nprof = count(rttovConfig % swath_mask) if (rttovConfig % nprof .gt. 0) then ! Skip calculations if all values are swathed out @@ -872,7 +874,7 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig, end if call cpu_time(driver_time(4)) - !if (verbose) print*,'Beginning "cosp_rttov_call_direct".' + ! if (verbose) print*,'Beginning "cosp_rttov_call_direct".' call cosp_rttov_call_direct(rttovConfig % rttov_direct_nthreads, & rttovConfig % opts, & profiles, & diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 3d8e33a9e7..4759465aaa 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -303,7 +303,6 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs, ! Loop variables integer(kind=jpim) :: j, jch, nch, nlevels_rttov - logical :: verbose = .false. if (present(debug)) verbose = debug @@ -446,7 +445,6 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, call rttov_get_pc_predictindex(errorstatus, inst_opts, inst_predictindex, file_pccoef=inst_PC_coef_filepath) call rttov_error('rttov_get_pc_predictindex fatal error' , lalloc = .false.) - ! Determine the total number of radiances to simulate (nchanprof). inst_npred_pc = SIZE(inst_predictindex) inst_nchanprof = inst_npred_pc * inst_nprof ! Size of chanprof array is total number of predictors over all profiles From d01f1aedca25b3ab31da95849a9e2d6a3c2f3d13 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 15 Oct 2024 17:44:33 -0600 Subject: [PATCH 131/159] Add error checks in profile set-up --- src/simulator/rttov/cosp_rttov_v13.F90 | 35 +++++++++++++++----------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 4759465aaa..13252fadad 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -302,7 +302,6 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs, !---- Local variables ----! ! Loop variables integer(kind=jpim) :: j, jch, nch, nlevels_rttov - logical :: verbose = .false. if (present(debug)) verbose = debug @@ -606,7 +605,12 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & if (i .gt. rttovIN%nPoints) exit if (inst_swath_mask(i)) then ! only added masked columns to profiles j = j + 1 ! Increment first - + ! Ensure j is within bounds + if (j > size(inst_profiles)) then + call rttov_error('Profile index out of bounds in main loop', lalloc = .false.) + if (verbose) print*,"Went too far for inst_profiles in main loop" + exit + end if ! To imitate CAM6-RRTMG, set a model top index. If inst_extend_atmos==1 then just increment that index by one and retroactively apply it to the top layer. ! This will be the same index that the vertical interpolation operates over so it will fix that too! @@ -615,7 +619,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & inst_profiles(j)%p(:) = rttovIN%ph(i, :) * 1e-2 ! convert Pa to hPa. Pressure on levels. if (inst_profiles(j)%p(1) .le. 0) inst_profiles(j)%p(1) = 2.25 ! If the model top is set to zero (like the COSPv2 driver and CAM6) make it 2.25mb. CAM-like correction modeltop_index = 1 - else if (inst_extend_atmos==1) then + else if (inst_extend_atmos == 1) then modeltop_index = 2 inst_profiles(j)%p(1) = 1e-4 inst_profiles(j)%p(2) = 2.25 @@ -824,9 +828,6 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & end if end do - - ! JKS - nothing to check here, this will never trigger. - call rttov_error('error in profile initialization' , lalloc = .false.) ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Only add the cloud fields if simulating cloud. @@ -855,7 +856,11 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & if (i .gt. rttovIN%nPoints) exit if (inst_swath_mask(i)) then ! only added masked columns to profiles j = j + 1 ! Increment profile counter - + if (j > size(inst_profiles)) then + call rttov_error('Profile index out of bounds in Lrttov_cld loop', lalloc = .false.) + if (verbose) print*,"Went too far for inst_profiles in Lrttov_cld loop" + exit + end if ! Cloud scheme stuff. Values are on layers, not levels like the gas concentrations. inst_profiles(j)%cfrac(modeltop_index:inst_profiles(j)%nlayers) = rttovIN%tca(i,:) ! Cloud fraction for each layer inst_profiles(j)%cloud(1,modeltop_index:inst_profiles(j)%nlayers) = rttovIN%cldLiq(i,:) ! Cloud water mixing ratio (all in the first type for Deff) @@ -882,10 +887,6 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & end if end do end if - - ! JKS - nothing to check here, this will never trigger. - call rttov_error('error in cloud profile initialization' , lalloc = .false.) - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Only add the aerosol fields if simulating aerosol. @@ -914,7 +915,13 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & do i = 1,rttovIN%nPoints if (i .gt. rttovIN%nPoints) exit if (inst_swath_mask(i)) then ! only added masked columns to profiles - j = j + 1 ! Increment profile counter + j = j + 1 ! Increment profile counter + ! Ensure j is within bounds + if (j > size(inst_profiles)) then + call rttov_error('Profile index out of bounds in Lrttov_solar loop', lalloc = .false.) + if (verbose) print*,"Went too far for inst_profiles in Lrttov_solar loop" + exit + end if inst_profiles(j)%date(:) = rttovIN%rttov_date(i,:) inst_profiles(j)%time(:) = rttovIN%rttov_time(i,:) end if @@ -973,7 +980,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & ! end if ! JKS - nothing to check here, this will never trigger. - call rttov_error('error in aerosol profile initialization' , lalloc = .true.) + ! call rttov_error('error in aerosol profile initialization' , lalloc = .true.) ! JKS To-do: set up scattering profiles (MW only) (rttov_profile_cloud) @@ -1107,7 +1114,6 @@ subroutine cosp_rttov_call_direct(inst_nthreads, & print*,'shape(inst_chanprof%prof): ',shape(inst_chanprof%prof) print*,'shape(inst_chanprof%chan): ',shape(inst_chanprof%chan) print*,'shape(inst_profiles): ',shape(inst_profiles) -! print*,'shape(inst_profiles(:)%q): ',shape(inst_profiles(:)%q) end if ! print*,'NTHRDS tests' @@ -1269,7 +1275,6 @@ subroutine cosp_rttov_save_output(nPoints,inst_nchan_out,inst_swath_mask, & integer :: i, j ! Documentation for RTTOV radiance structure in RTTOV User Guide pg 166 - ! Only save output if appropriate if (count(inst_swath_mask) .eq. nPoints) then ! No swathing, save all output if (Lrttov_bt) then From 26d0abe5a646d9f2e6e8cb0ee071117ed16545ac Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Mon, 21 Oct 2024 12:01:37 -0600 Subject: [PATCH 132/159] Picky changes about indexing and a few print statements for memory leak hunting. --- src/simulator/cosp_rttov_interface_v13.F90 | 15 +++++----- src/simulator/rttov/cosp_rttov_v13.F90 | 33 +++++++++++++--------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 846ec37025..0c90b1863a 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -62,16 +62,15 @@ MODULE MOD_COSP_RTTOV_INTERFACE IMPLICIT NONE -#include "rttov_scatt.interface" -#include "rttov_parallel_scatt.interface" -#include "rttov_read_scattcoeffs.interface" -#include "rttov_dealloc_scattcoeffs.interface" -#include "rttov_scatt_setupindex.interface" +! #include "rttov_scatt.interface" +! #include "rttov_parallel_scatt.interface" +! #include "rttov_read_scattcoeffs.interface" +! #include "rttov_dealloc_scattcoeffs.interface" +! #include "rttov_scatt_setupindex.interface" #include "rttov_read_coefs.interface" #include "rttov_user_options_checkinput.interface" #include "rttov_print_opts.interface" -#include "rttov_get_pc_predictindex.interface" ! RTTOV variables/structures. !==================== @@ -654,6 +653,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & print*,'rttov_config % clw_scheme: ',rttov_config % clw_scheme print*,'rttov_config % ice_scheme: ',rttov_config % ice_scheme print*,'rttov_config % icede_param: ',rttov_config % icede_param + call rttov_print_opts(rttov_config % opts) ! JKS testing end if ! subsub routines @@ -885,7 +885,8 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig, calcemis, & emissivity, & calcrefl, & - reflectance) + reflectance, & + verbose) call cpu_time(driver_time(5)) diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 13252fadad..8a4d7618bf 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -81,11 +81,11 @@ module mod_cosp_rttov !#include "rttov_dealloc_coef_pccomp.interface" ! Includes when directly inputting cloud optical parameters -#include "rttov_init_opt_param.interface" -#include "rttov_bpr_init.interface" -#include "rttov_bpr_calc.interface" -#include "rttov_bpr_dealloc.interface" -#include "rttov_legcoef_calc.interface" +! #include "rttov_init_opt_param.interface" +! #include "rttov_bpr_init.interface" +! #include "rttov_bpr_calc.interface" +! #include "rttov_bpr_dealloc.interface" +! #include "rttov_legcoef_calc.interface" #include "rttov_calc_solar_angles.interface" ! Scattering coefficients (read in once during initialization) @@ -616,7 +616,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & ! top layer thickness if (inst_extend_atmos == 0) then - inst_profiles(j)%p(:) = rttovIN%ph(i, :) * 1e-2 ! convert Pa to hPa. Pressure on levels. + inst_profiles(j)%p(1:inst_profiles(j)%nlevels) = rttovIN%ph(i, :) * 1e-2 ! convert Pa to hPa. Pressure on levels. if (inst_profiles(j)%p(1) .le. 0) inst_profiles(j)%p(1) = 2.25 ! If the model top is set to zero (like the COSPv2 driver and CAM6) make it 2.25mb. CAM-like correction modeltop_index = 1 else if (inst_extend_atmos == 1) then @@ -643,12 +643,12 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & ! Trace gas concentrations on levels (not layers!) ! Initialize trace gas concentrations from user input. if (Luser_tracegas) then - if (Ldo_co2) inst_profiles(j)%co2(:) = inst_co2_mr - if (Ldo_n2o) inst_profiles(j)%n2o(:) = inst_n2o_mr - if (Ldo_co) inst_profiles(j)%co(:) = inst_co_mr - if (Ldo_ch4) inst_profiles(j)%ch4(:) = inst_ch4_mr - if (Ldo_so2) inst_profiles(j)%so2(:) = inst_so2_mr - ! if (Ldo_o3) inst_profiles(j)%o3(:) = rttovIN%o3(i, :) + if (Ldo_co2) inst_profiles(j)%co2(1:inst_profiles(j)%nlevels) = inst_co2_mr + if (Ldo_n2o) inst_profiles(j)%n2o(1:inst_profiles(j)%nlevels) = inst_n2o_mr + if (Ldo_co) inst_profiles(j)%co(1:inst_profiles(j)%nlevels) = inst_co_mr + if (Ldo_ch4) inst_profiles(j)%ch4(1:inst_profiles(j)%nlevels) = inst_ch4_mr + if (Ldo_so2) inst_profiles(j)%so2(1:inst_profiles(j)%nlevels) = inst_so2_mr + ! if (Ldo_o3) inst_profiles(j)%o3(1:inst_profiles(j)%nlevels) = rttovIN%o3(i, :) if (Ldo_o3) then ! no O3 user input set up call interpolate_logp(100*inst_profiles(j)%p(modeltop_index),rttovIN%p(i,1),rttovIN%p(i,2),rttovIN%o3(i,1),rttovIN%o3(i,2),inst_profiles(j)%o3(modeltop_index)) call interpolate_logp(100*inst_profiles(j)%p(inst_profiles(j)%nlevels),rttovIN%p(i,rttovIN%nlevels-1),rttovIN%p(i,rttovIN%nlevels),rttovIN%o3(i,rttovIN%nlevels-1),rttovIN%o3(i,rttovIN%nlevels),inst_profiles(j)%o3(inst_profiles(j)%nlevels)) @@ -828,7 +828,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & end if end do - + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Only add the cloud fields if simulating cloud. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1114,6 +1114,10 @@ subroutine cosp_rttov_call_direct(inst_nthreads, & print*,'shape(inst_chanprof%prof): ',shape(inst_chanprof%prof) print*,'shape(inst_chanprof%chan): ',shape(inst_chanprof%chan) print*,'shape(inst_profiles): ',shape(inst_profiles) + print*,'inst_profiles(1)' + call rttov_print_profile(inst_profiles(1)) + print*,'inst_profiles(size(inst_profiles))' + call rttov_print_profile(inst_profiles(size(inst_profiles))) end if ! print*,'NTHRDS tests' @@ -1305,7 +1309,8 @@ subroutine cosp_rttov_save_output(nPoints,inst_nchan_out,inst_swath_mask, & refl_clear(1:nPoints, 1:inst_nchan_out) = & transpose(reshape(inst_radiance%refl_clear(1:inst_nchan_out * nPoints), (/ inst_nchan_out, nPoints/) )) end if - else ! If swathing is occurring, assign the outputs appropriately + else ! If swathing is occurring, assign the outputs appropriately. + ! The radiance structure has shape nchanprof and the outputs have shape (nPoints, inst_nchan_out) j = 0 do i=1,nPoints ! if (i .gt. nPoints) exit From 0375a17ca843380f02466b3138de4ec66d8d04cc Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Mon, 21 Oct 2024 12:02:16 -0600 Subject: [PATCH 133/159] AIRS namelist files for swathing with correct cloud optics schemes. --- .../cosp2_rttov_AIRS_L1C_CESM2.txt | 6 +- .../cosp2_rttov_AIRS_L1C_CESM2_asc.txt | 85 +++++++++++++++++++ .../cosp2_rttov_AIRS_L1C_CESM2_des.txt | 85 +++++++++++++++++++ 3 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2_asc.txt create mode 100644 driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2_des.txt diff --git a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2.txt index 165a737823..5c7f627252 100644 --- a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2.txt +++ b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2.txt @@ -76,6 +76,10 @@ rttov_Nlocaltime=0, ! Number of local times to sample at rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) + rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. + rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. + rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=0, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. + rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. / diff --git a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2_asc.txt b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2_asc.txt new file mode 100644 index 0000000000..862ba412a8 --- /dev/null +++ b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2_asc.txt @@ -0,0 +1,85 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.true., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? + Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=45, ! 2645 for all AIRS L1C channels, 45 channel subset mostly from Sergio + !-------------- RTTOV Filepaths + Lchannel_filepath=.true., + channel_filepath='rttov_channel_input_AIRSL1C_subset.csv' + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + ! OD_coef_filepath='AIRS_L1C/rtcoef_eos_2_airs_l1c_o3co2.H5', + OD_coef_filepath='AIRS_L1C/rtcoef_eos_2_airs_l1c_7gas.H5', ! Full version with N20 and CH4 + cld_coef_filepath='AIRS_L1C/sccldcoef_eos_2_airs_l1c.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.true., ! .true. for 7gas + CO_data=.false., + CO2_data=.true., + CH4_data=.true., ! .true. for 7gas + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=6.09e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air + rttov_ZenAng=0.0, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=1, ! Number of local times to sample at + rttov_localtime=13.5, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1800, ! Swath width (km) + ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) + rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. + rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. + rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. + ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. + rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. +/ diff --git a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2_des.txt b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2_des.txt new file mode 100644 index 0000000000..14e1c158b8 --- /dev/null +++ b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2_des.txt @@ -0,0 +1,85 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.true., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? + Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=45, ! 2645 for all AIRS L1C channels, 45 channel subset mostly from Sergio + !-------------- RTTOV Filepaths + Lchannel_filepath=.true., + channel_filepath='rttov_channel_input_AIRSL1C_subset.csv' + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + ! OD_coef_filepath='AIRS_L1C/rtcoef_eos_2_airs_l1c_o3co2.H5', + OD_coef_filepath='AIRS_L1C/rtcoef_eos_2_airs_l1c_7gas.H5', ! Full version with N20 and CH4 + cld_coef_filepath='AIRS_L1C/sccldcoef_eos_2_airs_l1c.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.true., ! .true. for 7gas + CO_data=.false., + CO2_data=.true., + CH4_data=.true., ! .true. for 7gas + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=6.09e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air + rttov_ZenAng=0.0, ! Satellite Zenith Angle + ! Set local time sampling with swath widths + rttov_Nlocaltime=1, ! Number of local times to sample at + rttov_localtime=1.5, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1800, ! Swath width (km) + ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) + rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. + rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. + rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. + ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. + rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. +/ From 731b7c613786deec0831ed57c327c1bf1df17008 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Mon, 21 Oct 2024 12:03:09 -0600 Subject: [PATCH 134/159] Namelist files for memory leak testing. Run with ./cosp2_test cosp2_input_rttov_swathleak_nl.txt cosp2_output_rttov_swathleak_nl.txt --- driver/run/cosp2_input_rttov_swathleak_nl.txt | 109 +++++++++++++ .../run/cosp2_output_rttov_swathleak_nl.txt | 152 ++++++++++++++++++ 2 files changed, 261 insertions(+) create mode 100644 driver/run/cosp2_input_rttov_swathleak_nl.txt create mode 100644 driver/run/cosp2_output_rttov_swathleak_nl.txt diff --git a/driver/run/cosp2_input_rttov_swathleak_nl.txt b/driver/run/cosp2_input_rttov_swathleak_nl.txt new file mode 100644 index 0000000000..654898f015 --- /dev/null +++ b/driver/run/cosp2_input_rttov_swathleak_nl.txt @@ -0,0 +1,109 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&COSP_INPUT + NPOINTS=153,! Number of gridpoints 153,27840,7081,6912 + NPOINTS_IT=5000,! 50,5000, Max number of gridpoints to be processed in one iteration + NCOLUMNS=20, ! Number of subcolumns + NLEVELS=38, ! Number of model levels + USE_VGRID=.true., ! Use fixed vertical grid for outputs? (if .true. then you need to define number of levels with Nlr) + NLVGRID=40, ! Number of levels in statistical outputs (only used if USE_VGRID=.true.) + CSAT_VGRID=.true., ! CloudSat vertical grid? (if .true. then the CloudSat standard grid is used for the outputs. + ! USE_VGRID needs also be .true.) + DINPUT='./', ! Directory where the input files are located. Useful when processing multiple files. + ! Leave blank ('') if you are using the full path in FINPUT. + FINPUT='../data/inputs/UKMO/cosp_input_um.nc', ! List input NetCDF files + FOUTPUT='../data/outputs/UKMO/cosp2_output_rttov_um_bin.nc', + !---------------------------------------------------------------------------------- + !--------------- Inputs related to radar simulations + !---------------------------------------------------------------------------------- + cloudsat_RADAR_FREQ=94.0, ! CloudSat radar frequency (GHz) + SURFACE_RADAR=0, ! surface=1, spaceborne=0 + cloudsat_use_gas_abs=1, ! include gaseous absorption? yes=1,no=0 + cloudsat_do_ray=0, ! calculate/output Rayleigh refl=1, not=0 + cloudsat_k2=-1, ! |K|^2, -1=use frequency dependent default + use_precipitation_fluxes=.true., ! True if precipitation fluxes are input to the algorithm + cloudsat_micro_scheme='MMF_v3_single_moment', !'MMF_v3.5_two_moment' + !---------------------------------------------------------------------------------- + !---------------- Inputs related to lidar simulations + !---------------------------------------------------------------------------------- + lidar_ice_type=0, ! Ice particle shape in lidar calculations (0=ice-spheres ; 1=ice-non-spherical) + OVERLAP=3, ! overlap assumption used by scops: 1=max, 2=rand, 3=max/rand + !---------------------------------------------------------------------------------- + !---------------- Inputs related to ISCCP simulator + !---------------------------------------------------------------------------------- + ISCCP_TOPHEIGHT=1, ! 1 = adjust top height using both a computed + ! infrared brightness temperature and the visible + ! optical depth to adjust cloud top pressure. Note + ! that this calculation is most appropriate to compare + ! to ISCCP data during sunlit hours. + ! 2 = do not adjust top height, that is cloud top + ! pressure is the actual cloud top pressure + ! in the model + ! 3 = adjust top height using only the computed + ! infrared brightness temperature. Note that this + ! calculation is most appropriate to compare to ISCCP + ! IR only algortihm (i.e. you can compare to nighttime + ! ISCCP data with this option) + ISCCP_TOPHEIGHT_DIRECTION=2, ! direction for finding atmosphere pressure level + ! with interpolated temperature equal to the radiance + ! determined cloud-top temperature + ! 1 = find the *lowest* altitude (highest pressure) level + ! with interpolated temperature equal to the radiance + ! determined cloud-top temperature + ! 2 = find the *highest* altitude (lowest pressure) level + ! with interpolated temperature equal to the radiance + ! determined cloud-top temperature. This is the + ! default value since V4.0 of the ISCCP simulator. + ! ONLY APPLICABLE IF top_height EQUALS 1 or 3 + !---------------------------------------------------------------------------------- + !-------------- RTTOV inputs + !---------------------------------------------------------------------------------- + rttov_Ninstruments = 3, + rttov_instrument_namelists = 'instrument_nls/cosp2_rttov_AIRS_L1C_CESM2_des.txt','instrument_nls/cosp2_rttov_AIRS_L1C_CESM2_asc.txt','instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt', + rttov_verbose=.true. + !---------------------------------------------------------------------------------- + !-------------- Swathing inputs + !---------------------------------------------------------------------------------- + N_SWATHS_ISCCP=2, + SWATH_LOCALTIMES_ISCCP=5.25,18.0, + SWATH_WIDTHS_ISCCP=2000,2000, + N_SWATHS_MISR=2, + SWATH_LOCALTIMES_MISR=6.5,18.25, + SWATH_WIDTHS_MISR=2000,2000, + N_SWATHS_MODIS=2, + SWATH_LOCALTIMES_MODIS=5.75,13.5, + SWATH_WIDTHS_MODIS=2000,2000, + N_SWATHS_CSCAL=2, + SWATH_LOCALTIMES_CSCAL=6.75,19.25, + SWATH_WIDTHS_CSCAL=2000,2000, + N_SWATHS_PARASOL=2, + SWATH_LOCALTIMES_PARASOL=6.75,19, + SWATH_WIDTHS_PARASOL=2000,2000, + N_SWATHS_ATLID=2, + SWATH_LOCALTIMES_ATLID=7.25,19.5, + SWATH_WIDTHS_ATLID=2000,2000, +/ diff --git a/driver/run/cosp2_output_rttov_swathleak_nl.txt b/driver/run/cosp2_output_rttov_swathleak_nl.txt new file mode 100644 index 0000000000..9c8a349949 --- /dev/null +++ b/driver/run/cosp2_output_rttov_swathleak_nl.txt @@ -0,0 +1,152 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +! Namelist that sets up output-related variables. It controls +! the instrument simulators to run and the list of variables +! to be written to file +&COSP_OUTPUT + !- CloudSat + Lcfaddbze94=.true., + Ldbze94=.true., + !- CALIPSO + Latb532=.true., + LcfadLidarsr532=.true., + Lclcalipso=.true., + Lclhcalipso=.true., + Lcllcalipso=.true., + Lclmcalipso=.true., + Lcltcalipso=.true., + LparasolRefl=.true., + ! CALIPSO phase diagnostics + Lclcalipsoliq=.true., + Lclcalipsoice=.true., + Lclcalipsoun=.true., + Lclcalipsotmp=.true., + Lclcalipsotmpliq=.true., + Lclcalipsotmpice=.true., + Lclcalipsotmpun=.true., + Lclhcalipsoliq=.true., + Lcllcalipsoliq=.true., + Lclmcalipsoliq=.true., + Lcltcalipsoliq=.true., + Lclhcalipsoice=.true., + Lcllcalipsoice=.true., + Lclmcalipsoice=.true., + Lcltcalipsoice=.true., + Lclhcalipsoun=.true., + Lcllcalipsoun=.true., + Lclmcalipsoun=.true., + Lcltcalipsoun=.true., + ! CALIPSO OPAQ diagnostics + Lclopaquecalipso=.true., + Lclthincalipso=.true., + Lclzopaquecalipso=.true., + Lclcalipsoopaque=.true., + Lclcalipsothin=.true., + Lclcalipsozopaque=.true., + Lclcalipsoopacity=.true., + Lclopaquetemp=.true., + Lclthintemp=.true., + Lclzopaquetemp=.true., + Lclopaquemeanz=.true., + Lclthinmeanz=.true., + Lclthinemis=.true., + Lclopaquemeanzse=.true., + Lclthinmeanzse=.true., + Lclzopaquecalipsose=.true., + ! GROUND LIDAR diagnostics + LlidarBetaMol532gr=.true., + LcfadLidarsr532gr=.true., + Latb532gr=.true., + LclgrLidar532=.true., + LclhgrLidar532=.true., + LcllgrLidar532=.true., + LclmgrLidar532=.true., + LcltgrLidar532=.true., + ! ATLID diagnostics + LlidarBetaMol355=.true., + LcfadLidarsr355=.true., + Latb355=.true., + Lclatlid=.true., + Lclhatlid=.true., + Lcllatlid=.true., + Lclmatlid=.true., + Lcltatlid=.true., + !- ISCCP + Lalbisccp=.true., + Lboxptopisccp=.true., + Lboxtauisccp=.true., + Lpctisccp=.true., + Lclisccp=.true., + Ltauisccp=.true., + Lcltisccp=.true., + Lmeantbisccp=.true., + Lmeantbclrisccp=.true., + !- MISR + LclMISR=.true., + !- Use lidar and radar + Lclcalipso2=.true., + Lcltlidarradar=.true., + Lcloudsat_tcc=.true., + Lcloudsat_tcc2=.true., + !- These are provided for debugging or special purposes + Lfracout=.true., + LlidarBetaMol532=.true., + !- MODIS + Lcltmodis=.true., + Lclwmodis=.true., + Lclimodis=.true., + Lclhmodis=.true., + Lclmmodis=.true., + Lcllmodis=.true., + Ltautmodis=.true., + Ltauwmodis=.true., + Ltauimodis=.true., + Ltautlogmodis=.true., + Ltauwlogmodis=.true., + Ltauilogmodis=.true., + Lreffclwmodis=.true., + Lreffclimodis=.true., + Lpctmodis=.true., + Llwpmodis=.true., + Liwpmodis=.true., + Lclmodis=.true., + !- RTTOV + Lrttov_run=.true., ! Run RTTOV? + ! -CLOUDSAT precipitation frequency/occurence diagnostics + Lptradarflag0=.true., + Lptradarflag1=.true., + Lptradarflag2=.true., + Lptradarflag3=.true., + Lptradarflag4=.true., + Lptradarflag5=.true., + Lptradarflag6=.true., + Lptradarflag7=.true., + Lptradarflag8=.true., + Lptradarflag9=.true., + Lradarpia=.true., + !- CloudSat+MODIS joint diagnostics + Lwr_occfreq=.true., + Lcfodd=.true. +/ From 22edcd56be7516ff6974f73a62707814c6cb7058 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 17 Dec 2024 11:40:56 -0700 Subject: [PATCH 135/159] Correct RTTOV object types --- .../cosp2_rttov_AIRS_L1C_CESM2.txt | 2 +- .../cosp2_rttov_AIRS_L1C_SCAMval.txt | 84 +++++++++++++++++++ src/simulator/rttov/cosp_rttov_v13.F90 | 26 +++--- 3 files changed, 101 insertions(+), 11 deletions(-) create mode 100644 driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_SCAMval.txt diff --git a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2.txt index 5c7f627252..31546c17f7 100644 --- a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2.txt +++ b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2.txt @@ -57,6 +57,7 @@ ! -------------- RTTOV Trace Gas Concentrations ! -------------- Specify units in RTTOV options set-up ! ---------------Standard units are kg/kg over moist air + rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below CO2_mr=6.09e-04, CH4_mr=9.139e-07, @@ -70,7 +71,6 @@ !-------------- RTTOV Other --------------- ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel rttov_nthreads=1, - rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air rttov_ZenAng=0.0, ! Satellite Zenith Angle ! Set local time sampling with swath widths rttov_Nlocaltime=0, ! Number of local times to sample at diff --git a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_SCAMval.txt b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_SCAMval.txt new file mode 100644 index 0000000000..c677abd5a6 --- /dev/null +++ b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_SCAMval.txt @@ -0,0 +1,84 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&RTTOV_INPUT + !-------------- Logical for constructing outputs and determining settings + Lrttov_bt=.true., ! Calculate RTTOV brightness temps + Lrttov_rad=.true., ! Calculate RTTOV radiances + Lrttov_refl=.false., ! Calculate RTTOV reflectivities + Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values + Lrttov_cldparam=.false., ! Use user input cloud optical parameters + Lrttov_aerparam=.false., ! Use user input aerosol optical parameters + Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? + Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. + Lrttov_pc=.false., ! Run with PC-RTTOV + !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" + nchannels_rec=2645, ! 2645 for all AIRS L1C channels, could limit just to those that overlap RRTMG channels + !-------------- RTTOV Filepaths + Lchannel_filepath=.false., + channel_filepath='rttov_channel_input_AIRS.csv' + rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', + rttov_coefDir='rtcoef_rttov13/', + OD_coef_filepath='AIRS_L1C/rtcoef_eos_2_airs_l1c_7gas.H5', ! Full version with N20 and CH4 + cld_coef_filepath='AIRS_L1C/sccldcoef_eos_2_airs_l1c.H5', + !-------------- RTTOV Trace Gas Logicals (must match coefficient files) + SO2_data=.false., + N2O_data=.true., + CO_data=.false., + CO2_data=.true., + CH4_data=.true., + ozone_data=.true., + clw_data=.false., ! Only used for MW calculations + ! -------------- RTTOV Trace Gas Concentrations + ! -------------- Specify units in RTTOV options set-up + ! ---------------Standard units are kg/kg over moist air + rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air + user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below + CO2_mr=6.09e-04, + CH4_mr=9.139e-07, + CO_mr=2.098e-07, + N2O_mr=4.665e-07, + SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv + !-------------- PC-RTTOV ------------------ + ipcbnd=1, ! Always 1 for RTTOV v13 + ipcreg=2, ! Set the number of predictors (channel outputs) + npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) + !-------------- RTTOV Other --------------- + ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel + rttov_nthreads=1, + rttov_ZenAng=0.0, ! Satellite Zenith Angle, was 76.2 + ! Set local time sampling with swath widths + rttov_Nlocaltime=0, ! Number of local times to sample at + rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] + rttov_localtime_width=1550,0, ! Swath width (km) + ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) + rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. + rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. + rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. + ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. + rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. +/ diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 8a4d7618bf..40f0279e99 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -270,7 +270,7 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs, inst_opts type(rttov_coefs),intent(in) :: & inst_coefs - type(rttov_profile),pointer,intent(out) :: & + type(rttov_profile),allocatable,target,intent(out) :: & inst_profiles(:) integer(kind=jpim),dimension(inst_nChannels_rec),intent(in) :: & inst_iChannel @@ -343,7 +343,8 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs, calcrefl=inst_calcrefl, & reflectance=inst_reflectance, & init=.TRUE._jplm) - call rttov_error('allocation error for rttov_direct structures' , lalloc = .false.) + call rttov_error('error for rttov_alloc_direct structures' , lalloc = .false.) + call rttov_error('allocation error for rttov_alloc_direct structures' , lalloc = .true.) ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! 4. Build the list of profile/channel indices in chanprof @@ -386,7 +387,7 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, inst_coefs type(rttov_options),intent(inout) :: & inst_opts - type(rttov_profile),pointer,intent(out) :: & + type(rttov_profile),allocatable,target,intent(out) :: & inst_profiles(:) integer(kind=jpim),intent(inout) :: & inst_nchannels_rec @@ -497,6 +498,7 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, nchannels_rec=inst_nchannels_rec * inst_nprof, & pccomp=inst_pccomp, & init=.TRUE._jplm) + call rttov_error('error for rttov_direct structures (PC-RTTOV)' , lalloc = .false.) call rttov_error('allocation error for rttov_direct structures (PC-RTTOV)' , lalloc = .true.) ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -551,7 +553,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & type(rttov_in),intent(in) :: & rttovIN - type(rttov_profile),pointer,intent(inout) :: & + type(rttov_profile),allocatable,target,intent(inout) :: & inst_profiles(:) logical,intent(in) :: & Lrttov_cld, & @@ -1084,7 +1086,7 @@ subroutine cosp_rttov_call_direct(inst_nthreads, & inst_nthreads type(rttov_options),intent(in) :: & inst_opts - type(rttov_profile),pointer,intent(in) :: & + type(rttov_profile),allocatable,target,intent(in) :: & inst_profiles(:) type(rttov_coefs),intent(in) :: & inst_coefs @@ -1154,7 +1156,8 @@ subroutine cosp_rttov_call_direct(inst_nthreads, & reflectance = inst_reflectance,&! inout input/output BRDFs per channel nthreads = inst_nthreads) ! in number of threads to use endif - call rttov_error('rttov_direct error', lalloc = .true.) + call rttov_error('rttov_direct error', lalloc = .false.) + call rttov_error('rttov_direct allocation error', lalloc = .true.) end subroutine cosp_rttov_call_direct @@ -1182,7 +1185,7 @@ subroutine cosp_pc_rttov_call_direct(inst_nthreads, & inst_nthreads type(rttov_options),intent(in) :: & inst_opts - type(rttov_profile),pointer,intent(in) :: & + type(rttov_profile),allocatable,target,intent(in) :: & inst_profiles(:) type(rttov_coefs),intent(in) :: & inst_coefs @@ -1239,7 +1242,9 @@ subroutine cosp_pc_rttov_call_direct(inst_nthreads, & channels_rec = inst_channels_rec,&! in reconstructed channel list nthreads = inst_nthreads) ! in number of threads to use endif - call rttov_error('rttov_direct error (PC-RTTOV)', lalloc = .true.) + call rttov_error('rttov_direct error (PC-RTTOV)', lalloc = .false.) + call rttov_error('rttov_direct allocation error (PC-RTTOV)', lalloc = .true.) + end subroutine cosp_pc_rttov_call_direct ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1446,7 +1451,7 @@ subroutine cosp_rttov_deallocate_profiles(inst_nprof, & nLevels type(rttov_options),intent(in) :: & inst_opts - type(rttov_profile),pointer,intent(in) :: & + type(rttov_profile),allocatable,target,intent(in) :: & inst_profiles(:) type(rttov_coefs),intent(in) :: & inst_coefs @@ -1483,6 +1488,7 @@ subroutine cosp_rttov_deallocate_profiles(inst_nprof, & emissivity=inst_emissivity, & calcrefl=inst_calcrefl, & reflectance=inst_reflectance) + call rttov_error('error for rttov_direct structures', lalloc = .false.) call rttov_error('deallocation error for rttov_direct structures', lalloc = .true.) end subroutine cosp_rttov_deallocate_profiles @@ -1515,7 +1521,7 @@ subroutine cosp_pc_rttov_deallocate_profiles(inst_nprof, & inst_nChannels_rec type(rttov_options),intent(in) :: & inst_opts - type(rttov_profile),pointer,intent(in) :: & + type(rttov_profile),allocatable,target,intent(in) :: & inst_profiles(:) type(rttov_coefs),intent(in) :: & inst_coefs From 61ed0f2cafed7367a07c42912e341b68dcdde437 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Fri, 27 Jun 2025 13:14:42 -0600 Subject: [PATCH 136/159] Swathing moved to simulator interfaces and consequent reorganization of cosp_stats and introduction of cosp_rttov_util --- build/Makefile | 39 +- cospsimulator_intr.F90 | 18 +- driver/src/cosp2_test.F90 | 41 +- src/cosp.F90 | 1098 +++-------------- src/cosp_constants.F90 | 8 +- src/cosp_rttov_util.F90 | 130 ++ src/cosp_rttov_utilSTUB.F90 | 99 ++ src/cosp_stats.F90 | 280 ++++- src/simulator/cosp_atlid_interface.F90 | 91 +- src/simulator/cosp_calipso_interface.F90 | 117 +- src/simulator/cosp_cloudsat_interface.F90 | 95 +- src/simulator/cosp_isccp_interface.F90 | 122 +- src/simulator/cosp_misr_interface.F90 | 94 +- src/simulator/cosp_modis_interface.F90 | 87 +- src/simulator/cosp_parasol_interface.F90 | 79 +- src/simulator/cosp_rttov_interfaceSTUB.F90 | 65 +- src/simulator/cosp_rttov_interface_v13.F90 | 124 +- src/simulator/quickbeam/quickbeam.F90 | 45 +- src/simulator/rttov/cosp_rttov_v13.F90 | 18 +- .../quickbeam_optics/quickbeam_optics.F90 | 3 +- 20 files changed, 1439 insertions(+), 1214 deletions(-) create mode 100644 src/cosp_rttov_util.F90 create mode 100644 src/cosp_rttov_utilSTUB.F90 diff --git a/build/Makefile b/build/Makefile index 39dbf22251..7a41ae2a31 100644 --- a/build/Makefile +++ b/build/Makefile @@ -53,6 +53,8 @@ cosp_rttov_interface_v13.o : cosp_rttov_interface_v13.F90 cosp_rttov_v13.o : cosp_rttov_v13.F90 $(F90) $(F90FLAGS) $(FFLAGS) -c $< +cosp_rttov_util.o : cosp_rttov_util.F90 + $(F90) $(F90FLAGS) $(FFLAGS) -c $< # # The COSP library # @@ -64,9 +66,9 @@ COSP_OBJS = cosp.o cosp_config.o cosp_stats.o cosp_constants.o cosp_errorHandlin # Add RTTOV files appropriately. ifdef RTTOV -COSP_OBJS += cosp_rttov_interface_v13.o cosp_rttov_v13.o +COSP_OBJS += cosp_rttov_interface_v13.o cosp_rttov_v13.o cosp_rttov_util.o else -COSP_OBJS += cosp_rttov_interfaceSTUB.o cosp_rttovSTUB.o +COSP_OBJS += cosp_rttov_interfaceSTUB.o cosp_rttovSTUB.o cosp_rttov_utilSTUB.o endif @@ -98,36 +100,39 @@ cosp.o : cosp_kinds.o cosp_modis_interface.o cosp_constants.o # Conditionally add dependencies on the STUB or actual RTTOV simulator. ifdef RTTOV -cosp.o: cosp_rttov_interface_v13.o cosp_rttov_v13.o +cosp.o : cosp_rttov_interface_v13.o cosp_rttov_v13.o cosp_rttov_util.o +cosp_stats.o : cosp_kinds.o cosp_config.o cosp_constants.o cosp_rttov_util.o else -cosp.o: cosp_rttov_interfaceSTUB.o cosp_rttovSTUB.o +cosp.o : cosp_rttov_interfaceSTUB.o cosp_rttovSTUB.o cosp_rttov_utilSTUB.o +cosp_stats.o : cosp_kinds.o cosp_config.o cosp_constants.o cosp_rttov_utilSTUB.o endif - 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_constants.o -cosp_isccp_interface.o : cosp_kinds.o icarus.o +cosp_isccp_interface.o : cosp_kinds.o icarus.o cosp_stats.o icarus.o : cosp_kinds.o cosp_constants.o cosp_stats.o -cosp_misr_interface.o : cosp_kinds.o +cosp_misr_interface.o : cosp_kinds.o cosp_stats.o MISR_simulator.o : cosp_kinds.o cosp_config.o cosp_stats.o -cosp_modis_interface.o : cosp_kinds.o cosp_config.o modis_simulator.o +cosp_modis_interface.o : cosp_kinds.o cosp_config.o modis_simulator.o cosp_stats.o modis_simulator.o : cosp_kinds.o cosp_config.o cosp_stats.o -cosp_parasol_interface.o : cosp_kinds.o +cosp_parasol_interface.o : cosp_kinds.o cosp_stats.o parasol.o : cosp_kinds.o cosp_config.o cosp_constants.o -cosp_calipso_interface.o : cosp_kinds.o lidar_simulator.o +cosp_calipso_interface.o : cosp_kinds.o lidar_simulator.o cosp_stats.o lidar_simulator.o : cosp_kinds.o cosp_config.o cosp_stats.o -cosp_grLidar532_interface.o : cosp_kinds.o -cosp_atlid_interface.o : cosp_kinds.o -cosp_cloudsat_interface.o : cosp_kinds.o cosp_config.o quickbeam.o +cosp_grLidar532_interface.o : cosp_kinds.o cosp_stats.o +cosp_atlid_interface.o : cosp_kinds.o cosp_stats.o +cosp_cloudsat_interface.o : cosp_kinds.o cosp_config.o quickbeam.o cosp_stats.o quickbeam.o : cosp_kinds.o cosp_stats.o # RTTOV Simulator code dependencies (only one interface and one RTTOV simulator are used at a time) -cosp_rttov_interface_v13.o : cosp_kinds.o cosp_config.o cosp_rttov_v13.o +cosp_rttov_interface_v13.o : cosp_kinds.o cosp_config.o cosp_rttov_v13.o cosp_rttov_util.o cosp_rttov_v13.o : cosp_kinds.o cosp_config.o cosp_constants.o -cosp_rttov_interfaceSTUB.o : cosp_kinds.o cosp_config.o cosp_rttovSTUB.o +cosp_rttov_interfaceSTUB.o : cosp_kinds.o cosp_config.o cosp_rttovSTUB.o cosp_rttov_utilSTUB.o cosp_rttovSTUB.o : cosp_kinds.o cosp_config.o cosp_constants.o +# RTTOV utility code dependencies +cosp_rttov_util.o : cosp_kinds.o +cosp_rttov_utilSTUB.o : cosp_kinds.o # Example subcolumn generaton and mapping to optical properties, following COSP 1.4 @@ -140,7 +145,7 @@ array_lib.o : cosp_kinds.o mrgrnk.o : cosp_kinds.o math_lib.o : cosp_kinds.o cosp_errorHandling.o optics_lib.o : cosp_kinds.o cosp_errorHandling.o -quickbeam_optics.o: cosp_kinds.o cosp_errorHandling.o cosp_constants.o cosp_config.o mrgrnk.o array_lib.o optics_lib.o math_lib.o quickbeam.o +quickbeam_optics.o: cosp_kinds.o cosp_errorHandling.o cosp_constants.o cosp_config.o mrgrnk.o array_lib.o optics_lib.o math_lib.o quickbeam.o cosp_stats.o scops.o : cosp_kinds.o cosp_errorHandling.o mo_rng.o prec_scops.o : cosp_kinds.o cosp_config.o cosp_utils.o : cosp_kinds.o cosp_config.o diff --git a/cospsimulator_intr.F90 b/cospsimulator_intr.F90 index 71819de237..eb8c97a387 100644 --- a/cospsimulator_intr.F90 +++ b/cospsimulator_intr.F90 @@ -4106,16 +4106,16 @@ end subroutine construct_cospstateIN ! ! This subroutine allocates output fields based on input logical flag switches. ! ###################################################################################### - subroutine construct_cosp_outputs(Npoints,Ncolumns,Nlevels,Nlvgrid,N_rttov_instruments,rttov_configs,x) + subroutine construct_cosp_outputs(Npoints,Ncolumns,Nlevels,Nlvgrid,Ninst_rttov,rttov_configs,x) ! Inputs integer,intent(in) :: & Npoints, & ! Number of sampled points Ncolumns, & ! Number of subgrid columns Nlevels, & ! Number of model levels Nlvgrid, & ! Number of levels in L3 stats computation - N_rttov_instruments ! Number of RTTOV instruments + Ninst_rttov ! Number of RTTOV instruments - type(rttov_cfg), dimension(N_rttov_instruments),intent(in) :: & + type(rttov_cfg), dimension(Ninst_rttov),intent(in) :: & rttov_configs ! Outputs @@ -4224,13 +4224,13 @@ subroutine construct_cosp_outputs(Npoints,Ncolumns,Nlevels,Nlvgrid,N_rttov_instr end if end if - if ((N_rttov_instruments .gt. 0) .and. (lrttov_sim)) then - x % N_rttov_instruments = N_rttov_instruments - allocate(x % rttov_outputs(N_rttov_instruments)) ! Need to allocate a pointer? + if ((Ninst_rttov .gt. 0) .and. (lrttov_sim)) then + x % Ninst_rttov = Ninst_rttov + allocate(x % rttov_outputs(Ninst_rttov)) ! Need to allocate a pointer? print*,'Immediately after rttov_outputs allocation.' print*,'associated(x % rttov_outputs(1) % refl_total): ',associated(x % rttov_outputs(1) % refl_total) print*,'associated(x % rttov_outputs(1) % refl_clear): ',associated(x % rttov_outputs(1) % refl_clear) - do i=1,N_rttov_instruments + do i=1,Ninst_rttov print*,'i: ',i print*,'rttov_configs(i) % nchan_out: ',rttov_configs(i) % nchan_out print*,'rttov_configs(i) % Lrttov_bt: ',rttov_configs(i) % Lrttov_bt @@ -4285,7 +4285,7 @@ subroutine construct_cosp_outputs(Npoints,Ncolumns,Nlevels,Nlvgrid,N_rttov_instr end if end do else - x % N_rttov_instruments = 0 + x % Ninst_rttov = 0 end if print*,'associated(x % rttov_outputs(i) % refl_total): ',associated(x % rttov_outputs(1) % refl_total) @@ -4618,7 +4618,7 @@ subroutine destroy_cosp_outputs(y) ! RTTOV multi-instrument - JKS ! if (associated(y%rttov_outputs)) then if (allocated(y%rttov_outputs)) then - do i=1,y % N_rttov_instruments ! Iterate over each instrument + do i=1,y % Ninst_rttov ! Iterate over each instrument if (associated(y%rttov_outputs(i)%channel_indices)) then deallocate(y%rttov_outputs(i)%channel_indices) nullify(y%rttov_outputs(i)%channel_indices) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 80b450bbd8..c9619c4ffa 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -31,6 +31,7 @@ ! 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 +! June 2025 - J.K. Shaw - Added COSP-RTTOV integration and swathing ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% program cosp2_test use cosp_kinds, only: wp @@ -57,17 +58,17 @@ program cosp2_test use mod_cosp_io, only: nc_read_input_file,write_cosp2_output USE mod_quickbeam_optics,only: size_distribution,hydro_class_init,quickbeam_optics, & quickbeam_optics_init,gases - use quickbeam, only: radar_cfg - use mod_cosp, only: cosp_init,cosp_optical_inputs,cosp_column_inputs, & - cosp_outputs,swath_inputs,cosp_cleanUp,cosp_simulator + use mod_cosp, only: cosp_init, & + cosp_outputs,swath_inputs,cosp_simulator USE mod_rng, ONLY: rng_state, init_rng USE mod_scops, ONLY: scops USE mod_prec_scops, ONLY: prec_scops USE MOD_COSP_UTILS, ONLY: cosp_precip_mxratio use cosp_optics, ONLY: cosp_simulator_optics,lidar_optics,modis_optics, & modis_optics_partition - use mod_cosp_stats, ONLY: COSP_CHANGE_VERTICAL_GRID - use MOD_COSP_RTTOV_INTERFACE, only: rttov_cfg + use mod_cosp_stats, ONLY: COSP_CHANGE_VERTICAL_GRID,cosp_optical_inputs, & + cosp_column_inputs,radar_cfg,cosp_cleanUp + use MOD_COSP_RTTOV_UTIL, only: rttov_cfg implicit none @@ -1236,11 +1237,7 @@ subroutine construct_cospstateIN(npoints,nlevels,y) ! Inputs integer,intent(in) :: & npoints, & ! Number of horizontal gridpoints - nlevels ! Number of vertical levels -! N_rttov_instruments - -! type(rttov_cfg), dimension(N_rttov_instruments),intent(in) :: & -! rttov_configs + nlevels ! Number of vertical levels ! Outputs type(cosp_column_inputs),intent(out) :: y @@ -1257,11 +1254,7 @@ subroutine construct_cospstateIN(npoints,nlevels,y) y%fl_snow(nPoints,nLevels),y%fl_rain(nPoints,nLevels), & y%tca(nPoints,nLevels),y%hgt_matrix_half(nPoints,nlevels), & y%rttov_date(nPoints,3),y%rttov_time(nPoints,3),y%sza(nPoints)) - - ! JKS - I should make this optional to save space. -! do i=1,N_rttov_instruments -! allocate(y%emis_in(npoints,rttov_configs(i) % nchan_out),y%refl_in(npoints,rttov_configs(i) % nchan_out)) -! end do + end subroutine construct_cospstateIN @@ -1302,7 +1295,7 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& Lptradarflag3,Lptradarflag4,Lptradarflag5, & Lptradarflag6,Lptradarflag7,Lptradarflag8, & Lptradarflag9,Lradarpia,Lwr_occfreq,Lcfodd, & - N_rttov_instruments,rttov_configs, & + Ninst_rttov,rttov_configs, & Npoints,Ncolumns,Nlevels,Nlvgrid,x) ! Inputs logical,intent(in) :: & @@ -1419,9 +1412,9 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& Ncolumns, & ! Number of subgrid columns Nlevels, & ! Number of model levels Nlvgrid, & ! Number of levels in L3 stats computation - N_rttov_instruments + Ninst_rttov - type(rttov_cfg), dimension(N_rttov_instruments),intent(in) :: & + type(rttov_cfg), dimension(Ninst_rttov),intent(in) :: & rttov_configs ! Outputs @@ -1585,10 +1578,10 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& ! RTTOV - Allocate output for multiple instruments ! Do I not need to allocate the number of instruments? Because each rttov output DDT will be a pointer? - if ((N_rttov_instruments .gt. 0) .and. (Lrttov)) then - x % N_rttov_instruments = N_rttov_instruments - allocate(x % rttov_outputs(N_rttov_instruments)) ! Need to allocate a pointer? - do i=1,N_rttov_instruments + if ((Ninst_rttov .gt. 0) .and. (Lrttov)) then + x % Ninst_rttov = Ninst_rttov + allocate(x % rttov_outputs(Ninst_rttov)) ! Need to allocate a pointer? + do i=1,Ninst_rttov x % rttov_outputs(i) % nchan_out = rttov_configs(i) % nchan_out if (rttov_configs(i) % Lrttov_pc) then ! Treat PC-RTTOV fields as clear-sky only for now allocate(x % rttov_outputs(i) % channel_indices(rttov_configs(i) % nchan_out)) @@ -1627,7 +1620,7 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& end if end do else - x % N_rttov_instruments = 0 + x % Ninst_rttov = 0 end if end subroutine construct_cosp_outputs @@ -2030,7 +2023,7 @@ subroutine destroy_cosp_outputs(y) ! RTTOV multi-instrument if (allocated(y%rttov_outputs)) then - do i=1,y % N_rttov_instruments ! Iterate over each instrument + do i=1,y % Ninst_rttov ! Iterate over each instrument if (associated(y%rttov_outputs(i)%channel_indices)) then deallocate(y%rttov_outputs(i)%channel_indices) nullify(y%rttov_outputs(i)%channel_indices) diff --git a/src/cosp.F90 b/src/cosp.F90 index e2797a6961..77d727a03f 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -50,20 +50,24 @@ MODULE MOD_COSP modis_histTauEdges,tau_binEdges,nCloudsatPrecipClass,& modis_histTauCenters,tau_binCenters, & cloudsat_preclvl,grLidar532_histBsct,atlid_histBsct - USE MOD_COSP_MODIS_INTERFACE, ONLY: cosp_modis_init, modis_IN - USE MOD_COSP_RTTOV_INTERFACE, ONLY: & - cosp_rttov_init, & - cosp_rttov_simulate, & - rttov_cfg, & - rttov_output - USE MOD_COSP_MISR_INTERFACE, ONLY: cosp_misr_init, misr_IN - USE MOD_COSP_ISCCP_INTERFACE, ONLY: cosp_isccp_init, isccp_IN - USE MOD_COSP_CALIPSO_INTERFACE, ONLY: cosp_calipso_init, calipso_IN - USE MOD_COSP_ATLID_INTERFACE, ONLY: cosp_atlid_init, atlid_IN + USE MOD_COSP_MODIS_INTERFACE, ONLY: cosp_modis_init, modis_IN, & + cosp_modis_mask + USE MOD_COSP_RTTOV_INTERFACE, ONLY: cosp_rttov_init, cosp_rttov_simulate + USE MOD_COSP_RTTOV_UTIL, ONLY: rttov_cfg, rttov_output + USE MOD_COSP_MISR_INTERFACE, ONLY: cosp_misr_init, misr_IN, & + cosp_misr_mask, cosp_misr_mask_clean + USE MOD_COSP_ISCCP_INTERFACE, ONLY: cosp_isccp_init, isccp_IN, & + cosp_isccp_mask, cosp_isccp_mask_clean + USE MOD_COSP_CALIPSO_INTERFACE, ONLY: cosp_calipso_init, calipso_IN, & + cosp_calipso_mask, cosp_calipso_mask_clean + USE MOD_COSP_ATLID_INTERFACE, ONLY: cosp_atlid_init, atlid_IN, & + cosp_atlid_mask, cosp_atlid_mask_clean USE MOD_COSP_GRLIDAR532_INTERFACE, ONLY: cosp_grLidar532_init, grLidar532_IN - USE MOD_COSP_PARASOL_INTERFACE, ONLY: cosp_parasol_init, parasol_in - USE MOD_COSP_CLOUDSAT_INTERFACE, ONLY: cosp_cloudsat_init, cloudsat_IN - USE quickbeam, ONLY: quickbeam_subcolumn, quickbeam_column, radar_cfg + USE MOD_COSP_PARASOL_INTERFACE, ONLY: cosp_parasol_init, parasol_in, & + cosp_parasol_mask, cosp_parasol_mask_clean + USE MOD_COSP_CLOUDSAT_INTERFACE, ONLY: cosp_cloudsat_init, cloudsat_IN, & + cosp_cloudsat_mask, cosp_cloudsat_mask_clean + USE quickbeam, ONLY: quickbeam_subcolumn, quickbeam_column USE MOD_ICARUS, ONLY: icarus_subcolumn, icarus_column USE MOD_MISR_SIMULATOR, ONLY: misr_subcolumn, misr_column USE MOD_LIDAR_SIMULATOR, ONLY: lidar_subcolumn, lidar_column @@ -71,134 +75,16 @@ MODULE MOD_COSP USE MOD_PARASOL, ONLY: parasol_subcolumn, parasol_column USE MOD_COSP_RTTOV, ONLY: rttov_IN USE MOD_COSP_STATS, ONLY: COSP_LIDAR_ONLY_CLOUD,COSP_CHANGE_VERTICAL_GRID, & - COSP_DIAG_WARMRAIN + COSP_DIAG_WARMRAIN, COMPUTE_ORBITMASKS, & + cosp_optical_inputs, cosp_column_inputs, & + swath_inputs, radar_cfg + USE COSP_PHYS_CONSTANTS, ONLY: radius_earth + USE COSP_MATH_CONSTANTS, ONLY: pi IMPLICIT NONE logical :: linitialization ! Initialization flag - ! ###################################################################################### - ! TYPE cosp_column_inputs - ! ###################################################################################### - type cosp_column_inputs - integer :: & - Npoints, & ! Number of gridpoints. - Ncolumns, & ! Number of columns. - Nlevels ! Number of levels. - - integer,allocatable,dimension(:) :: & - sunlit ! Sunlit flag (0-1) - - real(wp),allocatable,dimension(:,:) :: & - at, & ! Temperature (K) - pfull, & ! Pressure (Pa) - phalf, & ! Pressure at half-levels (Pa) - qv, & ! Specific humidity (kg/kg) - co2, & ! CO2 (kg/kg) - ch4, & ! Methane (kg/kg) - n2o, & ! N2O (kg/kg) - co, & ! CO (kg/kg) - so2, & ! SO2 (kg/kg) - hgt_matrix, & ! Height of atmosphere layer (km) - hgt_matrix_half ! Height of bottom interface of atm layer(km) - ! First level contains the bottom of the top layer. - ! Last level contains the bottom of the surface layer. - - real(wp),allocatable,dimension(:) :: & - land, & ! Land/Sea mask (0 for ocean, 1 for land) - skt, & ! Surface temperature (K) - psfc, & ! Surface pressure (Pa) - surfelev, & ! Surface Elevation (m) - rttov_sfcmask ! Mask for RTTOV surface types (0 for ocean, 1 for land, 2 for sea ice) - ! Fields used ONLY by RTTOV - real(wp),allocatable,dimension(:) :: & - u_sfc, & ! Surface u-wind (m/s) - v_sfc, & ! Surface v-wind (m/s) - t2m, & ! 2-meter temperature (K) - q2m, & ! 2-meter specific humidity (kg/kg) - lat, & ! Latitude (deg) - lon, & ! Longitude (deg) - sza ! Solar Zenith Angle in degrees - real(wp),allocatable,dimension(:,:) :: & - o3, & ! Ozone (kg/kg) - tca, & ! Total layer cloud fraction (0-1) - cloudIce, & ! Cloud ice water mixing ratio (kg/kg) - cloudLiq, & ! Cloud liquid water mixing ratio (kg/kg) - DeffLiq, & ! Cloud liquid effective diameter (um) - DeffIce, & ! Cloud ice effective diameter (um) - rttov_date, & ! Date of the profile as year (e.g. 2013), month (1-12), and day (1-31) - rttov_time, & ! Time of profile as hour, minute, second. - emis_in, & ! Surface emissivity (point,channel) (1) - refl_in, & ! Surface reflectance (point,channel) (1) - fl_rain, & ! Precipitation (rain) flux (kg/m2/s) - fl_snow ! Precipitation (snow) flux (kg/m2/s) - end type cosp_column_inputs - - ! ###################################################################################### - ! TYPE swath_inputs - ! ###################################################################################### - type swath_inputs - - integer :: & - N_inst_swaths = 0 - real(wp),dimension(20) :: & - inst_localtimes, & - inst_localtime_widths - - end type swath_inputs - - ! ###################################################################################### - ! TYPE cosp_optical_inputs - ! ###################################################################################### - type cosp_optical_inputs - integer :: & - Npoints, & ! Number of gridpoints. - Ncolumns, & ! Number of columns. - Nlevels, & ! Number of levels. - Npart, & ! Number of cloud meteors for LIDAR simulators. - Nrefl, & ! Number of reflectances for PARASOL simulator - Ninst_rttov ! Number of RTTOV instruments - real(wp),pointer :: & - emis_grey => null() ! Greybody (spectrally flat) emissivity value for RTTOV - real(wp) :: & - emsfc_lw ! Surface emissivity @ 11micron - real(wp),allocatable,dimension(:,:,:) :: & - frac_out, & ! Cloud fraction - tau_067, & ! Optical depth @ 0.67micron - emiss_11, & ! Emissivity @ 11 micron - fracLiq, & ! Fraction of optical-depth due to liquid (MODIS) - asym, & ! Assymetry parameter @ 3.7micron (MODIS) - ss_alb, & ! Single-scattering albedo @ 3.7micron (MODIS) - betatot_calipso, & ! Lidar backscatter coefficient (calipso @ 532nm) - betatot_grLidar532, & ! Lidar backscatter coefficient (ground-lidar @ 532nm) - betatot_atlid, & ! Lidar backscatter coefficient (atlid @ 355nm) - betatot_ice_calipso, & ! Lidar backscatter coefficient ICE (calipso @ 532nm) - betatot_liq_calipso, & ! Lidar backscatter coefficient LIQUID (calipso @ 532nm) - tautot_calipso, & ! Lidar Optical thickness (calipso @ 532nm) - tautot_grLidar532, & ! Lidar Optical thickness (ground-lidar @ 532nm) - tautot_atlid, & ! Lidar Optical thickness (atlid @ 355nm) - tautot_ice_calipso, & ! Lidar Ice Optical thickness (calipso @ 532nm) - tautot_liq_calipso, & ! Lidar Liquid Optical thickness (calipso @ 532nm) - z_vol_cloudsat, & ! Effective reflectivity factor (mm^6/m^3) - kr_vol_cloudsat, & ! Attenuation coefficient hydro (dB/km) - g_vol_cloudsat ! Attenuation coefficient gases (dB/km) - real(wp),allocatable,dimension(:,:) :: & - beta_mol_calipso, & ! Lidar molecular backscatter coefficient (calipso @ 532nm) - beta_mol_grLidar532, & ! Lidar molecular backscatter coefficient (ground-lidar @ 532nm) - beta_mol_atlid, & ! Lidar molecular backscatter coefficient (atlid @ 355nm) - tau_mol_calipso, & ! Lidar molecular optical depth (calipso @ 532nm) - tau_mol_grLidar532, & ! Lidar molecular optical depth (ground-lidar @ 532nm) - tau_mol_atlid, & ! Lidar molecular optical depth (atlid @ 355nm) - tautot_S_liq, & ! Parasol Liquid water optical thickness, from TOA to SFC - tautot_S_ice, & ! Parasol Ice water optical thickness, from TOA to SFC - fracPrecipIce ! Fraction of precipitation which is frozen (1). - type(radar_cfg) :: & - rcfg_cloudsat ! Radar configuration information (CLOUDSAT) - type(rttov_cfg),dimension(:),pointer :: & - cfg_rttov ! RTTOV configuration information (multiple instruments) - type(swath_inputs),dimension(6) :: & ! Could be a pointer but fine - cospswathsIN - end type cosp_optical_inputs ! ###################################################################################### ! TYPE cosp_outputs @@ -250,7 +136,6 @@ MODULE MOD_COSP real(wp), dimension(:),pointer :: & atlid_srbval => null() ! SR bins in cfad_sr - ! PARASOL outputs real(wp),dimension(:,:,:),pointer :: & parasolPix_refl => null() ! PARASOL reflectances (subcolumn) @@ -326,7 +211,7 @@ MODULE MOD_COSP real(wp),dimension(:,:), pointer :: & wr_occfreq_ntotal => null() ! # of nonprecip/drizzle/precip (Npoints,WR_NREGIME) integer :: & - N_rttov_instruments + Ninst_rttov type(rttov_output),dimension(:),allocatable :: & rttov_outputs @@ -394,9 +279,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ok_lidar_cfad_grLidar532 = .false., & ok_lidar_cfad_atlid = .false., & verbose = .false. - real(wp),dimension(10) :: driver_time - integer, dimension(:),allocatable :: & - rttov_Ichannel integer, dimension(:,:),allocatable :: & modisRetrievedPhase,isccpLEVMATCH real(wp), dimension(:), allocatable :: & @@ -432,13 +314,8 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Fields used in orbit swathing of gridcells. logical,dimension(:),allocatable :: & ! Mask of reals over all local times - ISCCP_SWATH_MASK, & - MISR_SWATH_MASK, & - CSCAL_SWATH_MASK, & - MODIS_SWATH_MASK, & - PARASOL_SWATH_MASK, & - ATLID_SWATH_MASK, & - MODIS_CSCAL_SWATH_MASK + CSCAL_SWATH_MASK, & ! Needed for MODIS CSCAL + MODIS_SWATH_MASK ! Needed for MODIS CSCAL + normal MODIS integer,dimension(:),allocatable :: & ! Arrays containing the indices of the swath masks ISCCP_MASK_INDICES, & MISR_MASK_INDICES, & @@ -447,51 +324,25 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ATLID_MASK_INDICES, & MODIS_CSCAL_MASK_INDICES integer :: j - integer,target :: & ! Number of gridcell points to computer on after swathing - N_ISCCP_SWATHED, & - N_MISR_SWATHED, & - N_CSCAL_SWATHED, & - N_MODIS_SWATHED, & - N_PARASOL_SWATHED, & - N_ATLID_SWATHED ! ISCCP swathing variables - integer,dimension(:),target,allocatable :: & - temp_isccp_sunlit real(wp),dimension(:),target,allocatable :: & - temp_isccp_skt, & temp_isccp_meanalbedocld, & temp_isccp_meanptop, & temp_isccp_meantaucld, & temp_isccp_totalcldarea, & temp_isccp_meantb - real(wp),dimension(:,:),target,allocatable :: & - temp_isccp_qv, & - temp_isccp_at, & - temp_isccp_phalf, & - temp_isccp_pfull real(wp),dimension(:,:,:),target,allocatable :: & - temp_isccp_frac_out, & - temp_isccp_tau_067, & - temp_isccp_emiss_11, & temp_isccp_fq ! MISR swathing variables - integer,dimension(:),target,allocatable :: & - temp_misr_sunlit real(wp),dimension(:),target,allocatable :: & temp_misr_cldarea, & temp_misr_meanztop - real(wp),dimension(:,:),target,allocatable :: & - temp_misr_zfull, & - temp_misr_at real(wp),dimension(:,:,:),target,allocatable :: & - temp_misr_dtau, & temp_misr_fq ! CALIPSO swathing variables real(wp),dimension(:),target,allocatable :: & temp_calipso_cldthinemis real(wp),dimension(:,:),target,allocatable :: & - temp_beta_mol_calipso, & - temp_tau_mol_calipso, & temp_calipso_lidarcld, & temp_calipso_cldlayer, & temp_calipso_cldtype, & @@ -499,12 +350,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) temp_calipso_cldtypemeanz,& temp_calipso_cldtypemeanzse real(wp),dimension(:,:,:),target,allocatable :: & - temp_betatot_calipso, & - temp_tautot_calipso, & - temp_betatot_liq_calipso, & - temp_tautot_liq_calipso, & - temp_betatot_ice_calipso, & - temp_tautot_ice_calipso, & temp_calipso_cfad_sr, & temp_calipso_lidarcldphase, & temp_calipso_lidarcldtype, & @@ -512,29 +357,19 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) temp_calipso_lidarcldtmp ! ATLID swathing variables real(wp),dimension(:,:),target,allocatable :: & - temp_beta_mol_atlid, & - temp_tau_mol_atlid, & temp_atlid_lidarcld, & temp_atlid_cldlayer real(wp),dimension(:,:,:),target,allocatable :: & - temp_betatot_atlid, & - temp_tautot_atlid, & temp_atlid_cfad_sr ! PARASOL swathing variables real(wp),dimension(:,:),target,allocatable :: & - temp_tautot_S_liq, & - temp_tautot_S_ice, & temp_parasolGrid_refl ! CLOUDSAT swathing variables real(wp),dimension(:),target,allocatable :: & temp_cloudsat_pia real(wp),dimension(:,:),target,allocatable :: & - temp_hgt_matrix, & temp_cloudsat_precip_cover real(wp),dimension(:,:,:),target,allocatable :: & - temp_z_vol_cloudsat, & - temp_kr_vol_cloudsat, & - temp_g_vol_cloudsat, & temp_cloudsat_cfad_ze ! MODIS swathing variables. real(wp),dimension(:,:),allocatable :: & @@ -652,7 +487,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (allocated(cospOUT%rttov_outputs)) then Lrttov_column = .true. endif - ! ISCCP column if (associated(cospOUT%isccp_fq) .or. & @@ -782,173 +616,15 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Indexing order for "cospIN % cospswathsIN" is ISCCP, MISR, CLOUDSAT-CALIPSO, ATLID, PARASOL, MODIS if (Lisccp_subcolumn .or. Lmodis_subcolumn) then - if (cospIN % cospswathsIN(1) % N_inst_swaths .gt. 0) then - allocate(ISCCP_SWATH_MASK(Npoints)) - ! Do swathing to figure out which cells to simulate on - call compute_orbitmasks(Npoints, & - cospIN % cospswathsIN(1) % N_inst_swaths, & - cospIN % cospswathsIN(1) % inst_localtimes, & - cospIN % cospswathsIN(1) % inst_localtime_widths, & - cospgridIN%lat, cospgridIN%lon, & - cospgridIN%rttov_date(:,2), cospgridIN%rttov_date(:,3), & ! Time fields: month, dayofmonth - cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute - ISCCP_SWATH_MASK,N_ISCCP_SWATHED) ! Output: logical mask array - isccpIN%Npoints => N_ISCCP_SWATHED - ISCCP_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = ISCCP_SWATH_MASK) - if (verbose) print*,'isccpIN%Npoints: ',isccpIN%Npoints - if (verbose) print*,'ISCCP_SWATH_MASK: ',ISCCP_SWATH_MASK - if (isccpIN%Npoints .gt. 0) then - ! Allocate swathed arrays. - allocate(temp_isccp_skt(isccpIN%Npoints),temp_isccp_qv(isccpIN%Npoints,cospIN%Nlevels),temp_isccp_at(isccpIN%Npoints,cospIN%Nlevels), & - temp_isccp_frac_out(isccpIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels),temp_isccp_tau_067(isccpIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & - temp_isccp_emiss_11(isccpIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels),temp_isccp_phalf(isccpIN%Npoints,cospIN%Nlevels+1), & - temp_isccp_pfull(isccpIN%Npoints,cospIN%Nlevels),temp_isccp_sunlit(isccpIN%Npoints)) - ! Encode step: Read only appropriate values into the new temp arrays. - temp_isccp_skt(:) = cospgridIN%skt(int(ISCCP_MASK_INDICES)) - temp_isccp_qv(:,:) = cospgridIN%qv(int(ISCCP_MASK_INDICES),:) - temp_isccp_at(:,:) = cospgridIN%at(int(ISCCP_MASK_INDICES),:) - temp_isccp_frac_out(:,:,:) = cospIN%frac_out(int(ISCCP_MASK_INDICES),:,:) - temp_isccp_tau_067(:,:,:) = cospIN%tau_067(int(ISCCP_MASK_INDICES),:,:) - temp_isccp_emiss_11(:,:,:) = cospIN%emiss_11(int(ISCCP_MASK_INDICES),:,:) - temp_isccp_phalf(:,:) = cospgridIN%phalf(int(ISCCP_MASK_INDICES),:) - temp_isccp_pfull(:,:) = cospgridIN%pfull(int(ISCCP_MASK_INDICES),:) - temp_isccp_sunlit(:) = cospgridIN%sunlit(int(ISCCP_MASK_INDICES)) - - isccpIN%Ncolumns => cospIN%Ncolumns - isccpIN%Nlevels => cospIN%Nlevels - isccpIN%emsfc_lw => cospIN%emsfc_lw - isccpIN%skt => temp_isccp_skt - isccpIN%qv => temp_isccp_qv - isccpIN%at => temp_isccp_at - isccpIN%frac_out => temp_isccp_frac_out - isccpIN%dtau => temp_isccp_tau_067 - isccpIN%dem => temp_isccp_emiss_11 - isccpIN%phalf => temp_isccp_phalf - isccpIN%pfull => temp_isccp_pfull - isccpIN%sunlit => temp_isccp_sunlit - end if - else - isccpIN%Npoints => Npoints - isccpIN%Ncolumns => cospIN%Ncolumns - isccpIN%Nlevels => cospIN%Nlevels - isccpIN%emsfc_lw => cospIN%emsfc_lw - isccpIN%skt => cospgridIN%skt - isccpIN%qv => cospgridIN%qv - isccpIN%at => cospgridIN%at - isccpIN%frac_out => cospIN%frac_out - isccpIN%dtau => cospIN%tau_067 - isccpIN%dem => cospIN%emiss_11 - isccpIN%phalf => cospgridIN%phalf - isccpIN%pfull => cospgridIN%pfull - isccpIN%sunlit => cospgridIN%sunlit - end if + call COSP_ISCCP_MASK(cospIN,cospgridIN,Npoints,isccpIN,ISCCP_MASK_INDICES) endif if (Lmisr_subcolumn) then - if (cospIN % cospswathsIN(2) % N_inst_swaths .gt. 0) then - allocate(MISR_SWATH_MASK(Npoints)) - ! Do swathing to figure out which cells to simulate on - call compute_orbitmasks(Npoints, & - cospIN % cospswathsIN(2) % N_inst_swaths, & - cospIN % cospswathsIN(2) % inst_localtimes, & - cospIN % cospswathsIN(2) % inst_localtime_widths, & - cospgridIN%lat, cospgridIN%lon, & - cospgridIN%rttov_date(:,2), cospgridIN%rttov_date(:,3), & ! Time fields: month, dayofmonth - cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute - MISR_SWATH_MASK,N_MISR_SWATHED) ! Output: logical mask array - misrIN%Npoints => N_MISR_SWATHED - MISR_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = MISR_SWATH_MASK) - if (verbose) print*,'misrIN%Npoints: ',misrIN%Npoints - if (verbose) print*,'MISR_SWATH_MASK: ',MISR_SWATH_MASK - if (misrIN%Npoints .gt. 0) then - ! Allocate swathed arrays. - allocate(temp_misr_dtau(misrIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & - temp_misr_sunlit(misrIN%Npoints), & - temp_misr_zfull(misrIN%Npoints,cospIN%Nlevels), & - temp_misr_at(misrIN%Npoints,cospIN%Nlevels)) - ! Encode step: Read only appropriate values into the new temp arrays. - temp_misr_dtau(:,:,:) = cospIN%tau_067(int(MISR_MASK_INDICES),:,:) - temp_misr_at(:,:) = cospgridIN%at(int(MISR_MASK_INDICES),:) - temp_misr_zfull(:,:) = cospgridIN%hgt_matrix(int(MISR_MASK_INDICES),:) - temp_misr_sunlit(:) = cospgridIN%sunlit(int(MISR_MASK_INDICES)) - - misrIN%Ncolumns => cospIN%Ncolumns - misrIN%Nlevels => cospIN%Nlevels - misrIN%dtau => temp_misr_dtau - misrIN%sunlit => temp_misr_sunlit - misrIN%zfull => temp_misr_zfull - misrIN%at => temp_misr_at - end if - else - misrIN%Npoints => Npoints - misrIN%Ncolumns => cospIN%Ncolumns - misrIN%Nlevels => cospIN%Nlevels - misrIN%dtau => cospIN%tau_067 - misrIN%sunlit => cospgridIN%sunlit - misrIN%zfull => cospgridIN%hgt_matrix - misrIN%at => cospgridIN%at - end if + call COSP_MISR_MASK(cospIN,cospgridIN,Npoints,misrIN,MISR_MASK_INDICES) endif if (Lcalipso_subcolumn) then - if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then - allocate(CSCAL_SWATH_MASK(Npoints)) - ! Do swathing to figure out which cells to simulate on - call compute_orbitmasks(Npoints, & - cospIN % cospswathsIN(3) % N_inst_swaths, & - cospIN % cospswathsIN(3) % inst_localtimes, & - cospIN % cospswathsIN(3) % inst_localtime_widths, & - cospgridIN%lat, cospgridIN%lon, & - cospgridIN%rttov_date(:,2), cospgridIN%rttov_date(:,3), & ! Time fields: month, dayofmonth - cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute - CSCAL_SWATH_MASK, N_CSCAL_SWATHED) ! Output: logical mask array - calipsoIN%Npoints => N_CSCAL_SWATHED - CSCAL_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = CSCAL_SWATH_MASK) - if (verbose) print*,'calipsoIN%Npoints: ',calipsoIN%Npoints - if (verbose) print*,'CSCAL_SWATH_MASK: ',CSCAL_SWATH_MASK - if (calipsoIN%Npoints .gt. 0) then - ! Allocate swathed arrays. - allocate(temp_beta_mol_calipso(calipsoIN%Npoints,cospIN%Nlevels), & - temp_tau_mol_calipso(calipsoIN%Npoints,cospIN%Nlevels), & - temp_betatot_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & - temp_tautot_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & - temp_betatot_liq_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & - temp_tautot_liq_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & - temp_betatot_ice_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & - temp_tautot_ice_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels)) - ! Encode step: Read only appropriate values into the new temp arrays. - temp_beta_mol_calipso(:,:) = cospIN%beta_mol_calipso(int(CSCAL_MASK_INDICES),:) - temp_tau_mol_calipso(:,:) = cospIN%tau_mol_calipso(int(CSCAL_MASK_INDICES),:) - temp_betatot_calipso(:,:,:) = cospIN%betatot_calipso(int(CSCAL_MASK_INDICES),:,:) - temp_tautot_calipso(:,:,:) = cospIN%tautot_calipso(int(CSCAL_MASK_INDICES),:,:) - temp_betatot_liq_calipso(:,:,:) = cospIN%betatot_liq_calipso(int(CSCAL_MASK_INDICES),:,:) - temp_tautot_liq_calipso(:,:,:) = cospIN%tautot_liq_calipso(int(CSCAL_MASK_INDICES),:,:) - temp_betatot_ice_calipso(:,:,:) = cospIN%betatot_ice_calipso(int(CSCAL_MASK_INDICES),:,:) - temp_tautot_ice_calipso(:,:,:) = cospIN%tautot_ice_calipso(int(CSCAL_MASK_INDICES),:,:) - calipsoIN%Ncolumns => cospIN%Ncolumns - calipsoIN%Nlevels => cospIN%Nlevels - calipsoIN%beta_mol => temp_beta_mol_calipso - calipsoIN%betatot => temp_betatot_calipso - calipsoIN%betatot_liq => temp_betatot_liq_calipso - calipsoIN%betatot_ice => temp_betatot_ice_calipso - calipsoIN%tau_mol => temp_tau_mol_calipso - calipsoIN%tautot => temp_tautot_calipso - calipsoIN%tautot_liq => temp_tautot_liq_calipso - calipsoIN%tautot_ice => temp_tautot_ice_calipso - endif - else - calipsoIN%Npoints => Npoints - calipsoIN%Ncolumns => cospIN%Ncolumns - calipsoIN%Nlevels => cospIN%Nlevels - calipsoIN%beta_mol => cospIN%beta_mol_calipso - calipsoIN%betatot => cospIN%betatot_calipso - calipsoIN%betatot_liq => cospIN%betatot_liq_calipso - calipsoIN%betatot_ice => cospIN%betatot_ice_calipso - calipsoIN%tau_mol => cospIN%tau_mol_calipso - calipsoIN%tautot => cospIN%tautot_calipso - calipsoIN%tautot_liq => cospIN%tautot_liq_calipso - calipsoIN%tautot_ice => cospIN%tautot_ice_calipso - endif + call COSP_CALIPSO_MASK(cospIN,cospgridIN,Npoints,calipsoIN,CSCAL_MASK_INDICES,CSCAL_SWATH_MASK) endif if (LgrLidar532_subcolumn) then @@ -962,205 +638,19 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) endif if (Latlid_subcolumn) then - if (cospIN % cospswathsIN(4) % N_inst_swaths .gt. 0) then - allocate(ATLID_SWATH_MASK(Npoints)) - ! Do swathing to figure out which cells to simulate on - call compute_orbitmasks(Npoints, & - cospIN % cospswathsIN(4) % N_inst_swaths, & - cospIN % cospswathsIN(4) % inst_localtimes, & - cospIN % cospswathsIN(4) % inst_localtime_widths, & - cospgridIN%lat, cospgridIN%lon, & - cospgridIN%rttov_date(:,2), cospgridIN%rttov_date(:,3), & ! Time fields: month, dayofmonth - cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute - ATLID_SWATH_MASK, N_ATLID_SWATHED) ! Output: logical mask array - atlidIN%Npoints => N_ATLID_SWATHED - ATLID_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = ATLID_SWATH_MASK) - if (verbose) print*,'atlidIN%Npoints: ',atlidIN%Npoints - if (verbose) print*,'ATLID_SWATH_MASK: ',ATLID_SWATH_MASK - if (atlidIN%Npoints .gt. 0) then - ! Allocate swathed arrays. - allocate(temp_beta_mol_atlid(atlidIN%Npoints,cospIN%Nlevels), & - temp_betatot_atlid(atlidIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & - temp_tau_mol_atlid(atlidIN%Npoints,cospIN%Nlevels), & - temp_tautot_atlid(atlidIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels)) - ! Encode step: Read only appropriate values into the new temp arrays. - temp_beta_mol_atlid(:,:) = cospIN%beta_mol_atlid(int(ATLID_MASK_INDICES),:) - temp_tau_mol_atlid(:,:) = cospIN%tau_mol_atlid(int(ATLID_MASK_INDICES),:) - temp_betatot_atlid(:,:,:) = cospIN%betatot_atlid(int(ATLID_MASK_INDICES),:,:) - temp_tautot_atlid(:,:,:) = cospIN%tautot_atlid(int(ATLID_MASK_INDICES),:,:) - atlidIN%Ncolumns => cospIN%Ncolumns - atlidIN%Nlevels => cospIN%Nlevels - atlidIN%beta_mol_atlid => temp_beta_mol_atlid - atlidIN%betatot_atlid => temp_betatot_atlid - atlidIN%tau_mol_atlid => temp_tau_mol_atlid - atlidIN%tautot_atlid => temp_tautot_atlid - endif - else - atlidIN%Npoints => Npoints - atlidIN%Ncolumns => cospIN%Ncolumns - atlidIN%Nlevels => cospIN%Nlevels - atlidIN%beta_mol_atlid => cospIN%beta_mol_atlid - atlidIN%betatot_atlid => cospIN%betatot_atlid - atlidIN%tau_mol_atlid => cospIN%tau_mol_atlid - atlidIN%tautot_atlid => cospIN%tautot_atlid - endif + call COSP_ATLID_MASK(cospIN,cospgridIN,Npoints,atlidIN,ATLID_MASK_INDICES) endif if (Lparasol_subcolumn) then - if (cospIN % cospswathsIN(5) % N_inst_swaths .gt. 0) then - allocate(PARASOL_SWATH_MASK(Npoints)) - ! Do swathing to figure out which cells to simulate on - call compute_orbitmasks(Npoints, & - cospIN % cospswathsIN(5) % N_inst_swaths, & - cospIN % cospswathsIN(5) % inst_localtimes, & - cospIN % cospswathsIN(5) % inst_localtime_widths, & - cospgridIN%lat, cospgridIN%lon, & - cospgridIN%rttov_date(:,2), cospgridIN%rttov_date(:,3), & ! Time fields: month, dayofmonth - cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute - PARASOL_SWATH_MASK, N_PARASOL_SWATHED) ! Output: logical mask array - parasolIN%Npoints => N_PARASOL_SWATHED - PARASOL_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = PARASOL_SWATH_MASK) - if (verbose) print*,'parasolIN%Npoints: ',parasolIN%Npoints - if (verbose) print*,'PARASOL_SWATH_MASK: ',PARASOL_SWATH_MASK - if (parasolIN%Npoints .gt. 0) then - ! Allocate swathed arrays. - allocate(temp_tautot_S_liq(parasolIN%Npoints,cospIN%Ncolumns), & - temp_tautot_S_ice(parasolIN%Npoints,cospIN%Ncolumns)) - ! Encode step: Read only appropriate values into the new temp arrays. - temp_tautot_S_liq(:,:) = cospIN%tautot_S_liq(int(PARASOL_MASK_INDICES),:) - temp_tautot_S_ice(:,:) = cospIN%tautot_S_ice(int(PARASOL_MASK_INDICES),:) - parasolIN%Nlevels => cospIN%Nlevels - parasolIN%Ncolumns => cospIN%Ncolumns - parasolIN%Nrefl => cospIN%Nrefl - parasolIN%tautot_S_liq => temp_tautot_S_liq - parasolIN%tautot_S_ice => temp_tautot_S_ice - endif - else - parasolIN%Npoints => Npoints - parasolIN%Nlevels => cospIN%Nlevels - parasolIN%Ncolumns => cospIN%Ncolumns - parasolIN%Nrefl => cospIN%Nrefl - parasolIN%tautot_S_liq => cospIN%tautot_S_liq - parasolIN%tautot_S_ice => cospIN%tautot_S_ice - endif + call COSP_PARASOL_MASK(cospIN,cospgridIN,Npoints,parasolIN,PARASOL_MASK_INDICES) endif if (Lcloudsat_subcolumn) then - if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then - if (.not. allocated(CSCAL_SWATH_MASK)) then - allocate(CSCAL_SWATH_MASK(Npoints)) - ! Do swathing to figure out which cells to simulate on - call compute_orbitmasks(Npoints, & - cospIN % cospswathsIN(3) % N_inst_swaths, & - cospIN % cospswathsIN(3) % inst_localtimes, & - cospIN % cospswathsIN(3) % inst_localtime_widths, & - cospgridIN%lat, cospgridIN%lon, & - cospgridIN%rttov_date(:,2), cospgridIN%rttov_date(:,3), & ! Time fields: month, dayofmonth - cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute - CSCAL_SWATH_MASK, N_CSCAL_SWATHED) ! Output: logical mask array - cloudsatIN%Npoints => N_CSCAL_SWATHED - if (.not. allocated(CSCAL_MASK_INDICES)) allocate(CSCAL_MASK_INDICES(cloudsatIN%Npoints)) - CSCAL_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = CSCAL_SWATH_MASK) - else - cloudsatIN%Npoints => N_CSCAL_SWATHED - end if - if (verbose) print*,'cloudsatIN%Npoints: ',cloudsatIN%Npoints - if (verbose) print*,'CSCAL_SWATH_MASK: ',CSCAL_SWATH_MASK - if (cloudsatIN%Npoints .gt. 0) then - ! Allocate swathed arrays. - allocate(temp_z_vol_cloudsat(cloudsatIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & - temp_kr_vol_cloudsat(cloudsatIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & - temp_g_vol_cloudsat(cloudsatIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & - temp_hgt_matrix(cloudsatIN%Npoints,cospIN%Nlevels)) - ! Encode step: Read only appropriate values into the new temp arrays. - temp_z_vol_cloudsat = cospIN%z_vol_cloudsat(int(CSCAL_MASK_INDICES),:,:) - temp_kr_vol_cloudsat = cospIN%kr_vol_cloudsat(int(CSCAL_MASK_INDICES),:,:) - temp_g_vol_cloudsat = cospIN%g_vol_cloudsat(int(CSCAL_MASK_INDICES),:,:) - temp_hgt_matrix = cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES),:) - ! Reassign swathed values. - cloudsatIN%Nlevels => cospIN%Nlevels - cloudsatIN%Ncolumns => cospIN%Ncolumns - cloudsatIN%z_vol => temp_z_vol_cloudsat - cloudsatIN%kr_vol => temp_kr_vol_cloudsat - cloudsatIN%g_vol => temp_g_vol_cloudsat - cloudsatIN%rcfg => cospIN%rcfg_cloudsat - cloudsatIN%hgt_matrix => temp_hgt_matrix - endif - else - cloudsatIN%Npoints => Npoints - cloudsatIN%Nlevels => cospIN%Nlevels - cloudsatIN%Ncolumns => cospIN%Ncolumns - cloudsatIN%z_vol => cospIN%z_vol_cloudsat - cloudsatIN%kr_vol => cospIN%kr_vol_cloudsat - cloudsatIN%g_vol => cospIN%g_vol_cloudsat - cloudsatIN%rcfg => cospIN%rcfg_cloudsat - cloudsatIN%hgt_matrix => cospgridIN%hgt_matrix - end if + call COSP_CLOUDSAT_MASK(cospIN,cospgridIN,Npoints,cloudsatIN,CSCAL_MASK_INDICES,CSCAL_SWATH_MASK) endif if (Lmodis_subcolumn) then - if (cospIN % cospswathsIN(6) % N_inst_swaths .gt. 0) then - allocate(MODIS_SWATH_MASK(Npoints)) - ! Do swathing to figure out which cells to simulate on - call compute_orbitmasks(Npoints, & - cospIN % cospswathsIN(6) % N_inst_swaths, & - cospIN % cospswathsIN(6) % inst_localtimes, & - cospIN % cospswathsIN(6) % inst_localtime_widths, & - cospgridIN%lat, cospgridIN%lon, & - cospgridIN%rttov_date(:,2), cospgridIN%rttov_date(:,3), & ! Time fields: month, dayofmonth - cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute - MODIS_SWATH_MASK, N_MODIS_SWATHED) ! Output: logical mask array - - ! Operate a little differently with MODIS because there is already some swathing at play. - ! modisIN is over all variables rather than just swathed variables - modisIN%Ncolumns => cospIN%Ncolumns - modisIN%Nlevels => cospIN%Nlevels - modisIN%Npoints => Npoints - modisIN%liqFrac => cospIN%fracLiq - modisIN%tau => cospIN%tau_067 - modisIN%g => cospIN%asym - modisIN%w0 => cospIN%ss_alb - - allocate(modisIN%pres(modisIN%Npoints,cospIN%Nlevels+1)) ! Moving this outside of the sunlit statements for consistency with the other variables - modisIN%Nsunlit = count((cospgridIN%sunlit > 0) .and. MODIS_SWATH_MASK) ! Sunlit mask and indices array will just include swathing as well - modisIN%pres = cospgridIN%phalf - if (modisIN%Nsunlit .gt. 0) then - allocate(modisIN%sunlit(modisIN%Nsunlit)) - modisIN%sunlit = pack((/ (i, i = 1, modisIN%Npoints ) /),mask = ((cospgridIN%sunlit > 0) .and. MODIS_SWATH_MASK)) ! Indices of columns to operate on in modisIN - if (verbose) print*,'modisIN%Nsunlit: ',modisIN%Nsunlit - if (verbose) print*,'modisIN%sunlit: ',modisIN%sunlit - endif - if (modisIN%Npoints - modisIN%Nsunlit .gt. 0) then ! If more than zero tiles are not sunlit and swathed, create array to mask out these gridcells in cospOUT - allocate(modisIN%notSunlit(modisIN%Npoints - modisIN%Nsunlit)) - modisIN%notSunlit = pack((/ (i, i = 1, Npoints ) /),mask = (.not. ((cospgridIN%sunlit > 0) .and. MODIS_SWATH_MASK))) ! Create an array with the indices of the non-sunlit tiles - endif - ! Create a CSCAL-MODIS joint mask for the combined product. - if (allocated(CSCAL_SWATH_MASK)) then - allocate(MODIS_CSCAL_SWATH_MASK(Npoints)) - MODIS_CSCAL_SWATH_MASK = (.not. (MODIS_SWATH_MASK .and. CSCAL_SWATH_MASK)) ! Gridcells not seen by both MODIS and CSCAL should be set to zero - MODIS_CSCAL_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = MODIS_CSCAL_SWATH_MASK) - ! else - ! MODIS_CSCAL_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = .not. MODIS_SWATH_MASK) - end if - else - modisIN%Ncolumns => cospIN%Ncolumns - modisIN%Nlevels => cospIN%Nlevels - modisIN%Npoints => Npoints - modisIN%liqFrac => cospIN%fracLiq - modisIN%tau => cospIN%tau_067 - modisIN%g => cospIN%asym - modisIN%w0 => cospIN%ss_alb - modisIN%Nsunlit = count(cospgridIN%sunlit > 0) - if (modisIN%Nsunlit .gt. 0) then - allocate(modisIN%sunlit(modisIN%Nsunlit),modisIN%pres(modisIN%Nsunlit,cospIN%Nlevels+1)) - modisIN%sunlit = pack((/ (i, i = 1, Npoints ) /),mask = cospgridIN%sunlit > 0) - modisIN%pres = cospgridIN%phalf(int(modisIN%sunlit(:)),:) ! JKS no reason to have this structure differently, right? Memory? - endif - if (count(cospgridIN%sunlit <= 0) .gt. 0) then ! If more than zero tiles are not sunlit a.k.a. if there are dark tiles - allocate(modisIN%notSunlit(count(cospgridIN%sunlit <= 0))) - modisIN%notSunlit = pack((/ (i, i = 1, Npoints ) /),mask = .not. cospgridIN%sunlit > 0) ! Create an array with the indices of the non-sunlit tiles - endif - end if + call COSP_MODIS_MASK(cospIN,cospgridIN,Npoints,modisIN,CSCAL_SWATH_MASK,MODIS_CSCAL_MASK_INDICES) endif if (Lrttov_column) then @@ -1206,8 +696,8 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) rttovIN%cldIce => cospgridIN%cloudIce rttovIN%DeffLiq => cospgridIN%DeffLiq rttovIN%DeffIce => cospgridIN%DeffIce - rttovIN%fl_rain => cospgridIN%fl_rain ! JKS remove? No, keep in case of RTTOV-SCATT implementation. - rttovIN%fl_snow => cospgridIN%fl_snow ! JKS remove? No, keep in case of RTTOV-SCATT implementation. + rttovIN%fl_rain => cospgridIN%fl_rain ! Keep in case of RTTOV-SCATT implementation. + rttovIN%fl_snow => cospgridIN%fl_snow ! Keep in case of RTTOV-SCATT implementation. endif !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1216,111 +706,70 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! ISCCP (icarus) subcolumn simulator if (Lisccp_subcolumn .or. Lmodis_subcolumn) then - if (verbose) print*,'ISCCP Subcol' - if (cospIN % cospswathsIN(1) % N_inst_swaths .gt. 0) then - if (isccpIN%Npoints .gt. 0) then - allocate(isccpLEVMATCH(isccpIN%Npoints,isccpIN%Ncolumns), & - isccp_boxttop(isccpIN%Npoints,isccpIN%Ncolumns), & - isccp_boxptop(isccpIN%Npoints,isccpIN%Ncolumns), & - isccp_boxtau(isccpIN%Npoints,isccpIN%Ncolumns), & - isccp_meantbclr(isccpIN%Npoints)) - ! Call simulator - call icarus_subcolumn(isccpIN%npoints,isccpIN%ncolumns,isccpIN%nlevels, & - isccpIN%sunlit,isccpIN%dtau,isccpIN%dem,isccpIN%skt, & - isccpIN%emsfc_lw,isccpIN%qv,isccpIN%at,isccpIN%pfull, & - isccpIN%phalf,isccpIN%frac_out,isccpLEVMATCH, & - isccp_boxtau(:,:),isccp_boxptop(:,:), & - isccp_boxttop(:,:),isccp_meantbclr(:)) + if (isccpIN%Npoints .gt. 0) then + allocate(isccpLEVMATCH(isccpIN%Npoints,isccpIN%Ncolumns), & + isccp_boxttop(isccpIN%Npoints,isccpIN%Ncolumns), & + isccp_boxptop(isccpIN%Npoints,isccpIN%Ncolumns), & + isccp_boxtau(isccpIN%Npoints,isccpIN%Ncolumns), & + isccp_meantbclr(isccpIN%Npoints)) + ! Call simulator + call icarus_subcolumn(isccpIN%npoints,isccpIN%ncolumns,isccpIN%nlevels, & + isccpIN%sunlit,isccpIN%dtau,isccpIN%dem,isccpIN%skt, & + isccpIN%emsfc_lw,isccpIN%qv,isccpIN%at,isccpIN%pfull, & + isccpIN%phalf,isccpIN%frac_out,isccpLEVMATCH, & + isccp_boxtau(:,:),isccp_boxptop(:,:), & + isccp_boxttop(:,:),isccp_meantbclr(:)) + if (cospIN % cospswathsIN(1) % N_inst_swaths .gt. 0) then ! Decode outputs from swaths when reading into cospOUT fields - cospOUT%isccp_boxtau(ij:ik,:) = R_UNDEF - cospOUT%isccp_boxptop(ij:ik,:) = R_UNDEF - cospOUT%isccp_meantbclr(ij:ik) = R_UNDEF - if (associated(cospOUT%isccp_boxtau)) cospOUT%isccp_boxtau(ij+int(ISCCP_MASK_INDICES)-1,:) = isccp_boxtau(:,:) - if (associated(cospOUT%isccp_boxptop)) cospOUT%isccp_boxptop(ij+int(ISCCP_MASK_INDICES)-1,:) = isccp_boxptop(:,:) - if (associated(cospOUT%isccp_meantbclr)) cospOUT%isccp_meantbclr(ij+int(ISCCP_MASK_INDICES)-1) = isccp_meantbclr(:) - deallocate(temp_isccp_skt,temp_isccp_qv,temp_isccp_at, & - temp_isccp_frac_out,temp_isccp_tau_067, & - temp_isccp_emiss_11,temp_isccp_phalf, & - temp_isccp_pfull) - else - cospOUT%isccp_boxtau(ij:ik,:) = R_UNDEF - cospOUT%isccp_boxptop(ij:ik,:) = R_UNDEF - cospOUT%isccp_meantbclr(ij:ik) = R_UNDEF - end if - else ! Proceed normally - allocate(isccpLEVMATCH(isccpIN%Npoints,isccpIN%Ncolumns), & - isccp_boxttop(isccpIN%Npoints,isccpIN%Ncolumns), & - isccp_boxptop(isccpIN%Npoints,isccpIN%Ncolumns), & - isccp_boxtau(isccpIN%Npoints,isccpIN%Ncolumns), & - isccp_meantbclr(isccpIN%Npoints)) - ! Call simulator - call icarus_subcolumn(isccpIN%npoints,isccpIN%ncolumns,isccpIN%nlevels, & - isccpIN%sunlit,isccpIN%dtau,isccpIN%dem,isccpIN%skt, & - isccpIN%emsfc_lw,isccpIN%qv,isccpIN%at,isccpIN%pfull, & - isccpIN%phalf,isccpIN%frac_out,isccpLEVMATCH, & - isccp_boxtau(:,:),isccp_boxptop(:,:), & - isccp_boxttop(:,:),isccp_meantbclr(:)) - ! Store output (if requested) - if (associated(cospOUT%isccp_boxtau)) then - cospOUT%isccp_boxtau(ij:ik,:) = isccp_boxtau - endif - if (associated(cospOUT%isccp_boxptop)) then - cospOUT%isccp_boxptop(ij:ik,:) = isccp_boxptop - endif - if (associated(cospOUT%isccp_meantbclr)) then - cospOUT%isccp_meantbclr(ij:ik) = isccp_meantbclr - endif - endif - endif - - ! MISR subcolumn simulator + cospOUT%isccp_boxtau(ij:ik,:) = R_UNDEF + cospOUT%isccp_boxptop(ij:ik,:) = R_UNDEF + cospOUT%isccp_meantbclr(ij:ik) = R_UNDEF + if (associated(cospOUT%isccp_boxtau)) cospOUT%isccp_boxtau(ij+int(ISCCP_MASK_INDICES)-1,:) = isccp_boxtau(:,:) + if (associated(cospOUT%isccp_boxptop)) cospOUT%isccp_boxptop(ij+int(ISCCP_MASK_INDICES)-1,:) = isccp_boxptop(:,:) + if (associated(cospOUT%isccp_meantbclr)) cospOUT%isccp_meantbclr(ij+int(ISCCP_MASK_INDICES)-1) = isccp_meantbclr(:) + else + if (associated(cospOUT%isccp_boxtau)) cospOUT%isccp_boxtau(ij:ik,:) = isccp_boxtau + if (associated(cospOUT%isccp_boxptop)) cospOUT%isccp_boxptop(ij:ik,:) = isccp_boxptop + if (associated(cospOUT%isccp_meantbclr)) cospOUT%isccp_meantbclr(ij:ik) = isccp_meantbclr + end if + else + cospOUT%isccp_boxtau(ij:ik,:) = R_UNDEF + cospOUT%isccp_boxptop(ij:ik,:) = R_UNDEF + cospOUT%isccp_meantbclr(ij:ik) = R_UNDEF + end if + end if + + ! MISR subcolumn simulator if (Lmisr_subcolumn) then - if (verbose) print*,'MISR Subcol' - if (cospIN % cospswathsIN(2) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays - if (misrIN%Npoints .gt. 0) then - ! Allocate space for local variables. - allocate(misr_boxztop(misrIN%Npoints,misrIN%Ncolumns), & - misr_boxtau(misrIN%Npoints,misrIN%Ncolumns), & - misr_dist_model_layertops(misrIN%Npoints,numMISRHgtBins)) - ! print*,'MISR Subcol-1' - ! Call simulator - call misr_subcolumn(misrIN%Npoints,misrIN%Ncolumns,misrIN%Nlevels,misrIN%dtau, & - misrIN%zfull,misrIN%at,misrIN%sunlit,misr_boxtau, & - misr_dist_model_layertops,misr_boxztop) - ! Decode outputs from swaths when reading into cospOUT fields - ! print*,'MISR Subcol-3' - cospOUT%misr_dist_model_layertops(ij:ik,:) = R_UNDEF - if (associated(cospOUT%misr_dist_model_layertops)) cospOUT%misr_dist_model_layertops(ij+int(MISR_MASK_INDICES)-1,:) = misr_dist_model_layertops(:,:) - ! print*,'MISR Subcol-4' - deallocate(temp_misr_zfull,temp_misr_at,temp_misr_dtau) - else - cospOUT%misr_dist_model_layertops(ij:ik,:) = R_UNDEF - endif - else - allocate(misr_boxztop(misrIN%Npoints,misrIN%Ncolumns), & - misr_boxtau(misrIN%Npoints,misrIN%Ncolumns), & - misr_dist_model_layertops(misrIN%Npoints,numMISRHgtBins)) - ! Call simulator - call misr_subcolumn(misrIN%Npoints,misrIN%Ncolumns,misrIN%Nlevels,misrIN%dtau, & - misrIN%zfull,misrIN%at,misrIN%sunlit,misr_boxtau, & - misr_dist_model_layertops,misr_boxztop) - ! Store output (if requested) - if (associated(cospOUT%misr_dist_model_layertops)) then - cospOUT%misr_dist_model_layertops(ij:ik,:) = misr_dist_model_layertops - endif - endif - endif + if (misrIN%Npoints .gt. 0) then + ! Allocate space for local variables. + allocate(misr_boxztop(misrIN%Npoints,misrIN%Ncolumns), & + misr_boxtau(misrIN%Npoints,misrIN%Ncolumns), & + misr_dist_model_layertops(misrIN%Npoints,numMISRHgtBins)) + ! Call simulator + call misr_subcolumn(misrIN%Npoints,misrIN%Ncolumns,misrIN%Nlevels,misrIN%dtau, & + misrIN%zfull,misrIN%at,misrIN%sunlit,misr_boxtau, & + misr_dist_model_layertops,misr_boxztop) + if (cospIN % cospswathsIN(2) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + ! Decode outputs from swaths when reading into cospOUT fields + cospOUT%misr_dist_model_layertops(ij:ik,:) = R_UNDEF + if (associated(cospOUT%misr_dist_model_layertops)) cospOUT%misr_dist_model_layertops(ij+int(MISR_MASK_INDICES)-1,:) = misr_dist_model_layertops(:,:) + else + if (associated(cospOUT%misr_dist_model_layertops)) cospOUT%misr_dist_model_layertops(ij:ik,:) = misr_dist_model_layertops + end if + else + cospOUT%misr_dist_model_layertops(ij:ik,:) = R_UNDEF + end if + end if ! Calipso subcolumn simulator if (Lcalipso_subcolumn) then - if (verbose) print*,'CALIPSO Subcol' if (calipsoIN%Npoints .gt. 0) then ! Allocate space for local variables allocate(calipso_beta_mol(calipsoIN%Npoints,calipsoIN%Nlevels), & calipso_beta_tot(calipsoIN%Npoints,calipsoIN%Ncolumns,calipsoIN%Nlevels),& calipso_betaperp_tot(calipsoIN%Npoints,calipsoIN%Ncolumns,calipsoIN%Nlevels)) ! Call simulator - ! print*,'CALIPSO Subcol-2' call lidar_subcolumn(calipsoIN%npoints, calipsoIN%ncolumns, calipsoIN%nlevels, .false., & calipsoIN%beta_mol, calipsoIN%tau_mol, calipsoIN%betatot, calipsoIN%tautot, & calipso_beta_mol(:,:), calipso_beta_tot(:,:,:), calipsoIN%betatot_ice, & @@ -1328,24 +777,17 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) calipso_betaperp_tot(:,:,:)) if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays ! Decode outputs from swaths when reading into cospOUT fields - ! print*,'CALIPSO Subcol-3' cospOUT%calipso_beta_mol(ij:ik,:) = R_UNDEF cospOUT%calipso_beta_tot(ij:ik,:,:) = R_UNDEF cospOUT%calipso_betaperp_tot(ij:ik,:,:) = R_UNDEF if (associated(cospOUT%calipso_beta_mol)) cospOUT%calipso_beta_mol(ij+int(CSCAL_MASK_INDICES)-1,calipsoIN%Nlevels:1:-1) = calipso_beta_mol(:,:) if (associated(cospOUT%calipso_beta_tot)) cospOUT%calipso_beta_tot(ij+int(CSCAL_MASK_INDICES)-1,:,calipsoIN%Nlevels:1:-1) = calipso_beta_tot(:,:,:) if (associated(cospOUT%calipso_betaperp_tot)) cospOUT%calipso_betaperp_tot(ij+int(CSCAL_MASK_INDICES)-1,:,:) = calipso_betaperp_tot(:,:,:) - ! print*,'CALIPSO Subcol-4' - deallocate(temp_beta_mol_calipso,temp_tau_mol_calipso,temp_betatot_calipso,temp_tautot_calipso, & - temp_betatot_liq_calipso,temp_tautot_liq_calipso,temp_betatot_ice_calipso,temp_tautot_ice_calipso) else ! Proceed normally ! Store output (if requested) - if (associated(cospOUT%calipso_beta_mol)) & - cospOUT%calipso_beta_mol(ij:ik,calipsoIN%Nlevels:1:-1) = calipso_beta_mol - if (associated(cospOUT%calipso_beta_tot)) & - cospOUT%calipso_beta_tot(ij:ik,:,calipsoIN%Nlevels:1:-1) = calipso_beta_tot - if (associated(cospOUT%calipso_betaperp_tot)) & - cospOUT%calipso_betaperp_tot(ij:ik,:,:) = calipso_betaperp_tot + if (associated(cospOUT%calipso_beta_mol)) cospOUT%calipso_beta_mol(ij:ik,calipsoIN%Nlevels:1:-1) = calipso_beta_mol + if (associated(cospOUT%calipso_beta_tot)) cospOUT%calipso_beta_tot(ij:ik,:,calipsoIN%Nlevels:1:-1) = calipso_beta_tot + if (associated(cospOUT%calipso_betaperp_tot)) cospOUT%calipso_betaperp_tot(ij:ik,:,:) = calipso_betaperp_tot endif else cospOUT%calipso_beta_mol(ij:ik,:) = R_UNDEF @@ -1372,7 +814,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! ATLID subcolumn simulator if (Latlid_subcolumn) then - if (verbose) print*,'ATLID Subcol' if (atlidIN%Npoints .gt. 0) then ! Allocate space for local variables allocate(atlid_beta_mol(atlidIN%Npoints,atlidIN%Nlevels), & @@ -1383,13 +824,10 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) atlidIN%tautot_atlid, atlid_beta_mol(:,:), atlid_beta_tot(:,:,:)) ! Decode outputs from swaths when reading into cospOUT fields if (cospIN % cospswathsIN(4) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays - ! print*,'ATLID Subcol-1' cospOUT%atlid_beta_mol(ij:ik,:) = R_UNDEF cospOUT%atlid_beta_tot(ij:ik,:,:) = R_UNDEF if (associated(cospOUT%atlid_beta_mol)) cospOUT%atlid_beta_mol(ij+int(ATLID_MASK_INDICES)-1,atlidIN%Nlevels:1:-1) = atlid_beta_mol(:,:) if (associated(cospOUT%atlid_beta_tot)) cospOUT%atlid_beta_tot(ij+int(ATLID_MASK_INDICES)-1,:,atlidIN%Nlevels:1:-1) = atlid_beta_tot(:,:,:) - ! print*,'ATLID Subcol-2' - deallocate(temp_beta_mol_atlid,temp_betatot_atlid,temp_tau_mol_atlid,temp_tautot_atlid) else ! Store output (if requested) if (associated(cospOUT%atlid_beta_mol)) & @@ -1405,7 +843,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! PARASOL subcolumn simulator if (Lparasol_subcolumn) then - if (verbose) print*,'PARASOL Subcol' if (parasolIN%Npoints .gt. 0) then ! Allocate space for local variables allocate(parasolPix_refl(parasolIN%Npoints,parasolIN%Ncolumns,PARASOL_NREFL)) @@ -1426,18 +863,14 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) else cospOUT%parasolPix_refl(ij:ik,:,1:PARASOL_NREFL) = R_UNDEF endif - if (allocated(temp_tautot_S_liq)) deallocate(temp_tautot_S_liq) - if (allocated(temp_tautot_S_ice)) deallocate(temp_tautot_S_ice) endif ! Cloudsat (quickbeam) subcolumn simulator if (Lcloudsat_subcolumn) then ! Allocate space for local variables - if (verbose) print*,'CLOUDSAT Subcol' if (cloudsatIN%Npoints .gt. 0) then allocate(cloudsatDBZe(cloudsatIN%Npoints,cloudsatIN%Ncolumns,cloudsatIN%Nlevels), & cloudsatZe_non(cloudsatIN%Npoints,cloudsatIN%Ncolumns,cloudsatIN%Nlevels)) - ! print*,'CLOUDSAT Subcol-0.5' do icol=1,cloudsatIN%ncolumns call quickbeam_subcolumn(cloudsatIN%rcfg,cloudsatIN%Npoints,cloudsatIN%Nlevels,& cloudsatIN%hgt_matrix/1000._wp, & @@ -1445,14 +878,10 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cloudsatIN%kr_vol(:,icol,:), & cloudsatIN%g_vol(:,1,:),cloudsatDBze(:,icol,:),cloudsatZe_non(:,icol,:)) enddo - ! print*,'CLOUDSAT Subcol-1' ! Store output (if requested) if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays - ! print*,'CLOUDSAT Subcol-2' cospOUT%cloudsat_Ze_tot(ij:ik,:,:) = R_UNDEF if (associated(cospOUT%cloudsat_Ze_tot)) cospOUT%cloudsat_Ze_tot(ij+int(CSCAL_MASK_INDICES)-1,:,1:cloudsatIN%Nlevels) = cloudsatDBZe(:,:,1:cloudsatIN%Nlevels) - ! print*,'CLOUDSAT Subcol-4' - deallocate(temp_hgt_matrix,temp_z_vol_cloudsat,temp_kr_vol_cloudsat,temp_g_vol_cloudsat) else if (associated(cospOUT%cloudsat_Ze_tot)) cospOUT%cloudsat_Ze_tot(ij:ik,:,:) = cloudsatDBZe(:,:,1:cloudsatIN%Nlevels) endif @@ -1460,16 +889,16 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospOUT%cloudsat_Ze_tot(ij:ik,:,:) = R_UNDEF endif endif + + ! MODIS subcolumn simulator if (Lmodis_subcolumn) then - if (verbose) print*,'MODIS Subcol' if (modisiN%nSunlit > 0) then ! Allocate space for local variables allocate(modisRetrievedTau(modisIN%nSunlit,modisIN%nColumns), & modisRetrievedSize(modisIN%nSunlit,modisIN%nColumns), & modisRetrievedPhase(modisIN%nSunlit,modisIN%nColumns), & modisRetrievedCloudTopPressure(modisIN%nSunlit,modisIN%nColumns)) - ! print*,'MODIS Subcol-1' - if (allocated(ISCCP_SWATH_MASK)) then ! If ISCCP is swathed must run ICARUS separately for MODIS + if ((Lisccp_subcolumn .or. Lmodis_subcolumn) .and. (cospIN % cospswathsIN(1) % N_inst_swaths .gt. 0)) then ! If ISCCP is swathed must run ICARUS separately for MODIS allocate(modisLEVMATCH(modisIN%Npoints,modisIN%Ncolumns), & modis_boxptop(modisIN%Npoints,modisIN%Ncolumns), & modis_boxttop(modisIN%Npoints,modisIN%Ncolumns), & @@ -1502,10 +931,9 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) modis_boxptop(int(modisIN%sunlit(i)),:), & modisRetrievedPhase(i,:), & modisRetrievedCloudTopPressure(i,:), & - modisRetrievedTau(i,:),modisRetrievedSize(i,:)) + modisRetrievedTau(i,:),modisRetrievedSize(i,:)) end do deallocate(modis_boxptop) - ! print*,'MODIS Subcol-2' endif endif @@ -1542,22 +970,20 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) endif ! Call simulator - if (cospIN % cospswathsIN(1) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays - if (isccpIN%Npoints .gt. 0) then - ! Operate at the masked format. - allocate(temp_isccp_fq(isccpIN%Npoints,numISCCPTauBins,numISCCPPresBins), & - temp_isccp_meanalbedocld(isccpIN%Npoints), & - temp_isccp_meanptop(isccpIN%Npoints), & - temp_isccp_meantaucld(isccpIN%Npoints), & - temp_isccp_totalcldarea(isccpIN%Npoints), & - temp_isccp_meantb(isccpIN%Npoints)) - - call icarus_column(isccpIN%npoints, isccpIN%ncolumns,isccp_boxtau(:,:), & - isccp_boxptop(:,:)/100._wp,isccpIN%sunlit,isccp_boxttop(:,:), & - temp_isccp_fq, & - temp_isccp_meanalbedocld, & - temp_isccp_meanptop,temp_isccp_meantaucld, & - temp_isccp_totalcldarea,temp_isccp_meantb) + if (isccpIN%Npoints .gt. 0) then + allocate(temp_isccp_fq(isccpIN%Npoints,numISCCPTauBins,numISCCPPresBins), & + temp_isccp_meanalbedocld(isccpIN%Npoints), & + temp_isccp_meanptop(isccpIN%Npoints), & + temp_isccp_meantaucld(isccpIN%Npoints), & + temp_isccp_totalcldarea(isccpIN%Npoints), & + temp_isccp_meantb(isccpIN%Npoints)) + call icarus_column(isccpIN%npoints, isccpIN%ncolumns,isccp_boxtau(:,:), & + isccp_boxptop(:,:)/100._wp,isccpIN%sunlit,isccp_boxttop(:,:), & + temp_isccp_fq, & + temp_isccp_meanalbedocld, & + temp_isccp_meanptop,temp_isccp_meantaucld, & + temp_isccp_totalcldarea,temp_isccp_meantb) + if (cospIN % cospswathsIN(1) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays ! Decode back to the cospOUT shapes cospOUT%isccp_fq(ij:ik,:,:) = R_UNDEF cospOUT%isccp_meanalbedocld(ij:ik) = R_UNDEF @@ -1571,23 +997,22 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (associated(cospOUT%isccp_meantaucld)) cospOUT%isccp_meantaucld(ij+int(ISCCP_MASK_INDICES)-1) = temp_isccp_meantaucld(:) if (associated(cospOUT%isccp_totalcldarea)) cospOUT%isccp_totalcldarea(ij+int(ISCCP_MASK_INDICES)-1) = temp_isccp_totalcldarea(:) if (associated(cospOUT%isccp_meantb)) cospOUT%isccp_meantb(ij+int(ISCCP_MASK_INDICES)-1) = temp_isccp_meantb(:) - deallocate(ISCCP_SWATH_MASK,ISCCP_MASK_INDICES,temp_isccp_fq,temp_isccp_meanalbedocld,temp_isccp_meanptop,temp_isccp_meantaucld,temp_isccp_totalcldarea,temp_isccp_meantb) else - cospOUT%isccp_fq(ij:ik,:,:) = R_UNDEF - cospOUT%isccp_meanalbedocld(ij:ik) = R_UNDEF - cospOUT%isccp_meanptop(ij:ik) = R_UNDEF - cospOUT%isccp_meantaucld(ij:ik) = R_UNDEF - cospOUT%isccp_totalcldarea(ij:ik) = R_UNDEF - cospOUT%isccp_meantb(ij:ik) = R_UNDEF - deallocate(ISCCP_SWATH_MASK,ISCCP_MASK_INDICES) - end if + if (associated(cospOUT%isccp_fq)) cospOUT%isccp_fq(ij:ik,:,:) = temp_isccp_fq(:,:,:) + if (associated(cospOUT%isccp_meanalbedocld)) cospOUT%isccp_meanalbedocld(ij:ik) = temp_isccp_meanalbedocld(:) + if (associated(cospOUT%isccp_meanptop)) cospOUT%isccp_meanptop(ij:ik) = temp_isccp_meanptop(:) + if (associated(cospOUT%isccp_meantaucld)) cospOUT%isccp_meantaucld(ij:ik) = temp_isccp_meantaucld(:) + if (associated(cospOUT%isccp_totalcldarea)) cospOUT%isccp_totalcldarea(ij:ik) = temp_isccp_totalcldarea(:) + if (associated(cospOUT%isccp_meantb)) cospOUT%isccp_meantb(ij:ik) = temp_isccp_meantb(:) + end if + deallocate(temp_isccp_fq,temp_isccp_meanalbedocld,temp_isccp_meanptop,temp_isccp_meantaucld,temp_isccp_totalcldarea,temp_isccp_meantb) else - call icarus_column(isccpIN%npoints, isccpIN%ncolumns,isccp_boxtau(:,:), & - isccp_boxptop(:,:)/100._wp, isccpIN%sunlit,isccp_boxttop(:,:), & - cospOUT%isccp_fq(ij:ik,:,:), & - cospOUT%isccp_meanalbedocld(ij:ik), & - cospOUT%isccp_meanptop(ij:ik),cospOUT%isccp_meantaucld(ij:ik), & - cospOUT%isccp_totalcldarea(ij:ik),cospOUT%isccp_meantb(ij:ik)) + cospOUT%isccp_fq(ij:ik,:,:) = R_UNDEF + cospOUT%isccp_meanalbedocld(ij:ik) = R_UNDEF + cospOUT%isccp_meanptop(ij:ik) = R_UNDEF + cospOUT%isccp_meantaucld(ij:ik) = R_UNDEF + cospOUT%isccp_totalcldarea(ij:ik) = R_UNDEF + cospOUT%isccp_meantb(ij:ik) = R_UNDEF end if cospOUT%isccp_fq(ij:ik,:,:) = cospOUT%isccp_fq(ij:ik,:,7:1:-1) @@ -1603,7 +1028,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (allocated(isccp_boxtau)) deallocate(isccp_boxtau) if (allocated(isccp_meantbclr)) deallocate(isccp_meantbclr) if (allocated(isccpLEVMATCH)) deallocate(isccpLEVMATCH) - if (allocated(temp_isccp_sunlit)) deallocate(temp_isccp_sunlit) + if (allocated(ISCCP_MASK_INDICES)) deallocate(ISCCP_MASK_INDICES) if (allocated(out1D_1)) then deallocate(out1D_1) nullify(cospOUT%isccp_meanalbedocld) @@ -1628,7 +1053,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) deallocate(out1D_6) nullify(cospOUT%isccp_fq) endif - ! Clear up memory for ISCCP swath variables endif ! MISR @@ -1649,17 +1073,14 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Call simulator if (cospIN % cospswathsIN(2) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays - if (verbose) print*,'MISR' if (misrIN%Npoints .gt. 0) then ! Operate at the masked format. allocate(temp_misr_cldarea(misrIN%Npoints), & temp_misr_meanztop(misrIN%Npoints), & temp_misr_fq(misrIN%Npoints,numMISRTauBins,numMISRHgtBins)) - ! print*,'MISR-1' call misr_column(misrIN%Npoints,misrIN%Ncolumns,misr_boxztop,misrIN%sunlit, & misr_boxtau,temp_misr_cldarea(:), & temp_misr_meanztop(:),temp_misr_fq(:,:,:)) - ! print*,'MISR-2' ! Decode back to the cospOUT shapes cospOUT%misr_cldarea(ij:ik) = R_UNDEF cospOUT%misr_meanztop(ij:ik) = R_UNDEF @@ -1667,13 +1088,11 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (associated(cospOUT%misr_cldarea)) cospOUT%misr_cldarea(ij+int(MISR_MASK_INDICES)-1) = temp_misr_cldarea(:) if (associated(cospOUT%misr_meanztop)) cospOUT%misr_meanztop(ij+int(MISR_MASK_INDICES)-1) = temp_misr_meanztop(:) if (associated(cospOUT%misr_fq)) cospOUT%misr_fq(ij+int(MISR_MASK_INDICES)-1,:,:) = temp_misr_fq(:,:,:) - ! print*,'MISR-3' - deallocate(MISR_SWATH_MASK,MISR_MASK_INDICES,temp_misr_sunlit,temp_misr_cldarea,temp_misr_meanztop,temp_misr_fq) + deallocate(temp_misr_cldarea,temp_misr_meanztop,temp_misr_fq) else cospOUT%misr_cldarea(ij:ik) = R_UNDEF cospOUT%misr_meanztop(ij:ik) = R_UNDEF cospOUT%misr_fq(ij:ik,:,:) = R_UNDEF - deallocate(MISR_SWATH_MASK,MISR_MASK_INDICES) endif else call misr_column(misrIN%Npoints,misrIN%Ncolumns,misr_boxztop,misrIN%sunlit,& @@ -1684,6 +1103,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (allocated(misr_boxtau)) deallocate(misr_boxtau) if (allocated(misr_boxztop)) deallocate(misr_boxztop) if (allocated(misr_dist_model_layertops)) deallocate(misr_dist_model_layertops) + if (allocated(MISR_MASK_INDICES)) deallocate(MISR_MASK_INDICES) if (allocated(out1D_1)) then deallocate(out1D_1) nullify(cospOUT%misr_cldarea) @@ -1753,7 +1173,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Call simulator if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays ! Operate at the masked format. - if (verbose) print*,'CALIPSO' if (calipsoIN%Npoints .gt. 0) then allocate(temp_calipso_cfad_sr(calipsoIN%Npoints,SR_BINS,Nlvgrid), & temp_calipso_lidarcld(calipsoIN%Npoints,Nlvgrid), & @@ -1768,7 +1187,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) temp_calipso_cldlayerphase(calipsoIN%Npoints,LIDAR_NCAT,6), & temp_calipso_lidarcldtmp(calipsoIN%Npoints,LIDAR_NTEMP,5)) ok_lidar_cfad=.true. - ! print*,'CALIPSO-1' call lidar_column(calipsoIN%Npoints, calipsoIN%Ncolumns, calipsoIN%Nlevels, & Nlvgrid, SR_BINS, LIDAR_NTYPE, 'calipso',calipso_beta_tot(:,:,:), calipso_beta_mol(:,:), & cospgridIN%phalf(int(CSCAL_MASK_INDICES),2:calipsoIN%Nlevels+1), & @@ -1783,7 +1201,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) temp_calipso_cldtypemeanzse(:,:), temp_calipso_cldthinemis(:), & temp_calipso_cldlayerphase(:,:,:), temp_calipso_lidarcldtmp(:,:,:)) ! Decode back to the cospOUT shapes - ! print*,'CALIPSO-2' cospOUT%calipso_cfad_sr(ij:ik,:,:) = R_UNDEF cospOUT%calipso_lidarcld(ij:ik,:) = R_UNDEF cospOUT%calipso_cldlayer(ij:ik,:) = R_UNDEF @@ -1808,8 +1225,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (associated(cospOUT%calipso_cldthinemis)) cospOUT%calipso_cldthinemis(ij+int(CSCAL_MASK_INDICES)-1) = temp_calipso_cldthinemis(:) if (associated(cospOUT%calipso_cldlayerphase)) cospOUT%calipso_cldlayerphase(ij+int(CSCAL_MASK_INDICES)-1,:,:) = temp_calipso_cldlayerphase(:,:,:) if (associated(cospOUT%calipso_lidarcldtmp)) cospOUT%calipso_lidarcldtmp(ij+int(CSCAL_MASK_INDICES)-1,:,:) = temp_calipso_lidarcldtmp(:,:,:) - ! print*,'CALIPSO-3' - deallocate(CSCAL_SWATH_MASK,temp_calipso_cfad_sr,temp_calipso_lidarcld,temp_calipso_cldlayer,temp_calipso_lidarcldphase, & + deallocate(temp_calipso_cfad_sr,temp_calipso_lidarcld,temp_calipso_cldlayer,temp_calipso_lidarcldphase, & temp_calipso_lidarcldtype,temp_calipso_cldtype,temp_calipso_cldtypetemp,temp_calipso_cldtypemeanz, & temp_calipso_cldtypemeanzse,temp_calipso_cldthinemis,temp_calipso_cldlayerphase,temp_calipso_lidarcldtmp) else @@ -1825,7 +1241,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospOUT%calipso_cldthinemis(ij:ik) = R_UNDEF cospOUT%calipso_cldlayerphase(ij:ik,:,:) = R_UNDEF cospOUT%calipso_lidarcldtmp(ij:ik,:,:) = R_UNDEF - deallocate(CSCAL_SWATH_MASK) endif else ok_lidar_cfad=.true. @@ -1942,7 +1357,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! ATLID Simulator if (Latlid_column) then - if (verbose) print*,'ATLID' ! Check to see which outputs are requested. If not requested, use a local dummy array if (.not. associated(cospOUT%atlid_cfad_sr)) then allocate(out1D_1(Npoints*SR_BINS*Nlvgrid)) @@ -1963,7 +1377,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) allocate(temp_atlid_cfad_sr(atlidIN%Npoints,SR_BINS,Nlvgrid), & temp_atlid_lidarcld(atlidIN%Npoints,Nlvgrid), & temp_atlid_cldlayer(atlidIN%Npoints,LIDAR_NCAT)) - ! print*,'ATLID-1' call lidar_column(atlidIN%Npoints, atlidIN%Ncolumns, atlidIN%Nlevels, & Nlvgrid, SR_BINS, LIDAR_NTYPE, 'atlid',atlid_beta_tot(:,:,:), & atlid_beta_mol(:,:), cospgridIN%phalf(int(ATLID_MASK_INDICES),2:atlidIN%Nlevels+1), & @@ -1972,17 +1385,14 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ok_lidar_cfad_atlid, LIDAR_NCAT, temp_atlid_cfad_sr(:,:,:), & temp_atlid_lidarcld(:,:), temp_atlid_cldlayer(:,:)) ! Decode back to the cospOUT shapes - ! print*,'ATLID-2' cospOUT%atlid_cfad_sr(ij:ik,:,:) = R_UNDEF cospOUT%atlid_lidarcld(ij:ik,:) = R_UNDEF cospOUT%atlid_cldlayer(ij:ik,:) = R_UNDEF if (associated(cospOUT%atlid_cfad_sr)) cospOUT%atlid_cfad_sr(ij+int(ATLID_MASK_INDICES)-1,:,:) = temp_atlid_cfad_sr(:,:,:) if (associated(cospOUT%atlid_lidarcld)) cospOUT%atlid_lidarcld(ij+int(ATLID_MASK_INDICES)-1,:) = temp_atlid_lidarcld(:,:) if (associated(cospOUT%atlid_cldlayer)) cospOUT%atlid_cldlayer(ij+int(ATLID_MASK_INDICES)-1,:) = temp_atlid_cldlayer(:,:) - ! print*,'ATLID-3' - deallocate(ATLID_SWATH_MASK,ATLID_MASK_INDICES,temp_atlid_cfad_sr,temp_atlid_lidarcld,temp_atlid_cldlayer) + deallocate(temp_atlid_cfad_sr,temp_atlid_lidarcld,temp_atlid_cldlayer) else - deallocate(ATLID_SWATH_MASK,ATLID_MASK_INDICES) cospOUT%atlid_cfad_sr(ij:ik,:,:) = R_UNDEF cospOUT%atlid_lidarcld(ij:ik,:) = R_UNDEF cospOUT%atlid_cldlayer(ij:ik,:) = R_UNDEF @@ -1997,8 +1407,9 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) endif if (associated(cospOUT%atlid_srbval)) cospOUT%atlid_srbval = atlid_histBsct - ! Free up memory (if necessary) - if (allocated(out1D_1)) then + ! Free up memory (if necessary) + if (allocated(ATLID_MASK_INDICES)) deallocate(ATLID_MASK_INDICES) + if (allocated(out1D_1)) then deallocate(out1D_1) nullify(cospOUT%atlid_cfad_sr) endif @@ -2016,19 +1427,15 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! PARASOL if (Lparasol_column) then if (cospIN % cospswathsIN(5) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays - if (verbose) print*,'PARASOL' if (parasolIN%Npoints .gt. 0) then allocate(temp_parasolGrid_refl(parasolIN%Npoints,PARASOL_NREFL)) - ! print*,'PARASOL-1' call parasol_column(parasolIN%Npoints,PARASOL_NREFL,parasolIN%Ncolumns, & cospgridIN%land(int(PARASOL_MASK_INDICES)),parasolPix_refl(:,:,:), & temp_parasolGrid_refl(:,:)) ! Decode back to the cospOUT shapes - ! print*,'PARASOL-2' - ! print*,'temp_parasolGrid_refl: ',temp_parasolGrid_refl cospOUT%parasolGrid_refl(ij:ik,:) = R_UNDEF if (associated(cospOUT%parasolGrid_refl)) cospOUT%parasolGrid_refl(ij+int(PARASOL_MASK_INDICES)-1,:) = temp_parasolGrid_refl(:,:) - deallocate(PARASOL_SWATH_MASK,temp_parasolGrid_refl) + deallocate(temp_parasolGrid_refl) else cospOUT%parasolGrid_refl(ij:ik,:) = R_UNDEF endif @@ -2039,7 +1446,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! print*,'cospOUT%parasolGrid_refl: ',cospOUT%parasolGrid_refl ! Values not zeroed here. endif if (allocated(parasolPix_refl)) deallocate(parasolPix_refl) - if (allocated(PARASOL_SWATH_MASK)) deallocate(PARASOL_SWATH_MASK) if (allocated(PARASOL_MASK_INDICES)) deallocate(PARASOL_MASK_INDICES) endif @@ -2062,19 +1468,16 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Call simulator if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays - if (verbose) print*,'CLOUDSAT' if (cloudsatIN%Npoints .gt. 0) then allocate(temp_cloudsat_cfad_ze(cloudsatIN%Npoints,cloudsat_DBZE_BINS,Nlvgrid), & temp_cloudsat_precip_cover(cloudsatIN%Npoints,cloudsat_DBZE_BINS), & temp_cloudsat_pia(cloudsatIN%Npoints)) - ! print*,'CLOUDSAT-1' call quickbeam_column(cloudsatIN%Npoints, cloudsatIN%Ncolumns, cloudsatIN%Nlevels, & Nlvgrid, cloudsat_DBZE_BINS, 'cloudsat', cloudsatDBZe, cloudsatZe_non, & cospgridIN%land(int(CSCAL_MASK_INDICES)), cospgridIN%surfelev(int(CSCAL_MASK_INDICES)), & cospgridIN%at(int(CSCAL_MASK_INDICES),cospIN%Nlevels), cospIN%fracPrecipIce(int(CSCAL_MASK_INDICES),:), & cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES),:), cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES),:), & temp_cloudsat_cfad_ze(:,:,:), temp_cloudsat_precip_cover(:,:), temp_cloudsat_pia(:)) - ! print*,'CLOUDSAT-2' ! Decode back to the cospOUT shapes cospOUT%cloudsat_cfad_ze(ij:ik,:,:) = R_UNDEF cospOUT%cloudsat_precip_cover(ij:ik,:) = R_UNDEF @@ -2084,7 +1487,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (associated(cospOUT%cloudsat_pia)) cospOUT%cloudsat_pia(ij+int(CSCAL_MASK_INDICES)-1) = temp_cloudsat_pia(:) deallocate(temp_cloudsat_cfad_ze,temp_cloudsat_precip_cover,temp_cloudsat_pia) if (allocated(CSCAL_SWATH_MASK)) deallocate(CSCAL_SWATH_MASK) - ! print*,'CLOUDSAT-4' else cospOUT%cloudsat_cfad_ze(ij:ik,:,:) = R_UNDEF cospOUT%cloudsat_precip_cover(ij:ik,:) = R_UNDEF @@ -2115,9 +1517,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! MODIS if (Lmodis_column) then - if (verbose) print*,'MODIS' if (modisIN%nSunlit > 0) then - ! print*,'MODIS-1' ! Allocate space for local variables allocate(modisCftotal(modisIN%nSunlit), modisCfLiquid(modisIN%nSunlit), & modisCfIce(modisIN%nSunlit),modisCfHigh(modisIN%nSunlit), & @@ -2135,7 +1535,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) modisJointHistogram(modisIN%nSunlit,numMODISTauBins,numMODISPresBins),& modisJointHistogramIce(modisIN%nSunlit,numModisTauBins,numMODISReffIceBins),& modisJointHistogramLiq(modisIN%nSunlit,numModisTauBins,numMODISReffLiqBins)) - ! print*,'MODIS-2' ! Call simulator call modis_column(modisIN%nSunlit, modisIN%Ncolumns,modisRetrievedPhase, & modisRetrievedCloudTopPressure,modisRetrievedTau, & @@ -2147,7 +1546,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) modisMeanCloudTopPressure, modisMeanLiquidWaterPath, & modisMeanIceWaterPath, modisJointHistogram, & modisJointHistogramIce,modisJointHistogramLiq) - ! print*,'MODIS-3' ! Store data (if requested) if (associated(cospOUT%modis_Cloud_Fraction_Total_Mean)) then cospOUT%modis_Cloud_Fraction_Total_Mean(ij+int(modisIN%sunlit(:))-1) = & @@ -2234,7 +1632,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospOUT%modis_Optical_Thickness_vs_ReffLiq(ij+int(modisIN%sunlit(:))-1, 1:numMODISTauBins,:) = & modisJointHistogramLiq(:,:,:) endif - ! print*,'MODIS-4' if(modisIN%nSunlit < modisIN%Npoints) then ! Where it's night and we haven't done the retrievals the values are undefined @@ -2280,7 +1677,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospOUT%modis_Optical_Thickness_vs_ReffLiq(ij+int(modisIN%notSunlit(:))-1, :, :) = R_UNDEF end if else - ! print*,'MODIS-5' ! It's nightime everywhere - everything is undefined if (associated(cospOUT%modis_Cloud_Fraction_Total_Mean)) & cospOUT%modis_Cloud_Fraction_Total_Mean(ij:ik) = R_UNDEF @@ -2361,7 +1757,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) do i=1,cospIN%Ninst_rttov ! Allocate memory for the outputs - I won't need all of these in every situation. ! Only allocate clear-sky memory when PC-RTTOV is run. - allocate(rttov_Ichannel(cospIN % cfg_rttov(i) % nchan_out)) ! Channel indices if (cospIN % cfg_rttov(i) % Lrttov_pc) then allocate(rttov_bt_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp allocate(rttov_rad_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky radiance @@ -2369,12 +1764,10 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) rttov_bt_clear(:,:) = R_UNDEF rttov_rad_clear(:,:) = R_UNDEF ! Run simulator - call cpu_time(driver_time(3)) call cosp_rttov_simulate(rttovIN,cospIN%cfg_rttov(i), & ! Inputs cosp_simulator(nError+1), & ! Error message holder bt_clear=rttov_bt_clear, & ! Clear-sky BT rad_clear=rttov_rad_clear) ! Clear-sky radiance - call cpu_time(driver_time(4)) else allocate(rttov_bt_total(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! all-sky brightness temp allocate(rttov_bt_clear(rttovIN%Npoints,cospIN % cfg_rttov(i) % nchan_out)) ! clear-sky brightness temp @@ -2392,7 +1785,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) rttov_refl_total(:,:) = R_UNDEF rttov_refl_clear(:,:) = R_UNDEF ! Run simulator - call cpu_time(driver_time(3)) call cosp_rttov_simulate(rttovIN,cospIN%cfg_rttov(i), & ! Inputs cosp_simulator(nError+1), & ! Error message holder bt_total=rttov_bt_total, & ! Brightness Temp Outputs @@ -2403,7 +1795,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) refl_total=rttov_refl_total, & ! Reflectance Outputs refl_clear=rttov_refl_clear, & debug=verbose) - call cpu_time(driver_time(4)) endif ! Write to cospOUT @@ -2432,7 +1823,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) endif ! Free up memory from output (if necessary) - if (allocated(rttov_Ichannel)) deallocate(rttov_Ichannel) if (allocated(rttov_bt_total)) deallocate(rttov_bt_total) if (allocated(rttov_bt_clear)) deallocate(rttov_bt_clear) if (allocated(rttov_rad_total)) deallocate(rttov_rad_total) @@ -2451,7 +1841,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! CLOUDSAT/CALIPSO products if (Lradar_lidar_tcc .or. Llidar_only_freq_cloud .or. Lcloudsat_tcc .or. Lcloudsat_tcc2) then - if (verbose) print*,'CLOUDSAT/CALIPSO joint' if (calipsoIN%Npoints .gt. 0) then if (use_vgrid) then allocate(lidar_only_freq_cloud(cloudsatIN%Npoints,Nlvgrid), & @@ -2464,7 +1853,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Regrid in the vertical (*NOTE* This routine requires SFC-2-TOA ordering, so flip ! inputs and outputs to maintain TOA-2-SFC ordering convention in COSP2.) - ! print*,'CLOUDSAT/CALIPSO joint-1' ! Use CLOUDSAT masking array here (it is the same as calipso) if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays betamol_in(:,1,:) = calipso_beta_mol(:,cloudsatIN%Nlevels:1:-1) @@ -2483,7 +1871,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospgridIN%hgt_matrix_half(int(CSCAL_MASK_INDICES(:)),cloudsatIN%Nlevels:1:-1), & cloudsatDBZe(:,:,cloudsatIN%Nlevels:1:-1),Nlvgrid,vgrid_zl(Nlvgrid:1:-1), & vgrid_zu(Nlvgrid:1:-1),Ze_totI(:,:,Nlvgrid:1:-1),log_units=.true.) - ! print*,'CLOUDSAT/CALIPSO joint-2' else betamol_in(:,1,:) = calipso_beta_mol(:,cloudsatIN%Nlevels:1:-1) call cosp_change_vertical_grid(cloudsatIN%Npoints,1,cloudsatIN%Nlevels, & @@ -2503,7 +1890,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospgridIN%hgt_matrix_half(:,cloudsatIN%Nlevels:1:-1), & cloudsatDBZe(:,:,cloudsatIN%Nlevels:1:-1),Nlvgrid,vgrid_zl(Nlvgrid:1:-1), & vgrid_zu(Nlvgrid:1:-1),Ze_totI(:,:,Nlvgrid:1:-1),log_units=.true.) - ! print*,'CLOUDSAT/CALIPSO joint-2b' end if call cosp_lidar_only_cloud(cloudsatIN%Npoints, cloudsatIN%Ncolumns, Nlvgrid, & pnormI, betamolI, Ze_totI, lidar_only_freq_cloud, radar_lidar_tcc, & @@ -2513,13 +1899,11 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) allocate(lidar_only_freq_cloud(cloudsatIN%Npoints,cloudsatIN%Nlevels), & radar_lidar_tcc(cloudsatIN%Npoints), cloudsat_tcc(cloudsatIN%Npoints), & cloudsat_tcc2(cloudsatIN%Npoints)) - ! print*,'CLOUDSAT/CALIPSO joint-3' call cosp_lidar_only_cloud(cloudsatIN%Npoints,cloudsatIN%Ncolumns, & cospIN%Nlevels,calipso_beta_tot(:,:,cloudsatIN%Nlevels:1:-1), & calipso_beta_mol(:,cloudsatIN%Nlevels:1:-1), & cloudsatDBZe(:,:,cloudsatIN%Nlevels:1:-1),lidar_only_freq_cloud, & radar_lidar_tcc, cloudsat_tcc, cloudsat_tcc2) - ! print*,'CLOUDSAT/CALIPSO joint-4' endif endif @@ -2559,14 +1943,12 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! CloudSat/MODIS joint products (CFODDs and Occurrence Frequency of Warm Clouds) if (Lcloudsat_modis_wr) then - if (verbose) print*,'CLOUDSAT/MODIS joint' if (cloudsatIN%Npoints .gt. 0) then allocate( cfodd_ntotal(cloudsatIN%Npoints, CFODD_NDBZE, CFODD_NICOD, CFODD_NCLASS) ) allocate( wr_occfreq_ntotal(cloudsatIN%Npoints, WR_NREGIME) ) if ( use_vgrid ) then !! interporation for fixed vertical grid: - ! print*,'CLOUDSAT/MODIS joint-1' allocate( zlev(cloudsatIN%Npoints,Nlvgrid), & t_in(cloudsatIN%Npoints,1,cloudsatIN%Nlevels), & tempI(cloudsatIN%Npoints,1,Nlvgrid), & @@ -2575,7 +1957,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) do k = 1, Nlvgrid zlev(:,k) = vgrid_zu(k) enddo - ! print*,'CLOUDSAT/MODIS joint-2' ! Use CLOUDSAT masking array here (it is the same as calipso) if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays t_in(:,1,:) = cospgridIN%at(int(CSCAL_MASK_INDICES(:)),:) @@ -2600,7 +1981,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospIN%frac_out(int(CSCAL_MASK_INDICES(:)),:,cloudsatIN%Nlevels:1:-1), Nlvgrid, & vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), & frac_outI(:,:,Nlvgrid:1:-1) ) - ! print*,'CLOUDSAT/MODIS joint-3' call cosp_diag_warmrain( & cloudsatIN%Npoints, cloudsatIN%Ncolumns, Nlvgrid, & !! in tempI, zlev, & !! in @@ -2638,7 +2018,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospIN%frac_out(:,:,cloudsatIN%Nlevels:1:-1), Nlvgrid, & vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), & frac_outI(:,:,Nlvgrid:1:-1) ) - ! print*,'CLOUDSAT/MODIS joint-3b' call cosp_diag_warmrain( & cloudsatIN%Npoints, cloudsatIN%Ncolumns, Nlvgrid, & !! in tempI, zlev, & !! in @@ -2654,11 +2033,9 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) Ze_totI, & !! in cfodd_ntotal, wr_occfreq_ntotal ) !! inout endif - ! print*,'CLOUDSAT/MODIS joint-4' deallocate( zlev, t_in, tempI, frac_outI, Ze_totI ) else ! do not use vgrid interporation ---------------------------------------! !! original model grid - ! print*,'CLOUDSAT/MODIS joint-5' if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays call cosp_diag_warmrain( & cloudsatIN%Npoints, cloudsatIN%Ncolumns, cospIN%Nlevels, & !! in @@ -2691,7 +2068,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cloudsatDBZe, & !! in cfodd_ntotal, wr_occfreq_ntotal ) !! inout endif - ! print*,'CLOUDSAT/MODIS joint-6' endif !! use_vgrid or not ! Store, when necessary @@ -2734,22 +2110,25 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! 7) Cleanup !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if (Lisccp_subcolumn .or. Lmodis_subcolumn) then - nullify(isccpIN%Npoints,isccpIN%Ncolumns,isccpIN%Nlevels,isccpIN%emsfc_lw, & + nullify(isccpIN%Ncolumns,isccpIN%Nlevels,isccpIN%emsfc_lw, & isccpIN%skt,isccpIN%qv,isccpIN%at,isccpIN%frac_out,isccpIN%dtau, & isccpIN%dem,isccpIN%phalf,isccpIN%sunlit,isccpIN%pfull) + call COSP_ISCCP_MASK_CLEAN() endif if (Lmisr_subcolumn) then - nullify(misrIN%Npoints,misrIN%Ncolumns,misrIN%Nlevels,misrIN%dtau,misrIN%sunlit, & + nullify(misrIN%Ncolumns,misrIN%Nlevels,misrIN%dtau,misrIN%sunlit, & misrIN%zfull,misrIN%at) + call COSP_MISR_MASK_CLEAN() endif if (Lcalipso_subcolumn) then - nullify(calipsoIN%Npoints,calipsoIN%Ncolumns,calipsoIN%Nlevels,calipsoIN%beta_mol,& + nullify(calipsoIN%Ncolumns,calipsoIN%Nlevels,calipsoIN%beta_mol,& calipsoIN%betatot,calipsoIN%betatot_liq,calipsoIN%betatot_ice, & calipsoIN%tau_mol,calipsoIN%tautot,calipsoIN%tautot_liq,calipsoIN%tautot_ice) if (allocated(CSCAL_MASK_INDICES)) deallocate(CSCAL_MASK_INDICES) - if (allocated(CSCAL_SWATH_MASK)) deallocate(CSCAL_SWATH_MASK) + if (allocated(CSCAL_SWATH_MASK)) deallocate(CSCAL_SWATH_MASK) + call COSP_CALIPSO_MASK_CLEAN() endif if (LgrLidar532_subcolumn) then @@ -2758,19 +2137,23 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) endif if (Latlid_subcolumn) then - nullify(atlidIN%Npoints,atlidIN%Ncolumns,atlidIN%Nlevels,atlidIN%beta_mol_atlid, & + nullify(atlidIN%Ncolumns,atlidIN%Nlevels,atlidIN%beta_mol_atlid, & atlidIN%betatot_atlid,atlidIN%tau_mol_atlid,atlidIN%tautot_atlid) + call COSP_ATLID_MASK_CLEAN() endif if (Lparasol_subcolumn) then - nullify(parasolIN%Npoints,parasolIN%Nlevels,parasolIN%Ncolumns,parasolIN%Nrefl, & - parasolIN%tautot_S_liq,parasolIN%tautot_S_ice) + nullify(parasolIN%Nlevels,parasolIN%Ncolumns,parasolIN%Nrefl, & + parasolIN%tautot_S_liq,parasolIN%tautot_S_ice) + call COSP_PARASOL_MASK_CLEAN() endif - if (Lcloudsat_subcolumn) then - nullify(cloudsatIN%Npoints,cloudsatIN%Nlevels,cloudsatIN%Ncolumns,cloudsatIN%rcfg,& + nullify(cloudsatIN%Nlevels,cloudsatIN%Ncolumns,cloudsatIN%rcfg,& cloudsatIN%kr_vol,cloudsatIN%g_vol,cloudsatIN%z_vol,cloudsatIN%hgt_matrix) + call COSP_CLOUDSAT_MASK_CLEAN() + if (allocated(CSCAL_MASK_INDICES)) deallocate(CSCAL_MASK_INDICES) + if (allocated(CSCAL_SWATH_MASK)) deallocate(CSCAL_SWATH_MASK) endif if (Lmodis_subcolumn) then @@ -2780,7 +2163,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (allocated(modisIN%notSunlit)) deallocate(modisIN%notSunlit) if (allocated(modisIN%pres)) deallocate(modisIN%pres) if (allocated(MODIS_CSCAL_MASK_INDICES)) deallocate(MODIS_CSCAL_MASK_INDICES) - if (allocated(MODIS_CSCAL_SWATH_MASK)) deallocate(MODIS_CSCAL_SWATH_MASK) endif if (Lrttov_column) then @@ -2839,7 +2221,6 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La ! vertical grid character(len=64),intent(in) :: & cloudsat_micro_scheme ! Microphysical scheme used by CLOUDSAT - real(wp),dimension(10) :: driver_time type(character(len=256)), dimension(rttov_Ninstruments) :: & rttov_instrument_namelists ! Array of paths to RTTOV instrument namelists @@ -2900,8 +2281,6 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La if (Lmisr) call cosp_misr_init() if (Lrttov) then - call cpu_time(driver_time(1)) - if (verbose) print*,'rttov_instrument_namelists: ',rttov_instrument_namelists if (present(unitn)) then call cosp_rttov_init(Lrttov,Nlevels,rttov_Ninstruments, & rttov_instrument_namelists, & @@ -2912,8 +2291,6 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La rttov_instrument_namelists, & rttov_configs,debug=verbose) end if - call cpu_time(driver_time(2)) - if (verbose) print*,'Time to run cosp_rttov_init: ',driver_time(2)-driver_time(1) endif if (Lcloudsat) call cosp_cloudsat_init(cloudsat_radar_freq,cloudsat_k2, & @@ -2927,115 +2304,6 @@ SUBROUTINE COSP_INIT(Lisccp, Lmodis, Lmisr, Lcloudsat, Lcalipso, LgrLidar532, La linitialization = .FALSE. END SUBROUTINE COSP_INIT - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE cosp_cleanUp - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine cosp_cleanUp() - deallocate(vgrid_zl,vgrid_zu,vgrid_z,dz) - end subroutine cosp_cleanUp - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE compute_orbitmasks - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine compute_orbitmasks(Npoints,Nlocaltimes,localtimes,localtime_widths, & - lat,lon,month,day,hour,minute,swath_mask_out,Nswathed_out) - - ! Inputs - integer,intent(in) :: & - Npoints, & - Nlocaltimes - - real(wp),dimension(Nlocaltimes),intent(in) :: & - localtimes, & - localtime_widths - - real(wp),dimension(Npoints),intent(in) :: & - lat, & - lon, & - month, & - day, & - hour, & - minute - - ! Output - logical,dimension(Npoints),intent(out) :: & - swath_mask_out ! Mask of reals over all gridcells - integer,intent(out) :: & - Nswathed_out - - ! Local variables - integer :: i ! iterator - - real(wp),parameter :: & - pi = 4.D0*DATAN(1.D0), & ! yum - radius = 6371.0 ! Earth's radius in km (mean volumetric) - - real(wp),dimension(Npoints,Nlocaltimes) :: & - sat_lon, & ! Central longitude of the instrument. - dlon, & ! distance to satellite longitude in degrees - dx ! distance to satellite longitude in km? - - logical,dimension(Npoints,Nlocaltimes) :: & - swath_mask_all ! Mask of logicals over all local times, gridcells - - integer, dimension(Npoints) :: & - rttov_DOY ! Array of day of year values - real(wp), dimension(Npoints) :: & - localtime_offsets ! Offset values to avoid striping with hourly RT calls. [hours] - ! Compute the day of the year and determine the localtime offset - do i=1,Npoints - call get_DOY(int(month(i)), int(day(i)), rttov_DOY(i)) - end do - localtime_offsets = (mod(rttov_DOY(:), 5) - 2) / 5.0 ! Need to cast to real - - ! Iterate over local times - swath_mask_all(:,:) = .false. - do i=1,Nlocaltimes - ! Calculate the central longitude for each gridcell and orbit - sat_lon(:,i) = 15.0 * (localtimes(i) + localtime_offsets - (hour + minute / 60)) - ! Calculate distance (in degrees) from each grid cell to the satellite central long - dlon(:,i) = mod((lon - sat_lon(:,i) + 180.0), 360.0) - 180.0 - ! calculate distance to satellite in km. Remember to convert to radians for cos/sine calls - dx(:,i) = dlon(:,i) * (pi/180.0) * COS(lat * pi / 180) * radius - ! Determine if a gridcell falls in the swath width - where (abs(dx(:,i))<(localtime_widths(i)*0.5)) - swath_mask_all(:,i) = .true. - end where - end do - - ! Mask is true where values should be calculated - swath_mask_out = ANY( swath_mask_all(:,:),2) ! Compute mask by collapsing the localtimes dimension - Nswathed_out = count(swath_mask_out) ! Number of gridcells that should be calculated. - - ! Mask is true where values should be masked to R_UNDEF - ! swath_mask_out = ALL( swath_mask_all(:,:) .eq. .false.,2) ! Compute mask by collapsing the localtimes dimension ! ANY(swath_mask_all,dim=1) - - end subroutine compute_orbitmasks - - subroutine get_DOY(month, day, DOY) - - integer,intent(in) :: & - month, & - day - integer,intent(out) :: & - DOY - - ! This subroutine does not handle leap years because it is not relevant to the purpose. - ! Simple look-up table for DOY. - if (month .eq. 1) DOY = day - if (month .eq. 2) DOY = 31 + day - if (month .eq. 3) DOY = 59 + day - if (month .eq. 4) DOY = 90 + day - if (month .eq. 5) DOY = 120 + day - if (month .eq. 6) DOY = 151 + day - if (month .eq. 7) DOY = 181 + day - if (month .eq. 8) DOY = 212 + day - if (month .eq. 9) DOY = 243 + day - if (month .eq. 10) DOY = 273 + day - if (month .eq. 11) DOY = 304 + day - if (month .eq. 12) DOY = 334 + day - - end subroutine get_DOY !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! SUBROUTINE cosp_errorCheck @@ -3098,47 +2366,47 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, alloc_status = .true. if (.not. allocated(cospgridIN%skt)) then nError=nError+1 - errorMessage(nError) = 'ERROR: COSP input variable (ISSCP simulator): cospgridIN%skt has not been allocated' + errorMessage(nError) = 'ERROR: COSP input variable (ISCCP simulator): cospgridIN%skt has not been allocated' alloc_status = .false. endif if (.not. allocated(cospgridIN%qv)) then nError=nError+1 - errorMessage(nError) = 'ERROR: COSP input variable (ISSCP simulator): cospgridIN%qv has not been allocated' + errorMessage(nError) = 'ERROR: COSP input variable (ISCCP simulator): cospgridIN%qv has not been allocated' alloc_status = .false. endif if (.not. allocated(cospgridIN%at)) then nError=nError+1 - errorMessage(nError) = 'ERROR: COSP input variable (ISSCP simulator): cospgridIN%at has not been allocated' + errorMessage(nError) = 'ERROR: COSP input variable (ISCCP simulator): cospgridIN%at has not been allocated' alloc_status = .false. endif if (.not. allocated(cospIN%frac_out)) then nError=nError+1 - errorMessage(nError) = 'ERROR: COSP input variable (ISSCP simulator): cospIN%frac_out has not been allocated' + errorMessage(nError) = 'ERROR: COSP input variable (ISCCP simulator): cospIN%frac_out has not been allocated' alloc_status = .false. endif if (.not. allocated(cospIN%tau_067)) then nError=nError+1 - errorMessage(nError) = 'ERROR: COSP input variable (ISSCP simulator): cospIN%tau_067 has not been allocated' + errorMessage(nError) = 'ERROR: COSP input variable (ISCCP simulator): cospIN%tau_067 has not been allocated' alloc_status = .false. endif if (.not. allocated(cospIN%emiss_11)) then nError=nError+1 - errorMessage(nError) = 'ERROR: COSP input variable (ISSCP simulator): cospIN%emiss_11 has not been allocated' + errorMessage(nError) = 'ERROR: COSP input variable (ISCCP simulator): cospIN%emiss_11 has not been allocated' alloc_status = .false. endif if (.not. allocated(cospgridIN%phalf)) then nError=nError+1 - errorMessage(nError) = 'ERROR: COSP input variable (ISSCP simulator): cospgridIN%phalf has not been allocated' + errorMessage(nError) = 'ERROR: COSP input variable (ISCCP simulator): cospgridIN%phalf has not been allocated' alloc_status = .false. endif if (.not. allocated(cospgridIN%sunlit)) then nError=nError+1 - errorMessage(nError) = 'ERROR: COSP input variable (ISSCP simulator): cospgridIN%sunlit has not been allocated' + errorMessage(nError) = 'ERROR: COSP input variable (ISCCP simulator): cospgridIN%sunlit has not been allocated' alloc_status = .false. endif if (.not. allocated(cospgridIN%pfull)) then nError=nError+1 - errorMessage(nError) = 'ERROR: COSP input variable (ISSCP simulator): cospgridIN%pfull has not been allocated' + errorMessage(nError) = 'ERROR: COSP input variable (ISCCP simulator): cospgridIN%pfull has not been allocated' alloc_status = .false. endif if (.not. alloc_status) then @@ -3778,7 +3046,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, if (.not. alloc_status) then Lrttov_column = .false. if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -3889,7 +3157,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lcloudsat_tcc2 = .false. Lcloudsat_modis_wr = .false. if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -3944,7 +3212,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lisccp_column = .false. Lrttov_column = .false. if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -3982,7 +3250,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Latlid_column = .false. LgrLidar532_column = .false. if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -4072,7 +3340,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lisccp_column = .false. Lrttov_column = .false. if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -4162,7 +3430,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, LgrLidar532_column = .false. Lcloudsat_modis_wr = .false. if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -4210,7 +3478,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lcalipso_column = .false. Lparasol_column = .false. if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -4246,7 +3514,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, Lisccp_column = .false. Lrttov_column = .false. if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -4278,7 +3546,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%co2 contains values out of range' Lrttov_column = .false. if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -4297,7 +3565,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%ch4 contains values out of range' Lrttov_column = .false. if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -4316,7 +3584,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%n2o contains values out of range' Lrttov_column = .false. if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -4335,7 +3603,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%co contains values out of range' Lrttov_column = .false. if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -4354,7 +3622,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%o3 contains values out of range' Lrttov_column = .false. if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -4373,7 +3641,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, ! errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%emis_in contains values out of range' ! Lrttov_column = .false. ! if (allocated(cospOUT%rttov_outputs)) then -! do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument +! do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument ! if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 ! if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF ! if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -4392,7 +3660,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, ! errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%refl_in contains values out of range' ! Lrttov_column = .false. ! if (allocated(cospOUT%rttov_outputs)) then -! do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument +! do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument ! if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 ! if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF ! if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -4411,7 +3679,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, errorMessage(nError) = 'ERROR: COSP input variable: cospgridIN%rttov_sfcmask contains values out of range' Lrttov_column = .false. if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -4430,7 +3698,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, errorMessage(nError) = 'ERROR: COSP input variable: cospIN%u_sfc contains values out of range' Lrttov_column = .false. if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -4449,7 +3717,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, errorMessage(nError) = 'ERROR: COSP input variable: cospIN%v_sfc contains values out of range' Lrttov_column = .false. if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -4468,7 +3736,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, errorMessage(nError) = 'ERROR: COSP input variable: cospIN%lat contains values out of range' Lrttov_column = .false. if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -4487,7 +3755,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, errorMessage(nError) = 'ERROR: COSP input variable: cospIN%lon contains values out of range' Lrttov_column = .false. if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -4506,7 +3774,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, errorMessage(nError) = 'ERROR: COSP input variable: cospIN%tca contains values out of range' Lrttov_column = .false. if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -4525,7 +3793,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, errorMessage(nError) = 'ERROR: COSP input variable: cospIN%rttov_time(1) contains values out of range' Lrttov_column = .false. if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -4544,7 +3812,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, errorMessage(nError) = 'ERROR: COSP input variable: cospIN%rttov_time(2) contains values out of range' Lrttov_column = .false. if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -4563,7 +3831,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, errorMessage(nError) = 'ERROR: COSP input variable: cospIN%rttov_time(3) contains values out of range' Lrttov_column = .false. if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -4582,7 +3850,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, errorMessage(nError) = 'ERROR: COSP input variable: cospIN%rttov_date(1) contains values out of range' Lrttov_column = .false. if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -4601,7 +3869,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, errorMessage(nError) = 'ERROR: COSP input variable: cospIN%rttov_date(2) contains values out of range' Lrttov_column = .false. if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF @@ -4620,7 +3888,7 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, errorMessage(nError) = 'ERROR: COSP input variable: cospIN%rttov_date(3) contains values out of range' Lrttov_column = .false. if (allocated(cospOUT%rttov_outputs)) then - do i=1,cospOUT % N_rttov_instruments ! Iterate over each instrument + do i=1,cospOUT % Ninst_rttov ! Iterate over each instrument if (associated(cospOUT%rttov_outputs(i)%channel_indices)) cospOUT%rttov_outputs(i)%channel_indices(:) = 0 if (associated(cospOUT%rttov_outputs(i)%bt_total)) cospOUT%rttov_outputs(i)%bt_total(:,:) = R_UNDEF if (associated(cospOUT%rttov_outputs(i)%bt_clear)) cospOUT%rttov_outputs(i)%bt_clear(:,:) = R_UNDEF diff --git a/src/cosp_constants.F90 b/src/cosp_constants.F90 index 31c2b46227..b1d73923dd 100755 --- a/src/cosp_constants.F90 +++ b/src/cosp_constants.F90 @@ -27,8 +27,8 @@ ! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! ! History: -! May 2015- D. Swales - Original version -! +! May 2015 - D. Swales - Original version +! June 2025 - J.K. Shaw - Added earth radius for COSP-RTTOV integration and swathing ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MODULE cosp_math_constants USE cosp_kinds, only: wp @@ -70,4 +70,8 @@ MODULE cosp_phys_constants cpv = 1869.46_wp, & ! Specific heat at constant pressure for water vapor [J/K/Kg] km = 1.38e-23_wp ! Boltzmann constant [J/K] + ! RTTOV constants + REAL(wp), PARAMETER :: & + radius_earth = 6371.0 ! Earth's radius in km (mean volumetric) + END MODULE cosp_phys_constants diff --git a/src/cosp_rttov_util.F90 b/src/cosp_rttov_util.F90 new file mode 100644 index 0000000000..9d3c0972b6 --- /dev/null +++ b/src/cosp_rttov_util.F90 @@ -0,0 +1,130 @@ +! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +! Copyright (c) 2015, Regents of the University of Colorado +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are +! permitted provided that the following conditions are met: +! +! 1. Redistributions of source code must retain the above copyright notice, this list of +! conditions and the following disclaimer. +! +! 2. Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other +! materials provided with the distribution. +! +! 3. Neither the name of the copyright holder nor the names of its contributors may be +! used to endorse or promote products derived from this software without specific prior +! written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +! MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +! THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +! OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +! +! History: +! Jun 2025 - J.K. Shaw - Initial version +! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +MODULE MOD_COSP_RTTOV_UTIL + USE COSP_KINDS, ONLY: wp + + ! jpim, jprb and jplm are the RTTOV integer, real and logical KINDs + USE parkind1, ONLY : jpim, jprb, jplm + + ! rttov_types contains definitions of all RTTOV data types + USE rttov_types, ONLY : & + rttov_options, & + rttov_options_scatt, & + rttov_coefs, & + rttov_pccomp + + IMPLICIT NONE + + ! RTTOV variables/structures. + !==================== + + ! DDT for each instrument being simulated. Values to be assigned during the cosp_rttov_init subroutine + type rttov_cfg + logical(KIND=jplm) :: & + Lrttov_bt, & + Lrttov_rad, & + Lrttov_refl, & + Lrttov_cld, & + Lrttov_aer, & + Lrttov_pc, & + Lrttov_solar, & + Lrttov_mwscatt, & + user_tracegas_input + character(len=256) :: & + rttov_srcDir, & + rttov_coefDir, & + OD_coef_filepath, & + aer_coef_filepath, & + cld_coef_filepath, & + PC_coef_filepath + integer(KIND=jpim) :: & + nchanprof, & + rttov_direct_nthreads, & + nchan_out, & + nchannels_rec, & + rttov_Nlocaltime, & + gas_units, & + clw_scheme, & + ice_scheme, & + icede_param, & + rttov_extendatmos, & + nprof + real(wp) :: & + CO2_mr, & + CH4_mr, & + CO_mr, & + N2O_mr, & + SO2_mr, & + ZenAng + integer(kind=jpim), allocatable :: & + iChannel(:), & ! Requested channel indices + iChannel_out(:) ! Passing out the channel indices (actual output channels) + real(kind=jprb), allocatable :: & + emisChannel(:), & ! RTTOV channel emissivity + reflChannel(:), & ! RTTOV channel reflectivity + wavenumChannel(:), & ! RTTOV channel wavenumber + rttov_localtime(:), & + rttov_localtime_width(:) + type(rttov_options) :: & + opts ! RTTOV options structure + type(rttov_options_scatt) :: & + opts_scatt + type(rttov_coefs) :: & + coefs ! RTTOV coefficients structure + type(rttov_pccomp) :: & + pccomp + logical(KIND=jplm), allocatable :: & + swath_mask(:) + end type rttov_cfg + + type rttov_output + integer :: & + nchan_out + integer,pointer :: & + channel_indices(:) => null() + real(wp),pointer :: & + bt_total(:,:) => null(), & + bt_clear(:,:) => null(), & + rad_total(:,:) => null(), & + rad_clear(:,:) => null(), & + rad_cloudy(:,:) => null(), & + refl_total(:,:) => null(), & + refl_clear(:,:) => null(), & + bt_total_pc(:,:) => null(), & + rad_total_pc(:,:) => null() + end type rttov_output + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! END MODULE + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +END MODULE MOD_COSP_RTTOV_UTIL \ No newline at end of file diff --git a/src/cosp_rttov_utilSTUB.F90 b/src/cosp_rttov_utilSTUB.F90 new file mode 100644 index 0000000000..8fee7b6ddd --- /dev/null +++ b/src/cosp_rttov_utilSTUB.F90 @@ -0,0 +1,99 @@ +! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +! Copyright (c) 2015, Regents of the University of Colorado +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are +! permitted provided that the following conditions are met: +! +! 1. Redistributions of source code must retain the above copyright notice, this list of +! conditions and the following disclaimer. +! +! 2. Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other +! materials provided with the distribution. +! +! 3. Neither the name of the copyright holder nor the names of its contributors may be +! used to endorse or promote products derived from this software without specific prior +! written permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +! MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +! THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +! OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +! +! History: +! Jun 2025 - J.K. Shaw - Initial version +! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +MODULE MOD_COSP_RTTOV_UTIL + USE COSP_KINDS, ONLY: wp + IMPLICIT NONE + + + ! DDT for each instrument being simulated. Values to be assigned during the cosp_rttov_init subroutine + type rttov_cfg + logical :: & + Lrttov_bt, & + Lrttov_rad, & + Lrttov_refl, & + Lrttov_cld, & + Lrttov_aer, & + Lrttov_pc + character(len=256) :: & + rttov_srcDir, & + rttov_coefDir, & + OD_coef_filepath, & + aer_coef_filepath, & + cld_coef_filepath, & + PC_coef_filepath + integer :: & + nchanprof, & + rttov_direct_nthreads, & + nchan_out, & + nchannels_rec, & + rttov_Nlocaltime + real(wp) :: & + CO2_mr, & + CH4_mr, & + CO_mr, & + N2O_mr, & + SO2_mr, & + ZenAng + integer,allocatable :: & + iChannel(:), & ! Requested channel indices + iChannel_out(:) ! Passing out the channel indices (actual output channels) + real(kind=wp),allocatable :: & + emisChannel(:), & ! RTTOV channel emissivity + reflChannel(:), & ! RTTOV channel reflectivity + rttov_localtime(:), & ! RTTOV localtime + rttov_localtime_width(:) + logical, allocatable :: & + swath_mask(:) + end type rttov_cfg + + type rttov_output + integer :: & + nchan_out + integer,pointer :: & + channel_indices(:) + real(wp),pointer :: & + bt_total(:,:), & + bt_clear(:,:), & + rad_total(:,:), & + rad_clear(:,:), & + rad_cloudy(:,:), & + refl_total(:,:), & + refl_clear(:,:), & + bt_total_pc(:,:), & + rad_total_pc(:,:) + end type rttov_output + + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! END MODULE + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +END MODULE MOD_COSP_RTTOV_UTIL \ No newline at end of file diff --git a/src/cosp_stats.F90 b/src/cosp_stats.F90 index def4d9c1b9..b057879ccc 100755 --- a/src/cosp_stats.F90 +++ b/src/cosp_stats.F90 @@ -37,6 +37,7 @@ ! - Added phase 3D/3Dtemperature/Map output variables in diag_lidar ! May 2015 - D. Swales - Modified for cosp2.0 ! Nov 2018 - T. Michibata - Added CloudSat+MODIS Warmrain Diagnostics +! Jun 2025 - J.K. Shaw. - Added COSP-RTTOV integration and swathing ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MODULE MOD_COSP_STATS USE COSP_KINDS, ONLY: wp @@ -52,12 +53,176 @@ MODULE MOD_COSP_STATS CFODD_ICOD_MIN, CFODD_ICOD_MAX, & CFODD_DBZE_WIDTH, CFODD_ICOD_WIDTH, & CFODD_HISTDBZE, CFODD_HISTICOD, & - WR_NREGIME - USE COSP_PHYS_CONSTANTS, ONLY: tmelt - + WR_NREGIME, VGRID_ZU, & + VGRID_ZL, VGRID_Z, & + DZ + USE COSP_PHYS_CONSTANTS, ONLY: tmelt, radius_earth + USE COSP_MATH_CONSTANTS, ONLY: pi + USE MOD_COSP_RTTOV_UTIL, ONLY: rttov_cfg IMPLICIT NONE -CONTAINS + ! ###################################################################################### + ! Quickbeam parameters + integer,parameter :: & + maxhclass = 20, & ! Qucikbeam maximum number of hydrometeor classes. + nRe_types = 550, & ! Quickbeam maximum number or Re size bins allowed in N and Z_scaled look up table. + nd = 85, & ! Qucikbeam number of discrete particles used in construction DSDs. + mt_ntt = 39, & ! Quickbeam number of temperatures in mie LUT. + Re_BIN_LENGTH = 10, & ! Quickbeam minimum Re interval in scale LUTs + Re_MAX_BIN = 250 ! Quickbeam maximum Re interval in scale LUTs + real(wp),parameter :: & + dmin = 0.1, & ! Quickbeam minimum size of discrete particle + dmax = 10000. ! Quickbeam maximum size of discrete particle + + ! ###################################################################################### + ! TYPE cosp_column_inputs + ! ###################################################################################### + type cosp_column_inputs + integer :: & + Npoints, & ! Number of gridpoints. + Ncolumns, & ! Number of columns. + Nlevels ! Number of levels. + + integer,allocatable,dimension(:) :: & + sunlit ! Sunlit flag (0-1) + + real(wp),allocatable,dimension(:,:) :: & + at, & ! Temperature (K) + pfull, & ! Pressure (Pa) + phalf, & ! Pressure at half-levels (Pa) + qv, & ! Specific humidity (kg/kg) + co2, & ! CO2 (kg/kg) + ch4, & ! Methane (kg/kg) + n2o, & ! N2O (kg/kg) + co, & ! CO (kg/kg) + so2, & ! SO2 (kg/kg) + hgt_matrix, & ! Height of atmosphere layer (km) + hgt_matrix_half ! Height of bottom interface of atm layer(km) + ! First level contains the bottom of the top layer. + ! Last level contains the bottom of the surface layer. + + real(wp),allocatable,dimension(:) :: & + land, & ! Land/Sea mask (0 for ocean, 1 for land) + skt, & ! Surface temperature (K) + surfelev ! Surface Elevation (m) + ! Fields used ONLY by RTTOV + real(wp),allocatable,dimension(:) :: & + u_sfc, & ! Surface u-wind (m/s) + v_sfc, & ! Surface v-wind (m/s) + t2m, & ! 2-meter temperature (K) + q2m, & ! 2-meter specific humidity (kg/kg) + lat, & ! Latitude (deg) + lon, & ! Longitude (deg) + sza, & ! Solar Zenith Angle in degrees + psfc, & ! Surface pressure (Pa) + rttov_sfcmask ! Mask for RTTOV surface types (0 for ocean, 1 for land, 2 for sea ice) + + real(wp),allocatable,dimension(:,:) :: & + o3, & ! Ozone (kg/kg) + tca, & ! Total layer cloud fraction (0-1) + cloudIce, & ! Cloud ice water mixing ratio (kg/kg) + cloudLiq, & ! Cloud liquid water mixing ratio (kg/kg) + DeffLiq, & ! Cloud liquid effective diameter (um) + DeffIce, & ! Cloud ice effective diameter (um) + rttov_date, & ! Date of the profile as year (e.g. 2013), month (1-12), and day (1-31) + rttov_time, & ! Time of profile as hour, minute, second. + emis_in, & ! Surface emissivity (point,channel) (1) + refl_in, & ! Surface reflectance (point,channel) (1) + fl_rain, & ! Precipitation (rain) flux (kg/m2/s) + fl_snow ! Precipitation (snow) flux (kg/m2/s) + end type cosp_column_inputs + + + ! ###################################################################################### + ! TYPE swath_inputs + ! ###################################################################################### + type swath_inputs + + integer :: & + N_inst_swaths = 0 + real(wp),dimension(20) :: & + inst_localtimes, & + inst_localtime_widths + + end type swath_inputs + + type radar_cfg + ! Radar properties + real(wp) :: freq,k2 + integer :: nhclass ! Number of hydrometeor classes in use + integer :: use_gas_abs, do_ray + logical :: radar_at_layer_one ! If true radar is assume to be at the edge + ! of the first layer, if the first layer is the + ! surface than a ground-based radar. If the + ! first layer is the top-of-atmosphere, then + ! a space borne radar. + + ! Variables used to store Z scale factors + character(len=240) :: scale_LUT_file_name + logical :: load_scale_LUTs, update_scale_LUTs + logical, dimension(maxhclass,nRe_types) :: N_scale_flag + logical, dimension(maxhclass,mt_ntt,nRe_types) :: Z_scale_flag,Z_scale_added_flag + real(wp),dimension(maxhclass,mt_ntt,nRe_types) :: Ze_scaled,Zr_scaled,kr_scaled + real(wp),dimension(maxhclass,nd,nRe_types) :: fc, rho_eff + real(wp),dimension(Re_MAX_BIN) :: base_list,step_list + + end type radar_cfg + + ! ###################################################################################### + ! TYPE cosp_optical_inputs + ! ###################################################################################### + type cosp_optical_inputs + integer :: & + Npoints, & ! Number of gridpoints. + Ncolumns, & ! Number of columns. + Nlevels, & ! Number of levels. + Npart, & ! Number of cloud meteors for LIDAR simulators. + Nrefl, & ! Number of reflectances for PARASOL simulator + Ninst_rttov ! Number of RTTOV instruments + real(wp),pointer :: & + emis_grey => null() ! Greybody (spectrally flat) emissivity value for RTTOV + real(wp) :: & + emsfc_lw ! Surface emissivity @ 11micron + real(wp),allocatable,dimension(:,:,:) :: & + frac_out, & ! Cloud fraction + tau_067, & ! Optical depth @ 0.67micron + emiss_11, & ! Emissivity @ 11 micron + fracLiq, & ! Fraction of optical-depth due to liquid (MODIS) + asym, & ! Assymetry parameter @ 3.7micron (MODIS) + ss_alb, & ! Single-scattering albedo @ 3.7micron (MODIS) + betatot_calipso, & ! Lidar backscatter coefficient (calipso @ 532nm) + betatot_grLidar532, & ! Lidar backscatter coefficient (ground-lidar @ 532nm) + betatot_atlid, & ! Lidar backscatter coefficient (atlid @ 355nm) + betatot_ice_calipso, & ! Lidar backscatter coefficient ICE (calipso @ 532nm) + betatot_liq_calipso, & ! Lidar backscatter coefficient LIQUID (calipso @ 532nm) + tautot_calipso, & ! Lidar Optical thickness (calipso @ 532nm) + tautot_grLidar532, & ! Lidar Optical thickness (ground-lidar @ 532nm) + tautot_atlid, & ! Lidar Optical thickness (atlid @ 355nm) + tautot_ice_calipso, & ! Lidar Ice Optical thickness (calipso @ 532nm) + tautot_liq_calipso, & ! Lidar Liquid Optical thickness (calipso @ 532nm) + z_vol_cloudsat, & ! Effective reflectivity factor (mm^6/m^3) + kr_vol_cloudsat, & ! Attenuation coefficient hydro (dB/km) + g_vol_cloudsat ! Attenuation coefficient gases (dB/km) + real(wp),allocatable,dimension(:,:) :: & + beta_mol_calipso, & ! Lidar molecular backscatter coefficient (calipso @ 532nm) + beta_mol_grLidar532, & ! Lidar molecular backscatter coefficient (ground-lidar @ 532nm) + beta_mol_atlid, & ! Lidar molecular backscatter coefficient (atlid @ 355nm) + tau_mol_calipso, & ! Lidar molecular optical depth (calipso @ 532nm) + tau_mol_grLidar532, & ! Lidar molecular optical depth (ground-lidar @ 532nm) + tau_mol_atlid, & ! Lidar molecular optical depth (atlid @ 355nm) + tautot_S_liq, & ! Parasol Liquid water optical thickness, from TOA to SFC + tautot_S_ice, & ! Parasol Ice water optical thickness, from TOA to SFC + fracPrecipIce ! Fraction of precipitation which is frozen (1). + type(radar_cfg) :: & + rcfg_cloudsat ! Radar configuration information (CLOUDSAT) + type(rttov_cfg),dimension(:),pointer :: & + cfg_rttov ! RTTOV configuration information (multiple instruments) + type(swath_inputs),dimension(6) :: & ! Could be a pointer but fine + cospswathsIN + end type cosp_optical_inputs + + +CONTAINS !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !---------- SUBROUTINE COSP_CHANGE_VERTICAL_GRID ---------------- !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -506,4 +671,111 @@ subroutine hist2D(var1,var2,npts,bin1,nbin1,bin2,nbin2,jointHist) enddo enddo end subroutine hist2D + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE cosp_cleanUp + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine cosp_cleanUp() + deallocate(vgrid_zl,vgrid_zu,vgrid_z,dz) + end subroutine cosp_cleanUp + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE compute_orbitmasks + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine compute_orbitmasks(Npoints,Nlocaltimes,localtimes,localtime_widths, & + lat,lon,month,day,hour,minute,swath_mask_out,Nswathed_out) + + ! Inputs + integer,intent(in) :: & + Npoints, & + Nlocaltimes + + real(wp),dimension(Nlocaltimes),intent(in) :: & + localtimes, & + localtime_widths + + real(wp),dimension(Npoints),intent(in) :: & + lat, & + lon, & + month, & + day, & + hour, & + minute + + ! Output + logical,dimension(Npoints),intent(out) :: & + swath_mask_out ! Mask of reals over all gridcells + integer,intent(out) :: & + Nswathed_out + + ! Local variables + integer :: i ! iterator + + real(wp),dimension(Npoints,Nlocaltimes) :: & + sat_lon, & ! Central longitude of the instrument. + dlon, & ! distance to satellite longitude in degrees + dx ! distance to satellite longitude in km? + + logical,dimension(Npoints,Nlocaltimes) :: & + swath_mask_all ! Mask of logicals over all local times, gridcells + + integer, dimension(Npoints) :: & + rttov_DOY ! Array of day of year values + real(wp), dimension(Npoints) :: & + localtime_offsets ! Offset values to avoid striping with hourly RT calls. [hours] + ! Compute the day of the year and determine the localtime offset + do i=1,Npoints + call get_DOY(int(month(i)), int(day(i)), rttov_DOY(i)) + end do + localtime_offsets = (mod(rttov_DOY(:), 5) - 2) / 5.0 ! Need to cast to real + + ! Iterate over local times + swath_mask_all(:,:) = .false. + do i=1,Nlocaltimes + ! Calculate the central longitude for each gridcell and orbit + sat_lon(:,i) = 15.0 * (localtimes(i) + localtime_offsets - (hour + minute / 60)) + ! Calculate distance (in degrees) from each grid cell to the satellite central long + dlon(:,i) = mod((lon - sat_lon(:,i) + 180.0), 360.0) - 180.0 + ! calculate distance to satellite in km. Remember to convert to radians for cos/sine calls + dx(:,i) = dlon(:,i) * (pi/180.0) * COS(lat * pi / 180) * radius_earth + ! Determine if a gridcell falls in the swath width + where (abs(dx(:,i))<(localtime_widths(i)*0.5)) + swath_mask_all(:,i) = .true. + end where + end do + + ! Mask is true where values should be calculated + swath_mask_out = ANY( swath_mask_all(:,:),2) ! Compute mask by collapsing the localtimes dimension + Nswathed_out = count(swath_mask_out) ! Number of gridcells that should be calculated. + + end subroutine compute_orbitmasks + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE get_DOY + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + subroutine get_DOY(month, day, DOY) + + integer,intent(in) :: & + month, & + day + integer,intent(out) :: & + DOY + + ! This subroutine does not handle leap years because it is not relevant to the purpose. + ! Simple look-up table for DOY. + if (month .eq. 1) DOY = day + if (month .eq. 2) DOY = 31 + day + if (month .eq. 3) DOY = 59 + day + if (month .eq. 4) DOY = 90 + day + if (month .eq. 5) DOY = 120 + day + if (month .eq. 6) DOY = 151 + day + if (month .eq. 7) DOY = 181 + day + if (month .eq. 8) DOY = 212 + day + if (month .eq. 9) DOY = 243 + day + if (month .eq. 10) DOY = 273 + day + if (month .eq. 11) DOY = 304 + day + if (month .eq. 12) DOY = 334 + day + + end subroutine get_DOY + END MODULE MOD_COSP_STATS diff --git a/src/simulator/cosp_atlid_interface.F90 b/src/simulator/cosp_atlid_interface.F90 index c18bd54492..c947c64d8b 100644 --- a/src/simulator/cosp_atlid_interface.F90 +++ b/src/simulator/cosp_atlid_interface.F90 @@ -28,17 +28,28 @@ ! ! History ! Apr 2018 - R. Guzman - Original version +! Jun 2025 - J.K. Shaw - Added COSP-RTTOV integration and swathing ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MODULE MOD_COSP_ATLID_INTERFACE USE COSP_KINDS, ONLY: wp + use mod_cosp_stats, ONLY: compute_orbitmasks,cosp_optical_inputs,cosp_column_inputs IMPLICIT NONE + ! Module variables + real(wp),dimension(:,:),target,allocatable :: & + temp_beta_mol_atlid, & + temp_tau_mol_atlid + real(wp),dimension(:,:,:),target,allocatable :: & + temp_betatot_atlid, & + temp_tautot_atlid + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! TYPE atlid_in !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% type atlid_IN + integer :: & + Npoints ! Number of gridpoints. integer,pointer :: & - Npoints, & ! Number of gridpoints. Ncolumns, & ! Number of columns. Nlevels ! Number of levels. @@ -60,6 +71,84 @@ subroutine cosp_atlid_init() end subroutine cosp_atlid_init + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE COSP_ATLID_MASK + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE COSP_ATLID_MASK(cospIN,cospgridIN,Npoints,atlidIN,ATLID_MASK_INDICES) + type(cosp_optical_inputs),intent(in),target :: cospIN ! Optical inputs to COSP simulator + type(cosp_column_inputs), intent(in),target :: cospgridIN ! Host model inputs to COSP + integer,intent(in),target :: & + Npoints + type(atlid_IN),intent(inout) :: & + atlidIN + integer,dimension(:),allocatable,intent(out) :: & ! Array containing the indices of the swath masks, already allocated? + ATLID_MASK_INDICES + + ! Local variables + logical,dimension(:),allocatable :: & ! Mask of reals over all local times + ATLID_SWATH_MASK + integer, target :: & + N_ATLID_SWATHED, & + i + + if (cospIN % cospswathsIN(4) % N_inst_swaths .gt. 0) then + allocate(ATLID_SWATH_MASK(Npoints)) + ! Do swathing to figure out which cells to simulate on + call compute_orbitmasks(Npoints, & + cospIN % cospswathsIN(4) % N_inst_swaths, & + cospIN % cospswathsIN(4) % inst_localtimes, & + cospIN % cospswathsIN(4) % inst_localtime_widths, & + cospgridIN%lat, cospgridIN%lon, & + cospgridIN%rttov_date(:,2), cospgridIN%rttov_date(:,3), & ! Time fields: month, dayofmonth + cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute + ATLID_SWATH_MASK,N_ATLID_SWATHED) ! Output: logical mask array + atlidIN%Npoints = N_ATLID_SWATHED + atlidIN%Ncolumns => cospIN%Ncolumns + allocate(ATLID_MASK_INDICES(N_ATLID_SWATHED)) + ATLID_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = ATLID_SWATH_MASK) + deallocate(ATLID_SWATH_MASK) + if (atlidIN%Npoints .gt. 0) then + ! Allocate swathed arrays. + allocate(temp_beta_mol_atlid(atlidIN%Npoints,cospIN%Nlevels), & + temp_betatot_atlid(atlidIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_tau_mol_atlid(atlidIN%Npoints,cospIN%Nlevels), & + temp_tautot_atlid(atlidIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels)) + ! Encode step: Read only appropriate values into the new temp arrays. + temp_beta_mol_atlid(:,:) = cospIN%beta_mol_atlid(int(ATLID_MASK_INDICES),:) + temp_tau_mol_atlid(:,:) = cospIN%tau_mol_atlid(int(ATLID_MASK_INDICES),:) + temp_betatot_atlid(:,:,:) = cospIN%betatot_atlid(int(ATLID_MASK_INDICES),:,:) + temp_tautot_atlid(:,:,:) = cospIN%tautot_atlid(int(ATLID_MASK_INDICES),:,:) + + atlidIN%Nlevels => cospIN%Nlevels + atlidIN%beta_mol_atlid => temp_beta_mol_atlid + atlidIN%betatot_atlid => temp_betatot_atlid + atlidIN%tau_mol_atlid => temp_tau_mol_atlid + atlidIN%tautot_atlid => temp_tautot_atlid + end if + else + atlidIN%Npoints = Npoints + atlidIN%Ncolumns => cospIN%Ncolumns + atlidIN%Nlevels => cospIN%Nlevels + atlidIN%beta_mol_atlid => cospIN%beta_mol_atlid + atlidIN%betatot_atlid => cospIN%betatot_atlid + atlidIN%tau_mol_atlid => cospIN%tau_mol_atlid + atlidIN%tautot_atlid => cospIN%tautot_atlid + end if + + END SUBROUTINE COSP_ATLID_MASK + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE COSP_ATLID_CLEAN + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE COSP_ATLID_MASK_CLEAN() + ! Deallocate temporary arrays + if (allocated(temp_beta_mol_atlid)) deallocate(temp_beta_mol_atlid) + if (allocated(temp_tau_mol_atlid)) deallocate(temp_tau_mol_atlid) + if (allocated(temp_betatot_atlid)) deallocate(temp_betatot_atlid) + if (allocated(temp_tautot_atlid)) deallocate(temp_tautot_atlid) + + END SUBROUTINE COSP_ATLID_MASK_CLEAN + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! END MODULE ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/simulator/cosp_calipso_interface.F90 b/src/simulator/cosp_calipso_interface.F90 index 7e50fb1743..fe1da45715 100644 --- a/src/simulator/cosp_calipso_interface.F90 +++ b/src/simulator/cosp_calipso_interface.F90 @@ -29,21 +29,35 @@ ! History ! May 2015 - D. Swales - Original version ! Jul 2017 - R. Guzman - Added Ground LIDar variables (GLID) +! Jun 2025 - J.K. Shaw - Added COSP-RTTOV integration and swathing ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MODULE MOD_COSP_CALIPSO_INTERFACE USE COSP_KINDS, ONLY: wp USE MOD_LIDAR_SIMULATOR, ONLY: alpha,beta,gamma + use mod_cosp_stats, ONLY: compute_orbitmasks,cosp_optical_inputs,cosp_column_inputs IMPLICIT NONE - + + ! Module variables + real(wp),dimension(:,:),target,allocatable :: & + temp_beta_mol_calipso, & + temp_tau_mol_calipso + real(wp),dimension(:,:,:),target,allocatable :: & + temp_betatot_calipso, & + temp_tautot_calipso, & + temp_betatot_liq_calipso, & + temp_tautot_liq_calipso, & + temp_betatot_ice_calipso, & + temp_tautot_ice_calipso + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! TYPE calipso_in !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% type calipso_IN + integer :: & + Npoints ! Number of gridpoints. integer,pointer :: & - Npoints, & ! Number of gridpoints. Ncolumns, & ! Number of columns. Nlevels ! Number of levels. - real(wp),dimension(:,:),pointer :: & beta_mol, & ! Molecular backscatter coefficient tau_mol ! Molecular optical depth @@ -79,6 +93,103 @@ subroutine cosp_calipso_init() end subroutine cosp_calipso_init + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE COSP_CALIPSO_MASK + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE COSP_CALIPSO_MASK(cospIN,cospgridIN,Npoints,calipsoIN,CSCAL_MASK_INDICES,CSCAL_SWATH_MASK) + type(cosp_optical_inputs),intent(in),target :: cospIN ! Optical inputs to COSP simulator + type(cosp_column_inputs), intent(in),target :: cospgridIN ! Host model inputs to COSP + integer,intent(in),target :: & + Npoints + type(calipso_IN),intent(inout) :: & + calipsoIN + integer,dimension(:),allocatable,intent(out) :: & ! Array containing the indices of the swath masks, already allocated? + CSCAL_MASK_INDICES + logical,dimension(:),allocatable,intent(inout) :: & ! Mask of reals over all local times + CSCAL_SWATH_MASK + + ! Local variables + integer, target :: & + N_CALIPSO_SWATHED, & + i + + if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then + if (.not.allocated(CSCAL_SWATH_MASK)) allocate(CSCAL_SWATH_MASK(Npoints)) + ! Do swathing to figure out which cells to simulate on + call compute_orbitmasks(Npoints, & + cospIN % cospswathsIN(3) % N_inst_swaths, & + cospIN % cospswathsIN(3) % inst_localtimes, & + cospIN % cospswathsIN(3) % inst_localtime_widths, & + cospgridIN%lat, cospgridIN%lon, & + cospgridIN%rttov_date(:,2), cospgridIN%rttov_date(:,3), & ! Time fields: month, dayofmonth + cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute + CSCAL_SWATH_MASK,N_CALIPSO_SWATHED) ! Output: logical mask array + calipsoIN%Npoints = N_CALIPSO_SWATHED + calipsoIN%Ncolumns => cospIN%Ncolumns + allocate(CSCAL_MASK_INDICES(N_CALIPSO_SWATHED)) + CSCAL_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = CSCAL_SWATH_MASK) + if (calipsoIN%Npoints .gt. 0) then + ! Allocate swathed arrays. + allocate(temp_beta_mol_calipso(calipsoIN%Npoints,cospIN%Nlevels), & + temp_tau_mol_calipso(calipsoIN%Npoints,cospIN%Nlevels), & + temp_betatot_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_tautot_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_betatot_liq_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_tautot_liq_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_betatot_ice_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_tautot_ice_calipso(calipsoIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels)) + ! Encode step: Read only appropriate values into the new temp arrays. + temp_beta_mol_calipso(:,:) = cospIN%beta_mol_calipso(int(CSCAL_MASK_INDICES),:) + temp_tau_mol_calipso(:,:) = cospIN%tau_mol_calipso(int(CSCAL_MASK_INDICES),:) + temp_betatot_calipso(:,:,:) = cospIN%betatot_calipso(int(CSCAL_MASK_INDICES),:,:) + temp_tautot_calipso(:,:,:) = cospIN%tautot_calipso(int(CSCAL_MASK_INDICES),:,:) + temp_betatot_liq_calipso(:,:,:) = cospIN%betatot_liq_calipso(int(CSCAL_MASK_INDICES),:,:) + temp_tautot_liq_calipso(:,:,:) = cospIN%tautot_liq_calipso(int(CSCAL_MASK_INDICES),:,:) + temp_betatot_ice_calipso(:,:,:) = cospIN%betatot_ice_calipso(int(CSCAL_MASK_INDICES),:,:) + temp_tautot_ice_calipso(:,:,:) = cospIN%tautot_ice_calipso(int(CSCAL_MASK_INDICES),:,:) + + calipsoIN%Nlevels => cospIN%Nlevels + calipsoIN%beta_mol => temp_beta_mol_calipso + calipsoIN%betatot => temp_betatot_calipso + calipsoIN%betatot_liq => temp_betatot_liq_calipso + calipsoIN%betatot_ice => temp_betatot_ice_calipso + calipsoIN%tau_mol => temp_tau_mol_calipso + calipsoIN%tautot => temp_tautot_calipso + calipsoIN%tautot_liq => temp_tautot_liq_calipso + calipsoIN%tautot_ice => temp_tautot_ice_calipso + end if + else + calipsoIN%Npoints = Npoints + calipsoIN%Ncolumns => cospIN%Ncolumns + calipsoIN%Nlevels => cospIN%Nlevels + calipsoIN%beta_mol => cospIN%beta_mol_calipso + calipsoIN%betatot => cospIN%betatot_calipso + calipsoIN%betatot_liq => cospIN%betatot_liq_calipso + calipsoIN%betatot_ice => cospIN%betatot_ice_calipso + calipsoIN%tau_mol => cospIN%tau_mol_calipso + calipsoIN%tautot => cospIN%tautot_calipso + calipsoIN%tautot_liq => cospIN%tautot_liq_calipso + calipsoIN%tautot_ice => cospIN%tautot_ice_calipso + end if + + END SUBROUTINE COSP_CALIPSO_MASK + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE COSP_CALIPSO_CLEAN + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE COSP_CALIPSO_MASK_CLEAN() + ! Deallocate temporary arrays + if (allocated(temp_beta_mol_calipso)) deallocate(temp_beta_mol_calipso) + if (allocated(temp_tau_mol_calipso)) deallocate(temp_tau_mol_calipso) + if (allocated(temp_betatot_calipso)) deallocate(temp_betatot_calipso) + if (allocated(temp_tautot_calipso)) deallocate(temp_tautot_calipso) + if (allocated(temp_betatot_liq_calipso)) deallocate(temp_betatot_liq_calipso) + if (allocated(temp_tautot_liq_calipso)) deallocate(temp_tautot_liq_calipso) + if (allocated(temp_betatot_ice_calipso)) deallocate(temp_betatot_ice_calipso) + if (allocated(temp_tautot_ice_calipso)) deallocate(temp_tautot_ice_calipso) + + END SUBROUTINE COSP_CALIPSO_MASK_CLEAN + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! END MODULE ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/simulator/cosp_cloudsat_interface.F90 b/src/simulator/cosp_cloudsat_interface.F90 index 0012f7a00a..aa2cc986b2 100644 --- a/src/simulator/cosp_cloudsat_interface.F90 +++ b/src/simulator/cosp_cloudsat_interface.F90 @@ -28,10 +28,12 @@ ! ! History ! May 2015 - D. Swales - Original version +! Jun 2025 - J.K. Shaw - Added COSP-RTTOV integration and swathing ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MODULE MOD_COSP_CLOUDSAT_INTERFACE USE COSP_KINDS, ONLY: wp - USE quickbeam, ONLY: quickbeam_init,radar_cfg,Re_MAX_BIN,Re_BIN_LENGTH + USE quickbeam, ONLY: quickbeam_init,Re_MAX_BIN,Re_BIN_LENGTH + use mod_cosp_stats, ONLY: radar_cfg,compute_orbitmasks,cosp_optical_inputs,cosp_column_inputs IMPLICIT NONE ! Directory where LUTs will be stored @@ -39,12 +41,21 @@ MODULE MOD_COSP_CLOUDSAT_INTERFACE logical :: RADAR_SIM_LOAD_scale_LUTs_flag = .false. logical :: RADAR_SIM_UPDATE_scale_LUTs_flag = .false. + ! Module variables + real(wp),dimension(:,:),target,allocatable :: & + temp_hgt_matrix + real(wp),dimension(:,:,:),target,allocatable :: & + temp_z_vol_cloudsat, & + temp_kr_vol_cloudsat, & + temp_g_vol_cloudsat + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! TYPE cloudsat_IN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% type cloudsat_IN + integer :: & + Npoints ! Number of horizontal grid-points integer,pointer :: & - Npoints, & ! Number of horizontal grid-points Nlevels, & ! Number of vertical levels Ncolumns ! Number of subcolumns real(wp),pointer :: & @@ -136,6 +147,86 @@ SUBROUTINE COSP_CLOUDSAT_INIT(radar_freq,k2,use_gas_abs,do_ray,undef,nhydro, & END SUBROUTINE COSP_CLOUDSAT_INIT + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE COSP_CLOUDSAT_MASK + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE COSP_CLOUDSAT_MASK(cospIN,cospgridIN,Npoints,cloudsatIN,CSCAL_MASK_INDICES,CSCAL_SWATH_MASK) + type(cosp_optical_inputs),intent(in),target :: cospIN ! Optical inputs to COSP simulator + type(cosp_column_inputs), intent(in),target :: cospgridIN ! Host model inputs to COSP + integer,intent(in),target :: & + Npoints + type(cloudsat_IN),intent(inout) :: & + cloudsatIN + integer,dimension(:),allocatable,intent(out) :: & ! Array containing the indices of the swath masks, already allocated? + CSCAL_MASK_INDICES + logical,dimension(:),allocatable,intent(inout) :: & ! Mask of reals over all local times + CSCAL_SWATH_MASK + + ! Local variables + integer, target :: & + N_CLOUDSAT_SWATHED, & + i + + if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then + if (.not.allocated(CSCAL_SWATH_MASK)) allocate(CSCAL_SWATH_MASK(Npoints)) + ! Do swathing to figure out which cells to simulate on + call compute_orbitmasks(Npoints, & + cospIN % cospswathsIN(3) % N_inst_swaths, & + cospIN % cospswathsIN(3) % inst_localtimes, & + cospIN % cospswathsIN(3) % inst_localtime_widths, & + cospgridIN%lat, cospgridIN%lon, & + cospgridIN%rttov_date(:,2), cospgridIN%rttov_date(:,3), & ! Time fields: month, dayofmonth + cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute + CSCAL_SWATH_MASK,N_CLOUDSAT_SWATHED) ! Output: logical mask array + cloudsatIN%Npoints = N_CLOUDSAT_SWATHED + cloudsatIN%Ncolumns => cospIN%Ncolumns + if (.not. allocated(CSCAL_MASK_INDICES)) allocate(CSCAL_MASK_INDICES(cloudsatIN%Npoints)) + CSCAL_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = CSCAL_SWATH_MASK) + if (cloudsatIN%Npoints .gt. 0) then + ! Allocate swathed arrays. + allocate(temp_z_vol_cloudsat(cloudsatIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_kr_vol_cloudsat(cloudsatIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_g_vol_cloudsat(cloudsatIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_hgt_matrix(cloudsatIN%Npoints,cospIN%Nlevels)) + ! Encode step: Read only appropriate values into the new temp arrays. + temp_z_vol_cloudsat = cospIN%z_vol_cloudsat(int(CSCAL_MASK_INDICES),:,:) + temp_kr_vol_cloudsat = cospIN%kr_vol_cloudsat(int(CSCAL_MASK_INDICES),:,:) + temp_g_vol_cloudsat = cospIN%g_vol_cloudsat(int(CSCAL_MASK_INDICES),:,:) + temp_hgt_matrix = cospgridIN%hgt_matrix(int(CSCAL_MASK_INDICES),:) + ! Reassign swathed values. + cloudsatIN%Nlevels => cospIN%Nlevels + cloudsatIN%z_vol => temp_z_vol_cloudsat + cloudsatIN%kr_vol => temp_kr_vol_cloudsat + cloudsatIN%g_vol => temp_g_vol_cloudsat + cloudsatIN%rcfg => cospIN%rcfg_cloudsat + cloudsatIN%hgt_matrix => temp_hgt_matrix + end if + else + cloudsatIN%Npoints = Npoints + cloudsatIN%Ncolumns => cospIN%Ncolumns + cloudsatIN%Nlevels => cospIN%Nlevels + cloudsatIN%z_vol => cospIN%z_vol_cloudsat + cloudsatIN%kr_vol => cospIN%kr_vol_cloudsat + cloudsatIN%g_vol => cospIN%g_vol_cloudsat + cloudsatIN%rcfg => cospIN%rcfg_cloudsat + cloudsatIN%hgt_matrix => cospgridIN%hgt_matrix + end if + + END SUBROUTINE COSP_CLOUDSAT_MASK + + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE COSP_CLOUDSAT_CLEAN + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE COSP_CLOUDSAT_MASK_CLEAN() + ! Deallocate temporary arrays + if (allocated(temp_z_vol_cloudsat)) deallocate(temp_z_vol_cloudsat) + if (allocated(temp_kr_vol_cloudsat)) deallocate(temp_kr_vol_cloudsat) + if (allocated(temp_g_vol_cloudsat)) deallocate(temp_g_vol_cloudsat) + if (allocated(temp_hgt_matrix)) deallocate(temp_hgt_matrix) + + END SUBROUTINE COSP_CLOUDSAT_MASK_CLEAN + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! END MODULE !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/simulator/cosp_isccp_interface.F90 b/src/simulator/cosp_isccp_interface.F90 index 70299aac43..3807e855a9 100644 --- a/src/simulator/cosp_isccp_interface.F90 +++ b/src/simulator/cosp_isccp_interface.F90 @@ -28,19 +28,37 @@ ! ! History ! May 2015 - D. Swales - Original version +! Jun 2025 - J.K. Shaw - Added COSP-RTTOV integration and swathing ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MODULE MOD_COSP_ISCCP_INTERFACE USE COSP_KINDS, ONLY: wp USE mod_icarus, ONLY: isccp_top_height,isccp_top_height_direction + use mod_cosp_stats, ONLY: compute_orbitmasks,cosp_optical_inputs,cosp_column_inputs + IMPLICIT NONE - + ! Module variables + integer,dimension(:),target,allocatable :: & + temp_isccp_sunlit + real(wp),dimension(:),target,allocatable :: & + temp_isccp_skt + real(wp),dimension(:,:),target,allocatable :: & + temp_isccp_qv, & + temp_isccp_at, & + temp_isccp_phalf, & + temp_isccp_pfull + real(wp),dimension(:,:,:),target,allocatable :: & + temp_isccp_frac_out, & + temp_isccp_tau_067, & + temp_isccp_emiss_11 + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! TYPE isccp_in !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Derived input type for ISCCP simulator type isccp_IN + integer :: & + Npoints ! Number of gridpoints. integer,pointer :: & - Npoints, & ! Number of gridpoints. Ncolumns, & ! Number of columns. Nlevels, & ! Number of levels. top_height, & ! @@ -79,6 +97,106 @@ SUBROUTINE COSP_ISCCP_INIT(top_height,top_height_direction) END SUBROUTINE COSP_ISCCP_INIT + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE COSP_ISCCP_MASK + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE COSP_ISCCP_MASK(cospIN,cospgridIN,Npoints,isccpIN,ISCCP_MASK_INDICES) + type(cosp_optical_inputs),intent(in),target :: cospIN ! Optical inputs to COSP simulator + type(cosp_column_inputs), intent(in),target :: cospgridIN ! Host model inputs to COSP + integer,intent(in),target :: & + Npoints + type(isccp_IN),intent(inout) :: & + isccpIN + integer,dimension(:),allocatable,intent(out) :: & ! Array containing the indices of the swath masks, already allocated? + ISCCP_MASK_INDICES + + ! Local variables + logical,dimension(:),allocatable :: & ! Mask of reals over all local times + ISCCP_SWATH_MASK + integer, target :: & + N_ISCCP_SWATHED, & + i + + if (cospIN % cospswathsIN(1) % N_inst_swaths .gt. 0) then + allocate(ISCCP_SWATH_MASK(Npoints)) + ! Do swathing to figure out which cells to simulate on + call compute_orbitmasks(Npoints, & + cospIN % cospswathsIN(1) % N_inst_swaths, & + cospIN % cospswathsIN(1) % inst_localtimes, & + cospIN % cospswathsIN(1) % inst_localtime_widths, & + cospgridIN%lat, cospgridIN%lon, & + cospgridIN%rttov_date(:,2), cospgridIN%rttov_date(:,3), & ! Time fields: month, dayofmonth + cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute + ISCCP_SWATH_MASK,N_ISCCP_SWATHED) ! Output: logical mask array + isccpIN%Npoints = N_ISCCP_SWATHED + isccpIN%Ncolumns => cospIN%Ncolumns + allocate(ISCCP_MASK_INDICES(N_ISCCP_SWATHED)) + ISCCP_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = ISCCP_SWATH_MASK) + deallocate(ISCCP_SWATH_MASK) + if (isccpIN%Npoints .gt. 0) then + ! Allocate swathed arrays. + allocate(temp_isccp_skt(isccpIN%Npoints),temp_isccp_qv(isccpIN%Npoints,cospIN%Nlevels),temp_isccp_at(isccpIN%Npoints,cospIN%Nlevels), & + temp_isccp_frac_out(isccpIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels),temp_isccp_tau_067(isccpIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_isccp_emiss_11(isccpIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels),temp_isccp_phalf(isccpIN%Npoints,cospIN%Nlevels+1), & + temp_isccp_pfull(isccpIN%Npoints,cospIN%Nlevels),temp_isccp_sunlit(isccpIN%Npoints)) + ! Encode step: Read only appropriate values into the new temp arrays. + temp_isccp_skt(:) = cospgridIN%skt(int(ISCCP_MASK_INDICES)) + temp_isccp_qv(:,:) = cospgridIN%qv(int(ISCCP_MASK_INDICES),:) + temp_isccp_at(:,:) = cospgridIN%at(int(ISCCP_MASK_INDICES),:) + temp_isccp_frac_out(:,:,:) = cospIN%frac_out(int(ISCCP_MASK_INDICES),:,:) + temp_isccp_tau_067(:,:,:) = cospIN%tau_067(int(ISCCP_MASK_INDICES),:,:) + temp_isccp_emiss_11(:,:,:) = cospIN%emiss_11(int(ISCCP_MASK_INDICES),:,:) + temp_isccp_phalf(:,:) = cospgridIN%phalf(int(ISCCP_MASK_INDICES),:) + temp_isccp_pfull(:,:) = cospgridIN%pfull(int(ISCCP_MASK_INDICES),:) + temp_isccp_sunlit(:) = cospgridIN%sunlit(int(ISCCP_MASK_INDICES)) + + isccpIN%Nlevels => cospIN%Nlevels + isccpIN%emsfc_lw => cospIN%emsfc_lw + isccpIN%skt => temp_isccp_skt + isccpIN%qv => temp_isccp_qv + isccpIN%at => temp_isccp_at + isccpIN%frac_out => temp_isccp_frac_out + isccpIN%dtau => temp_isccp_tau_067 + isccpIN%dem => temp_isccp_emiss_11 + isccpIN%phalf => temp_isccp_phalf + isccpIN%pfull => temp_isccp_pfull + isccpIN%sunlit => temp_isccp_sunlit + end if + else + isccpIN%Npoints = Npoints + isccpIN%Ncolumns => cospIN%Ncolumns + isccpIN%Nlevels => cospIN%Nlevels + isccpIN%emsfc_lw => cospIN%emsfc_lw + isccpIN%skt => cospgridIN%skt + isccpIN%qv => cospgridIN%qv + isccpIN%at => cospgridIN%at + isccpIN%frac_out => cospIN%frac_out + isccpIN%dtau => cospIN%tau_067 + isccpIN%dem => cospIN%emiss_11 + isccpIN%phalf => cospgridIN%phalf + isccpIN%pfull => cospgridIN%pfull + isccpIN%sunlit => cospgridIN%sunlit + end if + + END SUBROUTINE COSP_ISCCP_MASK + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE COSP_ISCCP_CLEAN + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE COSP_ISCCP_MASK_CLEAN() + ! Deallocate temporary arrays + if (allocated(temp_isccp_sunlit)) deallocate(temp_isccp_sunlit) + if (allocated(temp_isccp_skt)) deallocate(temp_isccp_skt) + if (allocated(temp_isccp_qv)) deallocate(temp_isccp_qv) + if (allocated(temp_isccp_at)) deallocate(temp_isccp_at) + if (allocated(temp_isccp_phalf)) deallocate(temp_isccp_phalf) + if (allocated(temp_isccp_pfull)) deallocate(temp_isccp_pfull) + if (allocated(temp_isccp_frac_out)) deallocate(temp_isccp_frac_out) + if (allocated(temp_isccp_tau_067)) deallocate(temp_isccp_tau_067) + if (allocated(temp_isccp_emiss_11)) deallocate(temp_isccp_emiss_11) + + END SUBROUTINE COSP_ISCCP_MASK_CLEAN + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! END MODULE !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/simulator/cosp_misr_interface.F90 b/src/simulator/cosp_misr_interface.F90 index a2daa6ef7d..b166cba6a8 100644 --- a/src/simulator/cosp_misr_interface.F90 +++ b/src/simulator/cosp_misr_interface.F90 @@ -28,18 +28,30 @@ ! ! History ! May 2015 - D. Swales - Original version +! Jun 2025 - J.K. Shaw - Added COSP-RTTOV integration and swathing ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MODULE MOD_COSP_MISR_INTERFACE USE COSP_KINDS, ONLY: wp - + use mod_cosp_stats, ONLY: compute_orbitmasks,cosp_optical_inputs,cosp_column_inputs + IMPLICIT NONE + ! Module variables + integer,dimension(:),target,allocatable :: & + temp_misr_sunlit + real(wp),dimension(:,:),target,allocatable :: & + temp_misr_zfull, & + temp_misr_at + real(wp),dimension(:,:,:),target,allocatable :: & + temp_misr_dtau + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! TYPE misr_in ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% type misr_IN + integer :: & + Npoints ! Number of gridpoints. integer,pointer :: & - Npoints, & ! Number of gridpoints. Ncolumns, & ! Number of columns. Nlevels ! Number of levels. integer,pointer :: & @@ -61,6 +73,84 @@ SUBROUTINE COSP_MISR_INIT() END SUBROUTINE COSP_MISR_INIT + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE COSP_MISR_MASK + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE COSP_MISR_MASK(cospIN,cospgridIN,Npoints,misrIN,MISR_MASK_INDICES) + type(cosp_optical_inputs),intent(in),target :: cospIN ! Optical inputs to COSP simulator + type(cosp_column_inputs), intent(in),target :: cospgridIN ! Host model inputs to COSP + integer,intent(in),target :: & + Npoints + type(misr_IN),intent(inout) :: & + misrIN + integer,dimension(:),allocatable,intent(out) :: & ! Array containing the indices of the swath masks, already allocated? + MISR_MASK_INDICES + + ! Local variables + logical,dimension(:),allocatable :: & ! Mask of reals over all local times + MISR_SWATH_MASK + integer, target :: & + N_MISR_SWATHED, & + i + + if (cospIN % cospswathsIN(2) % N_inst_swaths .gt. 0) then + allocate(MISR_SWATH_MASK(Npoints)) + ! Do swathing to figure out which cells to simulate on + call compute_orbitmasks(Npoints, & + cospIN % cospswathsIN(2) % N_inst_swaths, & + cospIN % cospswathsIN(2) % inst_localtimes, & + cospIN % cospswathsIN(2) % inst_localtime_widths, & + cospgridIN%lat, cospgridIN%lon, & + cospgridIN%rttov_date(:,2), cospgridIN%rttov_date(:,3), & ! Time fields: month, dayofmonth + cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute + MISR_SWATH_MASK,N_MISR_SWATHED) ! Output: logical mask array + misrIN%Npoints = N_MISR_SWATHED + misrIN%Ncolumns => cospIN%Ncolumns + allocate(MISR_MASK_INDICES(N_MISR_SWATHED)) + MISR_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = MISR_SWATH_MASK) + deallocate(MISR_SWATH_MASK) + if (misrIN%Npoints .gt. 0) then + ! Allocate swathed arrays. + allocate(temp_misr_dtau(misrIN%Npoints,cospIN%Ncolumns,cospIN%Nlevels), & + temp_misr_sunlit(misrIN%Npoints), & + temp_misr_zfull(misrIN%Npoints,cospIN%Nlevels), & + temp_misr_at(misrIN%Npoints,cospIN%Nlevels)) + ! Encode step: Read only appropriate values into the new temp arrays. + temp_misr_dtau(:,:,:) = cospIN%tau_067(int(MISR_MASK_INDICES),:,:) + temp_misr_at(:,:) = cospgridIN%at(int(MISR_MASK_INDICES),:) + temp_misr_zfull(:,:) = cospgridIN%hgt_matrix(int(MISR_MASK_INDICES),:) + temp_misr_sunlit(:) = cospgridIN%sunlit(int(MISR_MASK_INDICES)) + + misrIN%Nlevels => cospIN%Nlevels + misrIN%dtau => temp_misr_dtau + misrIN%sunlit => temp_misr_sunlit + misrIN%zfull => temp_misr_zfull + misrIN%at => temp_misr_at + end if + else + misrIN%Npoints = Npoints + misrIN%Ncolumns => cospIN%Ncolumns + misrIN%Nlevels => cospIN%Nlevels + misrIN%dtau => cospIN%tau_067 + misrIN%sunlit => cospgridIN%sunlit + misrIN%zfull => cospgridIN%hgt_matrix + misrIN%at => cospgridIN%at + end if + + END SUBROUTINE COSP_MISR_MASK + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE COSP_MISR_CLEAN + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE COSP_MISR_MASK_CLEAN() + ! Deallocate temporary arrays + if (allocated(temp_misr_sunlit)) deallocate(temp_misr_sunlit) + if (allocated(temp_misr_zfull)) deallocate(temp_misr_zfull) + if (allocated(temp_misr_at)) deallocate(temp_misr_at) + if (allocated(temp_misr_dtau)) deallocate(temp_misr_dtau) + + END SUBROUTINE COSP_MISR_MASK_CLEAN + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! END MODULE ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/simulator/cosp_modis_interface.F90 b/src/simulator/cosp_modis_interface.F90 index 10944654fc..90d1ce9d01 100644 --- a/src/simulator/cosp_modis_interface.F90 +++ b/src/simulator/cosp_modis_interface.F90 @@ -28,6 +28,7 @@ ! ! History ! May 2015 - D. Swales - Original version +! Jun 2025 - J.K. Shaw - Added COSP-RTTOV integration and swathing ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MODULE MOD_COSP_Modis_INTERFACE USE COSP_KINDS, ONLY: wp @@ -39,6 +40,7 @@ MODULE MOD_COSP_Modis_INTERFACE highCloudPressureLimit,lowCloudPressureLimit,phaseIsNone, & phaseIsLiquid,phaseIsIce,phaseIsUndetermined,trial_re_w, & trial_re_i,g_w,g_i,w0_w,w0_i, get_g_nir,get_ssa_nir + use mod_cosp_stats, ONLY: compute_orbitmasks,cosp_optical_inputs,cosp_column_inputs implicit none ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -106,7 +108,90 @@ SUBROUTINE COSP_MODIS_INIT() w0_i(1:num_trial_res) = get_ssa_nir(phaseIsIce,trial_re_i(1:num_trial_res)) END SUBROUTINE COSP_MODIS_INIT - + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE COSP_MODIS_MASK + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE COSP_MODIS_MASK(cospIN,cospgridIN,Npoints,modisIN,CSCAL_SWATH_MASK,MODIS_CSCAL_MASK_INDICES) + type(cosp_optical_inputs),intent(in),target :: cospIN ! Optical inputs to COSP simulator + type(cosp_column_inputs), intent(in),target :: cospgridIN ! Host model inputs to COSP + integer,intent(in),target :: & + Npoints + type(modis_IN),intent(inout) :: & + modisIN + logical,dimension(:),allocatable,intent(in) :: & ! Mask of reals over all local times + CSCAL_SWATH_MASK + integer,dimension(:),allocatable,intent(out) :: & ! Array containing the indices of the swath masks, already allocated? + MODIS_CSCAL_MASK_INDICES + ! Local variables + logical,dimension(:),allocatable :: & ! Mask of reals over all local times + MODIS_SWATH_MASK, & + MODIS_CSCAL_SWATH_MASK + integer, target :: & + N_MODIS_SWATHED, & + i + + if (cospIN % cospswathsIN(6) % N_inst_swaths .gt. 0) then + allocate(MODIS_SWATH_MASK(Npoints)) + ! Do swathing to figure out which cells to simulate on + call compute_orbitmasks(Npoints, & + cospIN % cospswathsIN(6) % N_inst_swaths, & + cospIN % cospswathsIN(6) % inst_localtimes, & + cospIN % cospswathsIN(6) % inst_localtime_widths, & + cospgridIN%lat, cospgridIN%lon, & + cospgridIN%rttov_date(:,2), cospgridIN%rttov_date(:,3), & ! Time fields: month, dayofmonth + cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute + MODIS_SWATH_MASK,N_MODIS_SWATHED) ! Output: logical mask array + + ! Operate a little differently with MODIS because there is already some swathing at play. + ! modisIN is over all variables rather than just swathed variables + modisIN%Ncolumns => cospIN%Ncolumns + modisIN%Nlevels => cospIN%Nlevels + modisIN%Npoints => Npoints + modisIN%liqFrac => cospIN%fracLiq + modisIN%tau => cospIN%tau_067 + modisIN%g => cospIN%asym + modisIN%w0 => cospIN%ss_alb + + allocate(modisIN%pres(modisIN%Npoints,cospIN%Nlevels+1)) ! Moving this outside of the sunlit statements for consistency with the other variables + modisIN%Nsunlit = count((cospgridIN%sunlit > 0) .and. MODIS_SWATH_MASK) ! Sunlit mask and indices array will just include swathing as well + modisIN%pres = cospgridIN%phalf + if (modisIN%Nsunlit .gt. 0) then + allocate(modisIN%sunlit(modisIN%Nsunlit)) + modisIN%sunlit = pack((/ (i, i = 1, modisIN%Npoints ) /),mask = ((cospgridIN%sunlit > 0) .and. MODIS_SWATH_MASK)) ! Indices of columns to operate on in modisIN + endif + if (modisIN%Npoints - modisIN%Nsunlit .gt. 0) then ! If more than zero tiles are not sunlit and swathed, create array to mask out these gridcells in cospOUT + allocate(modisIN%notSunlit(modisIN%Npoints - modisIN%Nsunlit)) + modisIN%notSunlit = pack((/ (i, i = 1, Npoints ) /),mask = (.not. ((cospgridIN%sunlit > 0) .and. MODIS_SWATH_MASK))) ! Create an array with the indices of the non-sunlit tiles + endif + ! Create a CSCAL-MODIS joint mask for the combined product. + if (allocated(CSCAL_SWATH_MASK)) then + allocate(MODIS_CSCAL_SWATH_MASK(Npoints)) + MODIS_CSCAL_SWATH_MASK = (.not. (MODIS_SWATH_MASK .and. CSCAL_SWATH_MASK)) ! Gridcells not seen by both MODIS and CSCAL should be set to zero + MODIS_CSCAL_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = MODIS_CSCAL_SWATH_MASK) + end if + else + modisIN%Ncolumns => cospIN%Ncolumns + modisIN%Nlevels => cospIN%Nlevels + modisIN%Npoints => Npoints + modisIN%liqFrac => cospIN%fracLiq + modisIN%tau => cospIN%tau_067 + modisIN%g => cospIN%asym + modisIN%w0 => cospIN%ss_alb + modisIN%Nsunlit = count(cospgridIN%sunlit > 0) + if (modisIN%Nsunlit .gt. 0) then + allocate(modisIN%sunlit(modisIN%Nsunlit),modisIN%pres(modisIN%Nsunlit,cospIN%Nlevels+1)) + modisIN%sunlit = pack((/ (i, i = 1, Npoints ) /),mask = cospgridIN%sunlit > 0) + modisIN%pres = cospgridIN%phalf(int(modisIN%sunlit(:)),:) ! JKS no reason to have this structure differently, right? Memory? + endif + if (count(cospgridIN%sunlit <= 0) .gt. 0) then ! If more than zero tiles are not sunlit a.k.a. if there are dark tiles + allocate(modisIN%notSunlit(count(cospgridIN%sunlit <= 0))) + modisIN%notSunlit = pack((/ (i, i = 1, Npoints ) /),mask = .not. cospgridIN%sunlit > 0) ! Create an array with the indices of the non-sunlit tiles + endif + end if + + END SUBROUTINE COSP_MODIS_MASK + ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! END MODULE MOD_COSP_Modis_INTERFACE ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/simulator/cosp_parasol_interface.F90 b/src/simulator/cosp_parasol_interface.F90 index 21a2d8650e..18a934dfb1 100644 --- a/src/simulator/cosp_parasol_interface.F90 +++ b/src/simulator/cosp_parasol_interface.F90 @@ -28,11 +28,18 @@ ! ! History ! May 2015 - D. Swales - Original version +! Jun 2025 - J.K. Shaw - Added COSP-RTTOV integration and swathing ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MODULE MOD_COSP_PARASOL_INTERFACE USE COSP_KINDS, ONLY: WP + use mod_cosp_stats, ONLY: compute_orbitmasks,cosp_optical_inputs,cosp_column_inputs implicit none + ! Module variables + real(wp),dimension(:,:),target,allocatable :: & + temp_tautot_S_liq, & + temp_tautot_S_ice + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! TYPE cosp_parasol !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -65,8 +72,9 @@ MODULE MOD_COSP_PARASOL_INTERFACE ! TYPE parasol_in !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TYPE parasol_IN + integer :: & + Npoints ! Number of horizontal gridpoints integer,pointer :: & - Npoints, & ! Number of horizontal gridpoints Nlevels, & ! Number of vertical levels Ncolumns, & ! Number of columns Nrefl ! Number of angles for which the reflectance is computed @@ -84,6 +92,75 @@ SUBROUTINE COSP_PARASOL_INIT() end subroutine COSP_PARASOL_INIT + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE COSP_PARASOL_MASK + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE COSP_PARASOL_MASK(cospIN,cospgridIN,Npoints,parasolIN,PARASOL_MASK_INDICES) + type(cosp_optical_inputs),intent(in),target :: cospIN ! Optical inputs to COSP simulator + type(cosp_column_inputs), intent(in),target :: cospgridIN ! Host model inputs to COSP + integer,intent(in),target :: & + Npoints + type(parasol_IN),intent(inout) :: & + parasolIN + integer,dimension(:),allocatable,intent(out) :: & ! Array containing the indices of the swath masks, already allocated? + PARASOL_MASK_INDICES + + ! Local variables + logical,dimension(:),allocatable :: & ! Mask of reals over all local times + PARASOL_SWATH_MASK + integer, target :: & + N_PARASOL_SWATHED, & + i + + if (cospIN % cospswathsIN(5) % N_inst_swaths .gt. 0) then + allocate(PARASOL_SWATH_MASK(Npoints)) + ! Do swathing to figure out which cells to simulate on + call compute_orbitmasks(Npoints, & + cospIN % cospswathsIN(5) % N_inst_swaths, & + cospIN % cospswathsIN(5) % inst_localtimes, & + cospIN % cospswathsIN(5) % inst_localtime_widths, & + cospgridIN%lat, cospgridIN%lon, & + cospgridIN%rttov_date(:,2), cospgridIN%rttov_date(:,3), & ! Time fields: month, dayofmonth + cospgridIN%rttov_time(:,1), cospgridIN%rttov_time(:,2), & ! Time fields: hour, minute + PARASOL_SWATH_MASK,N_PARASOL_SWATHED) ! Output: logical mask array + parasolIN%Npoints = N_PARASOL_SWATHED + parasolIN%Ncolumns => cospIN%Ncolumns + allocate(PARASOL_MASK_INDICES(N_PARASOL_SWATHED)) + PARASOL_MASK_INDICES = pack((/ (i, i = 1, Npoints ) /),mask = PARASOL_SWATH_MASK) + deallocate(PARASOL_SWATH_MASK) + if (parasolIN%Npoints .gt. 0) then + ! Allocate swathed arrays. + allocate(temp_tautot_S_liq(parasolIN%Npoints,cospIN%Ncolumns), & + temp_tautot_S_ice(parasolIN%Npoints,cospIN%Ncolumns)) + ! Encode step: Read only appropriate values into the new temp arrays. + temp_tautot_S_liq(:,:) = cospIN%tautot_S_liq(int(PARASOL_MASK_INDICES),:) + temp_tautot_S_ice(:,:) = cospIN%tautot_S_ice(int(PARASOL_MASK_INDICES),:) + + parasolIN%Nlevels => cospIN%Nlevels + parasolIN%Nrefl => cospIN%Nrefl + parasolIN%tautot_S_liq => temp_tautot_S_liq + parasolIN%tautot_S_ice => temp_tautot_S_ice + endif + else + parasolIN%Npoints = Npoints + parasolIN%Nlevels => cospIN%Nlevels + parasolIN%Nrefl => cospIN%Nrefl + parasolIN%tautot_S_liq => cospIN%tautot_S_liq + parasolIN%tautot_S_ice => cospIN%tautot_S_ice + end if + + END SUBROUTINE COSP_PARASOL_MASK + + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + ! SUBROUTINE COSP_PARASOL_CLEAN + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + SUBROUTINE COSP_PARASOL_MASK_CLEAN() + ! Deallocate temporary arrays + if (allocated(temp_tautot_S_liq)) deallocate(temp_tautot_S_liq) + if (allocated(temp_tautot_S_ice)) deallocate(temp_tautot_S_ice) + + END SUBROUTINE COSP_PARASOL_MASK_CLEAN + !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! END MODULE !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/simulator/cosp_rttov_interfaceSTUB.F90 b/src/simulator/cosp_rttov_interfaceSTUB.F90 index ce93b34724..a6223b0ba6 100644 --- a/src/simulator/cosp_rttov_interfaceSTUB.F90 +++ b/src/simulator/cosp_rttov_interfaceSTUB.F90 @@ -29,71 +29,15 @@ ! History ! May 2015 - D. Swales - Original version ! Apr 2015 - D. Swales - Modified for RTTOVv11.3 +! Jun 2025 - J.K. Shaw - Added RTTOVv13.2 integration and swathing. rttov_cfg moved to cosp_rttov_util.F90 ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MODULE MOD_COSP_RTTOV_INTERFACE - USE COSP_KINDS, ONLY: wp - USE MOD_COSP_RTTOV, ONLY: rttov_IN + USE COSP_KINDS, ONLY: wp + USE MOD_COSP_RTTOV, ONLY: rttov_IN + USE MOD_COSP_RTTOV_UTIL, ONLY: rttov_cfg, rttov_output IMPLICIT NONE - ! DDT for each instrument being simulated. Values to be assigned during the cosp_rttov_init subroutine - type rttov_cfg - logical :: & - Lrttov_bt, & - Lrttov_rad, & - Lrttov_refl, & - Lrttov_cld, & - Lrttov_aer, & - Lrttov_pc - character(len=256) :: & - rttov_srcDir, & - rttov_coefDir, & - OD_coef_filepath, & - aer_coef_filepath, & - cld_coef_filepath, & - PC_coef_filepath - integer :: & - nchanprof, & - rttov_direct_nthreads, & - nchan_out, & - nchannels_rec, & - rttov_Nlocaltime - real(wp) :: & - CO2_mr, & - CH4_mr, & - CO_mr, & - N2O_mr, & - SO2_mr, & - ZenAng - integer,allocatable :: & - iChannel(:), & ! Requested channel indices - iChannel_out(:) ! Passing out the channel indices (actual output channels) - real(kind=wp),allocatable :: & - emisChannel(:), & ! RTTOV channel emissivity - reflChannel(:), & ! RTTOV channel reflectivity - rttov_localtime(:), & ! RTTOV localtime - rttov_localtime_width(:) - logical, allocatable :: & - swath_mask(:) - end type rttov_cfg - - type rttov_output - integer :: & - nchan_out - integer,pointer :: & - channel_indices(:) - real(wp),pointer :: & - bt_total(:,:), & - bt_clear(:,:), & - rad_total(:,:), & - rad_clear(:,:), & - rad_cloudy(:,:), & - refl_total(:,:), & - refl_clear(:,:), & - bt_total_pc(:,:), & - rad_total_pc(:,:) - end type rttov_output - CONTAINS !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -168,7 +112,6 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,error, print*,'Running COSP_RTTOV_SIMULATE from STUB files.', & 'To run RTTOV, compile COSP after setting environmental variable "RTTOV"' - ! How do I want the interface to function? How should it to be consistent with the rest of COSP? END SUBROUTINE COSP_RTTOV_SIMULATE diff --git a/src/simulator/cosp_rttov_interface_v13.F90 b/src/simulator/cosp_rttov_interface_v13.F90 index 0c90b1863a..8e5e3b5556 100644 --- a/src/simulator/cosp_rttov_interface_v13.F90 +++ b/src/simulator/cosp_rttov_interface_v13.F90 @@ -29,13 +29,13 @@ ! History ! May 2015 - D. Swales - Original version ! Apr 2015 - D. Swales - Modified for RTTOVv11.3 -! Aug 2023 - J. Shaw - Modified for RTTOV v13 +! Jun 2025 - J.K. Shaw - Modified for RTTOV v13 ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% MODULE MOD_COSP_RTTOV_INTERFACE - USE COSP_KINDS, ONLY: wp + USE COSP_KINDS, ONLY: wp + use MOD_COSP_RTTOV, ONLY: rttov_in + USE MOD_COSP_RTTOV_UTIL, ONLY: rttov_cfg, rttov_output - use mod_cosp_rttov, only: rttov_in - ! rttov_const contains useful RTTOV constants USE rttov_const, ONLY : & errorstatus_success, & @@ -62,94 +62,10 @@ MODULE MOD_COSP_RTTOV_INTERFACE IMPLICIT NONE -! #include "rttov_scatt.interface" -! #include "rttov_parallel_scatt.interface" -! #include "rttov_read_scattcoeffs.interface" -! #include "rttov_dealloc_scattcoeffs.interface" -! #include "rttov_scatt_setupindex.interface" - #include "rttov_read_coefs.interface" #include "rttov_user_options_checkinput.interface" #include "rttov_print_opts.interface" - - ! RTTOV variables/structures. - !==================== - ! DDT for each instrument being simulated. Values to be assigned during the cosp_rttov_init subroutine - type rttov_cfg - logical(KIND=jplm) :: & - Lrttov_bt, & - Lrttov_rad, & - Lrttov_refl, & - Lrttov_cld, & - Lrttov_aer, & - Lrttov_pc, & - Lrttov_solar, & - Lrttov_mwscatt, & - user_tracegas_input - character(len=256) :: & - rttov_srcDir, & - rttov_coefDir, & - OD_coef_filepath, & - aer_coef_filepath, & - cld_coef_filepath, & - PC_coef_filepath - integer(KIND=jpim) :: & - nchanprof, & - rttov_direct_nthreads, & - nchan_out, & - nchannels_rec, & - rttov_Nlocaltime, & - gas_units, & - clw_scheme, & - ice_scheme, & - icede_param, & - rttov_extendatmos, & - nprof - real(wp) :: & - CO2_mr, & - CH4_mr, & - CO_mr, & - N2O_mr, & - SO2_mr, & - ZenAng - integer(kind=jpim), allocatable :: & - iChannel(:), & ! Requested channel indices - iChannel_out(:) ! Passing out the channel indices (actual output channels) - real(kind=jprb), allocatable :: & - emisChannel(:), & ! RTTOV channel emissivity - reflChannel(:), & ! RTTOV channel reflectivity - wavenumChannel(:), & ! RTTOV channel wavenumber - rttov_localtime(:), & - rttov_localtime_width(:) - type(rttov_options) :: & - opts ! RTTOV options structure - type(rttov_options_scatt) :: & - opts_scatt - type(rttov_coefs) :: & - coefs ! RTTOV coefficients structure - type(rttov_pccomp) :: & - pccomp - logical(KIND=jplm), allocatable :: & - swath_mask(:) - end type rttov_cfg - - type rttov_output - integer :: & - nchan_out - integer,pointer :: & - channel_indices(:) => null() - real(wp),pointer :: & - bt_total(:,:) => null(), & - bt_clear(:,:) => null(), & - rad_total(:,:) => null(), & - rad_clear(:,:) => null(), & - rad_cloudy(:,:) => null(), & - refl_total(:,:) => null(), & - refl_clear(:,:) => null(), & - bt_total_pc(:,:) => null(), & - rad_total_pc(:,:) => null() - end type rttov_output CONTAINS @@ -201,7 +117,7 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & Nlevels character(len=256),intent(in) :: & namelist_filepath ! Array of paths to RTTOV instrument namelists - type(rttov_cfg),intent(out) :: & ! intent(out)? + type(rttov_cfg),intent(out) :: & rttov_config integer,intent(in),Optional :: unitn ! Used for io limits @@ -363,7 +279,6 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & endif ! Set swath arrays correctly. - ! if (verbose) print*,"allocating rttov_config%rttov_localtime and rttov_config%rttov_localtime_width" allocate(rttov_config%rttov_localtime(rttov_Nlocaltime),rttov_config%rttov_localtime_width(rttov_Nlocaltime)) rttov_config%rttov_Nlocaltime = rttov_Nlocaltime rttov_config%rttov_localtime(:) = rttov_localtime(1:rttov_Nlocaltime) @@ -522,7 +437,6 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & endif - ! JKS To-do: include opts_scatt settings (user guide pg 161) if (rttov_config % Lrttov_mwscatt) then rttov_config % opts_scatt % config % do_checkinput = .true. rttov_config % opts_scatt % config % apply_reg_limits = .false. @@ -586,7 +500,6 @@ SUBROUTINE COSP_RTTOV_INIT_S(Nlevels,namelist_filepath, & !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Handle different radiance reconstruction options - ! JKS - I need to set these two separate variables here? Can one be set later? if (nchannels_rec < 0) then print*,'The namelist variable "nchannels_rec" is negative, rttov_direct call will fail. Exiting.' errorstatus = errorstatus_fatal @@ -738,7 +651,6 @@ SUBROUTINE COSP_RTTOV_SIMULATE(rttovIN,rttovConfig,error, rttovConfig % rttov_localtime_width, & rttovConfig % swath_mask, & debug) - ! rttovConfig % swath_mask(:) = .true. ! JKS - for now, just set everything to true rttovConfig % nprof = count(rttovConfig % swath_mask) if (rttovConfig % nprof .gt. 0) then ! Skip calculations if all values are swathed out @@ -808,7 +720,6 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig, ! Run each step for running RTTOV from mod_cosp_rttov (and time them) call cpu_time(driver_time(1)) - !if (verbose) print*,'Beginning "cosp_rttov_allocate".' call cosp_rttov_allocate(rttovIN, & rttovConfig % nChannels_rec, & rttovConfig % opts, & @@ -829,7 +740,6 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig, verbose) call cpu_time(driver_time(2)) - !if (verbose) print*,'Beginning "cosp_rttov_construct_profiles".' call cosp_rttov_construct_profiles(rttovIN, & profiles, & rttovConfig % Lrttov_cld, & @@ -859,7 +769,6 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig, call cpu_time(driver_time(3)) - !if (verbose) print*,'Beginning "cosp_rttov_setup_emissivity_reflectance".' if (associated(rttovIN % emis_grey)) then call cosp_rttov_setup_emissivity_reflectance(calcemis, & emissivity, & @@ -874,7 +783,6 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig, end if call cpu_time(driver_time(4)) - ! if (verbose) print*,'Beginning "cosp_rttov_call_direct".' call cosp_rttov_call_direct(rttovConfig % rttov_direct_nthreads, & rttovConfig % opts, & profiles, & @@ -890,7 +798,6 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig, call cpu_time(driver_time(5)) - !if (verbose) print*,'Beginning "cosp_rttov_save_output".' call cosp_rttov_save_output(rttovIN % nPoints, & rttovConfig % nchan_out, & rttovConfig % swath_mask, & @@ -905,7 +812,6 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig, refl_total,refl_clear) call cpu_time(driver_time(6)) - !if (verbose) print*,'Beginning "cosp_rttov_deallocate_profiles".' call cosp_rttov_deallocate_profiles(rttovConfig % nprof, & rttovConfig % nchanprof, & rttovIN % nLevels, & @@ -920,14 +826,6 @@ SUBROUTINE COSP_REG_RTTOV_SIMULATE(rttovIN,rttovConfig, calcrefl, & reflectance) call cpu_time(driver_time(7)) - -! print*,'Time to run "cosp_rttov_allocate": ', driver_time(2)-driver_time(1) -! print*,'Time to run "cosp_rttov_construct_profiles": ', driver_time(3)-driver_time(2) -! print*,'Time to run "cosp_rttov_setup_emissivity_reflectance": ',driver_time(4)-driver_time(3) -! print*,'Time to run "cosp_rttov_call_direct": ', driver_time(5)-driver_time(4) -! print*,'Time to run "cosp_rttov_save_output": ', driver_time(6)-driver_time(5) -! print*,'Time to run "cosp_rttov_deallocate_profiles": ', driver_time(7)-driver_time(6) -! print*,'Total RTTOV run time: ',driver_time(8)-driver_time(1) END SUBROUTINE COSP_REG_RTTOV_SIMULATE @@ -973,7 +871,6 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig, ! Run each step for running RTTOV from mod_cosp_rttov (and time them) call cpu_time(driver_time(1)) - ! if (verbose) print*,'Beginning "cosp_pc_rttov_allocate".' call cosp_pc_rttov_allocate(rttovIN, & rttovConfig % PC_coef_filepath, & rttovConfig % coefs, & @@ -995,7 +892,6 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig, predictindex) call cpu_time(driver_time(2)) -! if (verbose) print*,'Beginning "cosp_rttov_construct_profiles".' call cosp_rttov_construct_profiles(rttovIN, & profiles, & rttovConfig % Lrttov_cld, & @@ -1026,7 +922,6 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig, call cosp_pc_rttov_setup_emissivity(calcemis, & emissivity) call cpu_time(driver_time(4)) -! if (verbose) print*,'Beginning "cosp_pc_rttov_call_direct".' call cosp_pc_rttov_call_direct(rttovConfig % rttov_direct_nthreads, & rttovConfig % opts, & profiles, & @@ -1041,7 +936,6 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig, rttovConfig % pccomp) call cpu_time(driver_time(5)) -! if (verbose) print*,'Beginning "cosp_pc_rttov_save_output".' call cosp_pc_rttov_save_output(rttovIN % nPoints, & rttovConfig % nchannels_rec, & rttovConfig % swath_mask, & @@ -1052,7 +946,6 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig, rad_clear) call cpu_time(driver_time(6)) -! if (verbose) print*,'Beginning "cosp_pc_rttov_deallocate_profiles".' call cosp_pc_rttov_deallocate_profiles(rttovConfig % nprof, & rttovConfig % nchanprof, & rttovIN % nlevels, & @@ -1069,13 +962,6 @@ SUBROUTINE COSP_PC_RTTOV_SIMULATE(rttovIN,rttovConfig, predictindex) call cpu_time(driver_time(7)) - -! print*,'Time to run "cosp_pc_rttov_allocate": ', driver_time(2)-driver_time(1) -! print*,'Time to run "cosp_rttov_construct_profiles": ', driver_time(3)-driver_time(2) -! print*,'Time to run "cosp_pc_rttov_setup_emissivity": ', driver_time(4)-driver_time(3) -! print*,'Time to run "cosp_pc_rttov_call_direct": ', driver_time(5)-driver_time(4) -! print*,'Time to run "cosp_pc_rttov_save_output": ', driver_time(6)-driver_time(5) -! print*,'Time to run "cosp_pc_rttov_deallocate_profiles": ', driver_time(7)-driver_time(6) END SUBROUTINE COSP_PC_RTTOV_SIMULATE diff --git a/src/simulator/quickbeam/quickbeam.F90 b/src/simulator/quickbeam/quickbeam.F90 index 640dfe8cdf..bb39c55785 100644 --- a/src/simulator/quickbeam/quickbeam.F90 +++ b/src/simulator/quickbeam/quickbeam.F90 @@ -46,6 +46,7 @@ ! Also removed called to AVINT for gas and hydrometeor attenuation and replaced with simple ! summation. (Roger Marchand) ! May 2015 - D. Swales - Modified for COSPv2.0 +! Jun 2025 - J.K. Shaw - Parameters and DDT moved to cosp_stats.F90 for interface swathing ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% module quickbeam USE COSP_KINDS, ONLY: wp @@ -55,49 +56,11 @@ module quickbeam pClass_Rain4, pClass_default, Zenonbinval, Zbinvallnd, & N_HYDRO,nCloudsatPrecipClass,cloudsat_preclvl - USE MOD_COSP_STATS, ONLY: COSP_LIDAR_ONLY_CLOUD,hist1D,COSP_CHANGE_VERTICAL_GRID + USE MOD_COSP_STATS, ONLY: COSP_LIDAR_ONLY_CLOUD,hist1D,COSP_CHANGE_VERTICAL_GRID, & + maxhclass,nRe_types,nd,mt_ntt,Re_BIN_LENGTH,Re_MAX_BIN, & + dmin,dmax,radar_cfg implicit none - integer,parameter :: & - maxhclass = 20, & ! Qucikbeam maximum number of hydrometeor classes. - nRe_types = 550, & ! Quickbeam maximum number or Re size bins allowed in N and Z_scaled look up table. - nd = 85, & ! Qucikbeam number of discrete particles used in construction DSDs. - mt_ntt = 39, & ! Quickbeam number of temperatures in mie LUT. - Re_BIN_LENGTH = 10, & ! Quickbeam minimum Re interval in scale LUTs - Re_MAX_BIN = 250 ! Quickbeam maximum Re interval in scale LUTs - real(wp),parameter :: & - dmin = 0.1, & ! Quickbeam minimum size of discrete particle - dmax = 10000. ! Quickbeam maximum size of discrete particle - - !djs logical :: radar_at_layer_one ! If true radar is assume to be at the edge - ! of the first layer, if the first layer is the - ! surface than a ground-based radar. If the - ! first layer is the top-of-atmosphere, then - ! a space borne radar. - - ! ############################################################################################## - type radar_cfg - ! Radar properties - real(wp) :: freq,k2 - integer :: nhclass ! Number of hydrometeor classes in use - integer :: use_gas_abs, do_ray - logical :: radar_at_layer_one ! If true radar is assume to be at the edge - ! of the first layer, if the first layer is the - ! surface than a ground-based radar. If the - ! first layer is the top-of-atmosphere, then - ! a space borne radar. - - ! Variables used to store Z scale factors - character(len=240) :: scale_LUT_file_name - logical :: load_scale_LUTs, update_scale_LUTs - logical, dimension(maxhclass,nRe_types) :: N_scale_flag - logical, dimension(maxhclass,mt_ntt,nRe_types) :: Z_scale_flag,Z_scale_added_flag - real(wp),dimension(maxhclass,mt_ntt,nRe_types) :: Ze_scaled,Zr_scaled,kr_scaled - real(wp),dimension(maxhclass,nd,nRe_types) :: fc, rho_eff - real(wp),dimension(Re_MAX_BIN) :: base_list,step_list - - end type radar_cfg - contains ! ###################################################################################### ! SUBROUTINE quickbeam_subcolumn diff --git a/src/simulator/rttov/cosp_rttov_v13.F90 b/src/simulator/rttov/cosp_rttov_v13.F90 index 40f0279e99..58d92f7abe 100644 --- a/src/simulator/rttov/cosp_rttov_v13.F90 +++ b/src/simulator/rttov/cosp_rttov_v13.F90 @@ -270,8 +270,8 @@ subroutine cosp_rttov_allocate(rttovIN,inst_nChannels_rec,inst_opts,inst_coefs, inst_opts type(rttov_coefs),intent(in) :: & inst_coefs - type(rttov_profile),allocatable,target,intent(out) :: & - inst_profiles(:) + type(rttov_profile),pointer,intent(out) :: & + inst_profiles(:) integer(kind=jpim),dimension(inst_nChannels_rec),intent(in) :: & inst_iChannel type(rttov_chanprof),pointer,intent(inout) :: & @@ -387,8 +387,8 @@ subroutine cosp_pc_rttov_allocate(rttovIN,inst_PC_coef_filepath, inst_coefs type(rttov_options),intent(inout) :: & inst_opts - type(rttov_profile),allocatable,target,intent(out) :: & - inst_profiles(:) + type(rttov_profile),pointer,intent(out) :: & + inst_profiles(:) integer(kind=jpim),intent(inout) :: & inst_nchannels_rec integer(kind=jpim),intent(in),dimension(inst_nchannels_rec) :: & @@ -553,7 +553,7 @@ subroutine cosp_rttov_construct_profiles(rttovIN, & type(rttov_in),intent(in) :: & rttovIN - type(rttov_profile),allocatable,target,intent(inout) :: & + type(rttov_profile),target,intent(inout) :: & inst_profiles(:) logical,intent(in) :: & Lrttov_cld, & @@ -1086,7 +1086,7 @@ subroutine cosp_rttov_call_direct(inst_nthreads, & inst_nthreads type(rttov_options),intent(in) :: & inst_opts - type(rttov_profile),allocatable,target,intent(in) :: & + type(rttov_profile),target,intent(in) :: & inst_profiles(:) type(rttov_coefs),intent(in) :: & inst_coefs @@ -1185,7 +1185,7 @@ subroutine cosp_pc_rttov_call_direct(inst_nthreads, & inst_nthreads type(rttov_options),intent(in) :: & inst_opts - type(rttov_profile),allocatable,target,intent(in) :: & + type(rttov_profile),target,intent(in) :: & inst_profiles(:) type(rttov_coefs),intent(in) :: & inst_coefs @@ -1451,7 +1451,7 @@ subroutine cosp_rttov_deallocate_profiles(inst_nprof, & nLevels type(rttov_options),intent(in) :: & inst_opts - type(rttov_profile),allocatable,target,intent(in) :: & + type(rttov_profile),pointer,intent(in) :: & inst_profiles(:) type(rttov_coefs),intent(in) :: & inst_coefs @@ -1521,7 +1521,7 @@ subroutine cosp_pc_rttov_deallocate_profiles(inst_nprof, & inst_nChannels_rec type(rttov_options),intent(in) :: & inst_opts - type(rttov_profile),allocatable,target,intent(in) :: & + type(rttov_profile),pointer,intent(in) :: & inst_profiles(:) type(rttov_coefs),intent(in) :: & inst_coefs diff --git a/subsample_and_optics_example/optics/quickbeam_optics/quickbeam_optics.F90 b/subsample_and_optics_example/optics/quickbeam_optics/quickbeam_optics.F90 index 62f3a3f2a7..dd39c73b3a 100644 --- a/subsample_and_optics_example/optics/quickbeam_optics/quickbeam_optics.F90 +++ b/subsample_and_optics_example/optics/quickbeam_optics/quickbeam_optics.F90 @@ -37,10 +37,11 @@ module mod_quickbeam_optics USE optics_lib, ONLY: m_wat,m_ice,MieInt USE cosp_math_constants, ONLY: pi USE cosp_phys_constants, ONLY: rhoice - use quickbeam, ONLY: radar_cfg,dmin,dmax,Re_BIN_LENGTH, & + use quickbeam, ONLY: dmin,dmax,Re_BIN_LENGTH, & Re_MAX_BIN,nRe_types,nd,maxhclass use mod_cosp_config, ONLY: N_HYDRO use mod_cosp_error, ONLY: errorMessage + use mod_cosp_stats, ONLY: radar_cfg implicit none ! Derived type for particle size distribution From c9e169f0d6556526e87b2f8a15d82f22e9fcc9a3 Mon Sep 17 00:00:00 2001 From: dustinswales Date: Tue, 1 Jul 2025 10:44:07 -0600 Subject: [PATCH 137/159] Synced w/ master --- driver/src/cosp2_test.F90 | 4 +--- src/simulator/cosp_cloudsat_interface.F90 | 11 ----------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 41d10d6feb..18f46f2359 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -1228,8 +1228,6 @@ subroutine construct_cospIN(npoints,ncolumns,nlevels,ninst_rttov,y,emis_grey) y%ss_alb(npoints, ncolumns,nlevels)) endif - allocate (y%rcfg_cloudsat) - end subroutine construct_cospIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1416,7 +1414,7 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& Nlvgrid, & ! Number of levels in L3 stats computation Ninst_rttov - type(rttov_cfg), dimension(Ninst_rttov),intent(in) :: & + type(rttov_cfg), dimension(:),intent(in) :: & rttov_configs ! Outputs diff --git a/src/simulator/cosp_cloudsat_interface.F90 b/src/simulator/cosp_cloudsat_interface.F90 index 60d3d12275..5ed458ebcf 100644 --- a/src/simulator/cosp_cloudsat_interface.F90 +++ b/src/simulator/cosp_cloudsat_interface.F90 @@ -111,17 +111,6 @@ SUBROUTINE COSP_CLOUDSAT_INIT(radar_freq,k2,use_gas_abs,do_ray,undef,nhydro, & trim(cloudsat_micro_scheme) ! Initialize for NEW radar-configurarion derived type (radar_cfg) - allocate(rcfg%N_scale_flag(maxhclass,nRe_types)) - allocate(rcfg%Z_scale_flag(maxhclass,mt_ntt,nRe_types)) - allocate(rcfg%Z_scale_added_flag(maxhclass,mt_ntt,nRe_types)) - allocate(rcfg%Ze_scaled(maxhclass,mt_ntt,nRe_types)) - allocate(rcfg%Zr_scaled(maxhclass,mt_ntt,nRe_types)) - allocate(rcfg%kr_scaled(maxhclass,mt_ntt,nRe_types)) - allocate(rcfg%fc(maxhclass,nd,nRe_types)) - allocate(rcfg%rho_eff(maxhclass,nd,nRe_types)) - allocate(rcfg%base_list(Re_MAX_BIN)) - allocate(rcfg%step_list(Re_MAX_BIN)) - rcfg%freq = radar_freq rcfg%k2 = k2 rcfg%use_gas_abs = use_gas_abs From cd281b1fb68a0542eb0a07958bdd4aa84a79dd14 Mon Sep 17 00:00:00 2001 From: dustinswales Date: Tue, 1 Jul 2025 11:01:17 -0600 Subject: [PATCH 138/159] A few tiny bugs. Passing offline RTs --- src/cosp.F90 | 10 ++++++++-- src/simulator/cosp_parasol_interface.F90 | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cosp.F90 b/src/cosp.F90 index 76eff10c1b..46004c4b72 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -2119,8 +2119,14 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) endif !! use_vgrid or not ! Store, when necessary - cospOUT%lidar_only_freq_cloud(ij+int(CSCAL_MASK_INDICES(:))-1,:) = lidar_only_freq_cloud(:,:) - + if (associated(cospOUT%lidar_only_freq_cloud)) then + if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays + cospOUT%lidar_only_freq_cloud(ij+int(CSCAL_MASK_INDICES(:))-1,:) = lidar_only_freq_cloud(:,:) + else + cospOUT%lidar_only_freq_cloud(ij:ik,:) = lidar_only_freq_cloud + endif + endif + if (cospIN % cospswathsIN(3) % N_inst_swaths .gt. 0) then ! Trigger use of swathed arrays for CSCAL if (cospIN % cospswathsIN(6) % N_inst_swaths .gt. 0) then ! If MODIS is also swathed then use the joint mask MODIS_CSCAL_MASK_INDICES for setting R_UNDEF if ( associated(cospOUT%cfodd_ntotal) ) then diff --git a/src/simulator/cosp_parasol_interface.F90 b/src/simulator/cosp_parasol_interface.F90 index 18a934dfb1..dde889f359 100644 --- a/src/simulator/cosp_parasol_interface.F90 +++ b/src/simulator/cosp_parasol_interface.F90 @@ -143,6 +143,7 @@ SUBROUTINE COSP_PARASOL_MASK(cospIN,cospgridIN,Npoints,parasolIN,PARASOL_MASK_IN endif else parasolIN%Npoints = Npoints + parasolIN%Ncolumns => cospIN%Ncolumns parasolIN%Nlevels => cospIN%Nlevels parasolIN%Nrefl => cospIN%Nrefl parasolIN%tautot_S_liq => cospIN%tautot_S_liq From a1ea165fbd98f579609687de7bfd6a4664e8ff70 Mon Sep 17 00:00:00 2001 From: dustinswales Date: Tue, 1 Jul 2025 11:11:50 -0600 Subject: [PATCH 139/159] Add Macro to Makefile --- build/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build/Makefile b/build/Makefile index 7a41ae2a31..813752bf22 100644 --- a/build/Makefile +++ b/build/Makefile @@ -11,8 +11,10 @@ MODIS_PATH = $(SIM_PATH)/MODIS_simulator PARASOL_PATH = $(SIM_PATH)/parasol # Makefile.rttov needed to define the following: -# RTTOVDIR, FFLAGS, LIBDIR, LIBS, LLIBS, LDFLAGS_NETCDF, LDFLAGS_HDF5, LDFLAGS_ARCH +# RTTOVDIR, FFLAGS, LIBDIR, LIBS, LLIBS, LDFLAGS_NETCDF, LDFLAGS_HDF5, LDFLAGS_ARCH +ifdef RTTOV include Makefile.rttov +endif VPATH = $(SRC_PATH):$(HOOKS):$(SIM_PATH):$(RT_PATH):$(RS_PATH):$(CS_PATH):$(ISCCP_PATH):$(MISR_PATH):$(MODIS_PATH):$(PARASOL_PATH) From 82f7f4c9aae2003938fe1a3b85ed90bfd62d10e0 Mon Sep 17 00:00:00 2001 From: dustinswales Date: Tue, 1 Jul 2025 11:25:42 -0600 Subject: [PATCH 140/159] Changes to rttov options in driver --- driver/src/cosp2_test.F90 | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 18f46f2359..93c3a61d7b 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -143,7 +143,6 @@ program cosp2_test overlap, & ! Overlap type: 1=max, 2=rand, 3=max/rand isccp_topheight, & ! ISCCP cloud top height isccp_topheight_direction ! ISCCP cloud top height direction - integer :: rttov_Ninstruments = 0 real(wp) :: & ! cloudsat_radar_freq, & ! CloudSat radar frequency (GHz) cloudsat_k2 ! |K|^2, -1=use frequency dependent default @@ -161,12 +160,17 @@ program cosp2_test character(len=512) :: & dinput ! Directory where the input files are located character(len=600) :: & - fileIN ! dinput+finput + fileIN ! dinput+finput + + ! RTTOV + integer :: rttov_Ninstruments = 0 character(len=256), dimension(50) :: & ! Arbitrary limit of 50 should be fine. rttov_instrument_namelists ! Input of paths to RTTOV instrument namelists character(len=256), allocatable :: & rttov_instrument_namelists_final(:) ! Array of paths to RTTOV instrument namelists - + logical :: rttov_verbose = .false. + logical :: Lrttov_run = .false. + ! Inputs for orbit swathing integer :: N_SWATHS_ISCCP = 0 ! Number of ISCCP swaths integer :: N_SWATHS_MISR = 0 ! Number of MISR swaths @@ -192,7 +196,7 @@ program cosp2_test npoints_it, ncolumns, nlevels, use_vgrid, Nlvgrid, csat_vgrid, dinput, finput, & foutput, cloudsat_radar_freq, surface_radar, cloudsat_use_gas_abs,cloudsat_do_ray,& cloudsat_k2, cloudsat_micro_scheme, lidar_ice_type, use_precipitation_fluxes, & - rttov_Ninstruments, rttov_instrument_namelists, rttov_verbose, & + Lrttov_run, rttov_Ninstruments, rttov_instrument_namelists, rttov_verbose, & N_SWATHS_ISCCP, SWATH_LOCALTIMES_ISCCP, SWATH_WIDTHS_ISCCP, N_SWATHS_MISR, & SWATH_LOCALTIMES_MISR, SWATH_WIDTHS_MISR, N_SWATHS_MODIS, SWATH_LOCALTIMES_MODIS, & SWATH_WIDTHS_MODIS, N_SWATHS_PARASOL, SWATH_LOCALTIMES_PARASOL, & @@ -222,8 +226,6 @@ program cosp2_test Lptradarflag4,Lptradarflag5,Lptradarflag6,Lptradarflag7,Lptradarflag8, & Lptradarflag9,Lradarpia, & Lwr_occfreq,Lcfodd - logical :: Lrttov_run = .false. - logical :: rttov_verbose = .false. namelist/COSP_OUTPUT/Lcfaddbze94,Ldbze94,Latb532,LcfadLidarsr532,Lclcalipso, & Lclhcalipso,Lcllcalipso,Lclmcalipso,Lcltcalipso,LparasolRefl, & Lclcalipsoliq,Lclcalipsoice,Lclcalipsoun,Lclcalipsotmp, & @@ -246,7 +248,6 @@ program cosp2_test Lclmmodis,Lcllmodis,Ltautmodis,Ltauwmodis,Ltauimodis, & Ltautlogmodis,Ltauwlogmodis,Ltauilogmodis,Lreffclwmodis, & Lreffclimodis,Lpctmodis,Llwpmodis,Liwpmodis,Lclmodis, & - Lrttov_run, & Lptradarflag0,Lptradarflag1,Lptradarflag2,Lptradarflag3, & Lptradarflag4,Lptradarflag5,Lptradarflag6,Lptradarflag7, & Lptradarflag8,Lptradarflag9,Lradarpia, & @@ -444,12 +445,12 @@ program cosp2_test if (Lparasolrefl) Lparasol = .true. ! JKS - This will need to be revamped. Each instrument needs these flags - if (Lrttov_run .and. (rttov_Ninstruments .gt. 0)) Lrttov = .true. - if ((Lrttov_run) .and. (rttov_Ninstruments .le. 0)) then + if (Lrttov_run .and. (rttov_Ninstruments .gt. 0)) Lrttov = .true. + if (Lrttov_run .and. (rttov_Ninstruments .le. 0)) then print*,'Lrttov_run is "true" but rttov_Ninstruments < 1. COSP-RTTOV will not run.' Lrttov = .false. endif - if ((Lrttov_run .eq. .false.) .and. (rttov_Ninstruments .gt. 0)) then + if ((.not. Lrttov_run) .and. (rttov_Ninstruments .gt. 0)) then print*,'rttov_Ninstruments > 0 but Lrttov_run is "false". COSP-RTTOV will not run.' Lrttov = .false. endif From a5bf6bb510178110355efb99c245bc3cc5c200dd Mon Sep 17 00:00:00 2001 From: dustinswales Date: Tue, 1 Jul 2025 11:36:37 -0600 Subject: [PATCH 141/159] Changes to rttov options. Again... --- driver/src/cosp2_test.F90 | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 93c3a61d7b..9de61a2e39 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -169,7 +169,6 @@ program cosp2_test character(len=256), allocatable :: & rttov_instrument_namelists_final(:) ! Array of paths to RTTOV instrument namelists logical :: rttov_verbose = .false. - logical :: Lrttov_run = .false. ! Inputs for orbit swathing integer :: N_SWATHS_ISCCP = 0 ! Number of ISCCP swaths @@ -196,7 +195,7 @@ program cosp2_test npoints_it, ncolumns, nlevels, use_vgrid, Nlvgrid, csat_vgrid, dinput, finput, & foutput, cloudsat_radar_freq, surface_radar, cloudsat_use_gas_abs,cloudsat_do_ray,& cloudsat_k2, cloudsat_micro_scheme, lidar_ice_type, use_precipitation_fluxes, & - Lrttov_run, rttov_Ninstruments, rttov_instrument_namelists, rttov_verbose, & + rttov_Ninstruments, rttov_instrument_namelists, rttov_verbose, & N_SWATHS_ISCCP, SWATH_LOCALTIMES_ISCCP, SWATH_WIDTHS_ISCCP, N_SWATHS_MISR, & SWATH_LOCALTIMES_MISR, SWATH_WIDTHS_MISR, N_SWATHS_MODIS, SWATH_LOCALTIMES_MODIS, & SWATH_WIDTHS_MODIS, N_SWATHS_PARASOL, SWATH_LOCALTIMES_PARASOL, & @@ -343,7 +342,6 @@ program cosp2_test ! Jonah namelist checking area print*,'rttov_verbose: ',rttov_verbose - print*,'Lrttov_run: ',Lrttov_run print*,'rttov_Ninstruments: ',rttov_Ninstruments ! Shift the namelists read in into a shorter array for cosp_init: @@ -445,13 +443,13 @@ program cosp2_test if (Lparasolrefl) Lparasol = .true. ! JKS - This will need to be revamped. Each instrument needs these flags - if (Lrttov_run .and. (rttov_Ninstruments .gt. 0)) Lrttov = .true. - if (Lrttov_run .and. (rttov_Ninstruments .le. 0)) then - print*,'Lrttov_run is "true" but rttov_Ninstruments < 1. COSP-RTTOV will not run.' + if (Lrttov .and. (rttov_Ninstruments .gt. 0)) Lrttov = .true. + if (Lrttov .and. (rttov_Ninstruments .le. 0)) then + print*,'Lrttov is "true" but rttov_Ninstruments < 1. COSP-RTTOV will not run.' Lrttov = .false. endif - if ((.not. Lrttov_run) .and. (rttov_Ninstruments .gt. 0)) then - print*,'rttov_Ninstruments > 0 but Lrttov_run is "false". COSP-RTTOV will not run.' + if ((.not. Lrttov) .and. (rttov_Ninstruments .gt. 0)) then + print*,'rttov_Ninstruments > 0 but Lrttov is "false". COSP-RTTOV will not run.' Lrttov = .false. endif From f530c0986b59eedac1be0e3ec9ba420026c2c804 Mon Sep 17 00:00:00 2001 From: dustinswales Date: Tue, 1 Jul 2025 11:41:22 -0600 Subject: [PATCH 142/159] Update global snapshot nml to turn off RTTOV --- driver/run/cosp2_input_nl.um_global.txt | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/driver/run/cosp2_input_nl.um_global.txt b/driver/run/cosp2_input_nl.um_global.txt index 44c57f9226..ff5ba86407 100644 --- a/driver/run/cosp2_input_nl.um_global.txt +++ b/driver/run/cosp2_input_nl.um_global.txt @@ -82,15 +82,15 @@ !---------------------------------------------------------------------------------- !-------------- RTTOV inputs !---------------------------------------------------------------------------------- - rttov_Platform=1, ! satellite platform - rttov_Satellite=15, ! satellite - rttov_Instrument=5, ! instrument - rttov_Nchannels=3, ! Number of channels to be computed - rttov_Channels=1,2,3, ! Channel numbers (please be sure that you supply Nchannels) - rttov_Surfem=0.0,0.0,0.0, ! Surface emissivity (please be sure that you supply Nchannels) - rttov_ZenAng=50.0, ! Satellite Zenith Angle - CO2=5.241e-04, ! Mixing ratios of trace gases - CH4=9.139e-07, - N2O=4.665e-07, - CO=2.098e-07 + !rttov_Platform=1, ! satellite platform + !rttov_Satellite=15, ! satellite + !rttov_Instrument=5, ! instrument + !rttov_Nchannels=3, ! Number of channels to be computed + !rttov_Channels=1,2,3, ! Channel numbers (please be sure that you supply Nchannels) + !rttov_Surfem=0.0,0.0,0.0, ! Surface emissivity (please be sure that you supply Nchannels) + !rttov_ZenAng=50.0, ! Satellite Zenith Angle + !CO2=5.241e-04, ! Mixing ratios of trace gases + !CH4=9.139e-07, + !N2O=4.665e-07, + !CO=2.098e-07 / From 26995b32a7f58328d5cdf9316430eae9a6bae83a Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Tue, 1 Jul 2025 16:48:51 -0600 Subject: [PATCH 143/159] Test if error is dependent on chunk size --- driver/run/cosp2_input_nl.um_global.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver/run/cosp2_input_nl.um_global.txt b/driver/run/cosp2_input_nl.um_global.txt index ff5ba86407..4d50d131fb 100644 --- a/driver/run/cosp2_input_nl.um_global.txt +++ b/driver/run/cosp2_input_nl.um_global.txt @@ -26,7 +26,7 @@ ! Namelist that sets up the main COSP options &COSP_INPUT NPOINTS=1728, ! 1728,6912 - NPOINTS_IT=1000,! Max number of gridpoints to be processed in one iteration + NPOINTS_IT=50,! Max number of gridpoints to be processed in one iteration NCOLUMNS=20, ! Number of subcolumns NLEVELS=54, ! Number of model levels USE_VGRID=.true., ! Use fixed vertical grid for outputs? (if .true. then you need to define number of levels with Nlr) From 1dd9eb58ad6c2f637939db721319d86965553bc1 Mon Sep 17 00:00:00 2001 From: dustinswales Date: Wed, 2 Jul 2025 10:57:21 -0600 Subject: [PATCH 144/159] Bugfix for MODIS sunlit pressure array --- src/cosp.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cosp.F90 b/src/cosp.F90 index 46004c4b72..0eac926cf7 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -933,7 +933,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Call simulator one column at a time on sunlit columns do i = 1, modisIN%nSunlit ! Just run on the sunlit columns, even though the modisIN DDT includes everything orbit swathed call modis_subcolumn(modisIN%Ncolumns,modisIN%Nlevels, & - modisIN%pres(int(modisIN%sunlit(i)),:), & + modisIN%pres(i,:), & modisIN%tau(int(modisIN%sunlit(i)),:,:), & modisIN%liqFrac(int(modisIN%sunlit(i)),:,:), & modisIN%g(int(modisIN%sunlit(i)),:,:), & From 0893c64af33f60f9a61479b80ab194eb1cac6cb1 Mon Sep 17 00:00:00 2001 From: dustinswales Date: Wed, 2 Jul 2025 11:13:48 -0600 Subject: [PATCH 145/159] Revert chunk size change --- driver/run/cosp2_input_nl.um_global.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver/run/cosp2_input_nl.um_global.txt b/driver/run/cosp2_input_nl.um_global.txt index 4d50d131fb..ff5ba86407 100644 --- a/driver/run/cosp2_input_nl.um_global.txt +++ b/driver/run/cosp2_input_nl.um_global.txt @@ -26,7 +26,7 @@ ! Namelist that sets up the main COSP options &COSP_INPUT NPOINTS=1728, ! 1728,6912 - NPOINTS_IT=50,! Max number of gridpoints to be processed in one iteration + NPOINTS_IT=1000,! Max number of gridpoints to be processed in one iteration NCOLUMNS=20, ! Number of subcolumns NLEVELS=54, ! Number of model levels USE_VGRID=.true., ! Use fixed vertical grid for outputs? (if .true. then you need to define number of levels with Nlr) From 5d85ed51e8b633bcbea22fd6b9539aedbc2b4afc Mon Sep 17 00:00:00 2001 From: dustinswales Date: Wed, 2 Jul 2025 11:31:34 -0600 Subject: [PATCH 146/159] Revert change in modis pressure subsetting --- src/cosp.F90 | 2 +- src/simulator/cosp_modis_interface.F90 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cosp.F90 b/src/cosp.F90 index 0eac926cf7..46004c4b72 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -933,7 +933,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Call simulator one column at a time on sunlit columns do i = 1, modisIN%nSunlit ! Just run on the sunlit columns, even though the modisIN DDT includes everything orbit swathed call modis_subcolumn(modisIN%Ncolumns,modisIN%Nlevels, & - modisIN%pres(i,:), & + modisIN%pres(int(modisIN%sunlit(i)),:), & modisIN%tau(int(modisIN%sunlit(i)),:,:), & modisIN%liqFrac(int(modisIN%sunlit(i)),:,:), & modisIN%g(int(modisIN%sunlit(i)),:,:), & diff --git a/src/simulator/cosp_modis_interface.F90 b/src/simulator/cosp_modis_interface.F90 index 90d1ce9d01..039d3f0205 100644 --- a/src/simulator/cosp_modis_interface.F90 +++ b/src/simulator/cosp_modis_interface.F90 @@ -179,10 +179,10 @@ SUBROUTINE COSP_MODIS_MASK(cospIN,cospgridIN,Npoints,modisIN,CSCAL_SWATH_MASK,MO modisIN%g => cospIN%asym modisIN%w0 => cospIN%ss_alb modisIN%Nsunlit = count(cospgridIN%sunlit > 0) + modisIN%pres => cospgridIN%phalf if (modisIN%Nsunlit .gt. 0) then allocate(modisIN%sunlit(modisIN%Nsunlit),modisIN%pres(modisIN%Nsunlit,cospIN%Nlevels+1)) modisIN%sunlit = pack((/ (i, i = 1, Npoints ) /),mask = cospgridIN%sunlit > 0) - modisIN%pres = cospgridIN%phalf(int(modisIN%sunlit(:)),:) ! JKS no reason to have this structure differently, right? Memory? endif if (count(cospgridIN%sunlit <= 0) .gt. 0) then ! If more than zero tiles are not sunlit a.k.a. if there are dark tiles allocate(modisIN%notSunlit(count(cospgridIN%sunlit <= 0))) From 8dbc4414f336bfb618e09114c95e876ea045a9bf Mon Sep 17 00:00:00 2001 From: dustinswales Date: Wed, 2 Jul 2025 11:34:23 -0600 Subject: [PATCH 147/159] Revert change in modis pressure subsetting --- src/simulator/cosp_modis_interface.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simulator/cosp_modis_interface.F90 b/src/simulator/cosp_modis_interface.F90 index 039d3f0205..aa6bc7763d 100644 --- a/src/simulator/cosp_modis_interface.F90 +++ b/src/simulator/cosp_modis_interface.F90 @@ -179,7 +179,7 @@ SUBROUTINE COSP_MODIS_MASK(cospIN,cospgridIN,Npoints,modisIN,CSCAL_SWATH_MASK,MO modisIN%g => cospIN%asym modisIN%w0 => cospIN%ss_alb modisIN%Nsunlit = count(cospgridIN%sunlit > 0) - modisIN%pres => cospgridIN%phalf + modisIN%pres = cospgridIN%phalf if (modisIN%Nsunlit .gt. 0) then allocate(modisIN%sunlit(modisIN%Nsunlit),modisIN%pres(modisIN%Nsunlit,cospIN%Nlevels+1)) modisIN%sunlit = pack((/ (i, i = 1, Npoints ) /),mask = cospgridIN%sunlit > 0) From ccb1c0f05f78172f679d75d95ab328b1761d8ad3 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 2 Jul 2025 12:23:09 -0600 Subject: [PATCH 148/159] Correct modisIN%pres allocation and assignment --- src/simulator/cosp_modis_interface.F90 | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/simulator/cosp_modis_interface.F90 b/src/simulator/cosp_modis_interface.F90 index aa6bc7763d..26c820e16b 100644 --- a/src/simulator/cosp_modis_interface.F90 +++ b/src/simulator/cosp_modis_interface.F90 @@ -153,11 +153,10 @@ SUBROUTINE COSP_MODIS_MASK(cospIN,cospgridIN,Npoints,modisIN,CSCAL_SWATH_MASK,MO modisIN%g => cospIN%asym modisIN%w0 => cospIN%ss_alb - allocate(modisIN%pres(modisIN%Npoints,cospIN%Nlevels+1)) ! Moving this outside of the sunlit statements for consistency with the other variables - modisIN%Nsunlit = count((cospgridIN%sunlit > 0) .and. MODIS_SWATH_MASK) ! Sunlit mask and indices array will just include swathing as well - modisIN%pres = cospgridIN%phalf + modisIN%Nsunlit = count((cospgridIN%sunlit > 0) .and. MODIS_SWATH_MASK) ! Sunlit mask and indices now include swathing as well if (modisIN%Nsunlit .gt. 0) then - allocate(modisIN%sunlit(modisIN%Nsunlit)) + allocate(modisIN%sunlit(modisIN%Nsunlit), modisIN%pres(modisIN%Npoints,cospIN%Nlevels+1)) + modisIN%pres = cospgridIN%phalf modisIN%sunlit = pack((/ (i, i = 1, modisIN%Npoints ) /),mask = ((cospgridIN%sunlit > 0) .and. MODIS_SWATH_MASK)) ! Indices of columns to operate on in modisIN endif if (modisIN%Npoints - modisIN%Nsunlit .gt. 0) then ! If more than zero tiles are not sunlit and swathed, create array to mask out these gridcells in cospOUT @@ -179,9 +178,9 @@ SUBROUTINE COSP_MODIS_MASK(cospIN,cospgridIN,Npoints,modisIN,CSCAL_SWATH_MASK,MO modisIN%g => cospIN%asym modisIN%w0 => cospIN%ss_alb modisIN%Nsunlit = count(cospgridIN%sunlit > 0) - modisIN%pres = cospgridIN%phalf if (modisIN%Nsunlit .gt. 0) then - allocate(modisIN%sunlit(modisIN%Nsunlit),modisIN%pres(modisIN%Nsunlit,cospIN%Nlevels+1)) + allocate(modisIN%sunlit(modisIN%Nsunlit),modisIN%pres(modisIN%Npoints,cospIN%Nlevels+1)) + modisIN%pres = cospgridIN%phalf modisIN%sunlit = pack((/ (i, i = 1, Npoints ) /),mask = cospgridIN%sunlit > 0) endif if (count(cospgridIN%sunlit <= 0) .gt. 0) then ! If more than zero tiles are not sunlit a.k.a. if there are dark tiles From 6d1ab2032f1260c99d3bb391eaf0082e64a4cd68 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 2 Jul 2025 14:49:09 -0600 Subject: [PATCH 149/159] Clean up old swathing variables, remove unused Lrttov_subcolumn logical, remove emis_in and refl_in, appropriately allocate so2 field even if it isn't used, and only run rttov_cleanup when needed. --- driver/src/cosp2_test.F90 | 25 +++++++++++-------------- src/cosp.F90 | 7 ++----- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 9de61a2e39..41b87ddadb 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -276,7 +276,7 @@ program cosp2_test cospIN ! COSP optical (or derived?) fields needed by simulators type(cosp_column_inputs) :: & cospstateIN ! COSP model fields needed by simulators - integer :: iChunk,nChunks,start_idx,end_idx,nPtsPerIt,ij,inst_idx + integer :: iChunk,nChunks,start_idx,end_idx,nPtsPerIt,ij real(wp),dimension(10) :: driver_time character(len=256),dimension(100) :: cosp_status @@ -312,12 +312,7 @@ program cosp2_test gamma_2 = (/-1., -1., 6.0, 6.0, -1., -1., 6.0, 6.0, 6.0/),& gamma_3 = (/-1., -1., 2.0, 2.0, -1., -1., 2.0, 2.0, 2.0/),& gamma_4 = (/-1., -1., 6.0, 6.0, -1., -1., 6.0, 6.0, 6.0/) - - ! Local variables for orbit swathing - real(wp),dimension(:),allocatable :: & - cosp_localtime, & - cosp_localtime_width - + ! Swathing DDT array type(swath_inputs),dimension(6) :: & cospswathsIN @@ -597,8 +592,8 @@ program cosp2_test ! Assign RTTOV values ! Keeping these structures since refl and emis could come from model input - cospstateIN%emis_in(:,:) = 1._wp - cospstateIN%refl_in(:,:) = 1._wp + ! cospstateIN%emis_in(:,:) = 1._wp + ! cospstateIN%refl_in(:,:) = 1._wp ! Well-mixed gases are not provided in COSP offline input, so hardcoding them in. ! Units are kg/kg over moist air. @@ -748,8 +743,10 @@ program cosp2_test !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if (rttov_verbose) print*,'Calling "destroy_cosp_outputs".' call destroy_cosp_outputs(cospOUT) - if (rttov_verbose) print*,'Calling "rttov_cleanup".' - call rttov_cleanup(cospIN) + if (associated(cospIN%cfg_rttov)) then + if (rttov_verbose) print*,'Calling "rttov_cleanup".' + call rttov_cleanup(cospIN) + endif if (rttov_verbose) print*,'Calling "destroy_cospIN".' call destroy_cospIN(cospIN) if (rttov_verbose) print*,'Calling "destroy_cospstateIN".' @@ -1247,7 +1244,7 @@ subroutine construct_cospstateIN(npoints,nlevels,y) y%o3(npoints,nlevels),y%hgt_matrix(npoints,nlevels),y%u_sfc(npoints), & y%v_sfc(npoints),y%lat(npoints),y%lon(nPoints),y%rttov_sfcmask(nPoints), & y%co(npoints,nlevels),y%n2o(npoints,nlevels),y%ch4(npoints,nlevels), & - y%co2(npoints,nlevels), & + y%co2(npoints,nlevels), y%so2(npoints,nlevels), & y%cloudIce(nPoints,nLevels),y%cloudLiq(nPoints,nLevels),y%surfelev(nPoints),& y%DeffLiq(nPoints,nLevels),y%DeffIce(nPoints,nLevels), & y%fl_snow(nPoints,nLevels),y%fl_rain(nPoints,nLevels), & @@ -1690,8 +1687,8 @@ subroutine destroy_cospstateIN(y) if (allocated(y%v_sfc)) deallocate(y%v_sfc) if (allocated(y%lat)) deallocate(y%lat) if (allocated(y%lon)) deallocate(y%lon) - if (allocated(y%emis_in)) deallocate(y%emis_in) - if (allocated(y%refl_in)) deallocate(y%refl_in) + ! if (allocated(y%emis_in)) deallocate(y%emis_in) + ! if (allocated(y%refl_in)) deallocate(y%refl_in) if (allocated(y%cloudIce)) deallocate(y%cloudIce) if (allocated(y%cloudLiq)) deallocate(y%cloudLiq) if (allocated(y%DeffLiq)) deallocate(y%DeffLiq) diff --git a/src/cosp.F90 b/src/cosp.F90 index 46004c4b72..54651fe8a8 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -267,7 +267,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) Lparasol_subcolumn, & ! On/Off switch for subcolumn PARASOL simulator Lcloudsat_subcolumn, & ! On/Off switch for subcolumn CLOUDSAT simulator Lmodis_subcolumn, & ! On/Off switch for subcolumn MODIS simulator - Lrttov_subcolumn, & ! On/Off switch for subcolumn RTTOV simulator Lisccp_column, & ! On/Off switch for column ISCCP simulator Lmisr_column, & ! On/Off switch for column MISR simulator Lcalipso_column, & ! On/Off switch for column CALIPSO simulator @@ -422,7 +421,6 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) Lparasol_subcolumn = .false. Lcloudsat_subcolumn = .false. Lmodis_subcolumn = .false. - Lrttov_subcolumn = .false. Lisccp_column = .false. Lmisr_column = .false. Lcalipso_column = .false. @@ -616,7 +614,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) Lmisr_subcolumn, Lmisr_column, Lmodis_subcolumn, Lmodis_column, & Lcloudsat_subcolumn, Lcloudsat_column, Lcalipso_subcolumn, Lcalipso_column, & Latlid_subcolumn, Latlid_column, LgrLidar532_subcolumn, LgrLidar532_column, & - Lrttov_subcolumn, Lrttov_column, Lparasol_subcolumn, Lparasol_column, & + Lrttov_column, Lparasol_subcolumn, Lparasol_column, & Lradar_lidar_tcc, Llidar_only_freq_cloud, Lcloudsat_tcc,Lcloudsat_tcc2, & Lcloudsat_modis_wr, cospOUT, cosp_simulator, nError) @@ -2365,7 +2363,7 @@ END SUBROUTINE COSP_INIT subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, & Lmisr_subcolumn, Lmisr_column, Lmodis_subcolumn, Lmodis_column, Lcloudsat_subcolumn, & Lcloudsat_column, Lcalipso_subcolumn, Lcalipso_column, Latlid_subcolumn, & - Latlid_column, LgrLidar532_subcolumn, LgrLidar532_column, Lrttov_subcolumn, & + Latlid_column, LgrLidar532_subcolumn, LgrLidar532_column, & Lrttov_column, Lparasol_subcolumn, Lparasol_column, Lradar_lidar_tcc, & Llidar_only_freq_cloud, Lcloudsat_tcc, Lcloudsat_tcc2, Lcloudsat_modis_wr, & cospOUT, errorMessage, nError) @@ -2394,7 +2392,6 @@ subroutine cosp_errorCheck(cospgridIN, cospIN, Lisccp_subcolumn, Lisccp_column, LgrLidar532_column, & ! Ground Lidar column simulator on/off switch Lparasol_subcolumn, & ! PARASOL subcolumn simulator on/off switch Lparasol_column, & ! PARASOL column simulator on/off switch - Lrttov_subcolumn, & ! RTTOV subcolumn simulator on/off switch Lrttov_column, & ! RTTOV column simulator on/off switch Lcloudsat_tcc, & ! Lcloudsat_tcc2, & ! From 343d3b25b3f0083d9099ba40bda994925be9168e Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 2 Jul 2025 14:58:19 -0600 Subject: [PATCH 150/159] Correct commented RTTOV fields in input namelist files used for CI. --- driver/run/cosp2_input_nl.txt | 14 +++----------- driver/run/cosp2_input_nl.um_global.txt | 14 +++----------- .../run/cosp2_input_nl.um_global_model_levels.txt | 14 +++----------- 3 files changed, 9 insertions(+), 33 deletions(-) diff --git a/driver/run/cosp2_input_nl.txt b/driver/run/cosp2_input_nl.txt index f27d166f55..3520ac6a55 100644 --- a/driver/run/cosp2_input_nl.txt +++ b/driver/run/cosp2_input_nl.txt @@ -82,15 +82,7 @@ !---------------------------------------------------------------------------------- !-------------- RTTOV inputs !---------------------------------------------------------------------------------- -! rttov_Platform=1, ! satellite platform -! rttov_Satellite=15, ! satellite -! rttov_Instrument=5, ! instrument -! rttov_Nchannels=3, ! Number of channels to be computed -! rttov_Channels=1,2,3, ! Channel numbers (please be sure that you supply Nchannels) -! rttov_Surfem=0.0,0.0,0.0, ! Surface emissivity (please be sure that you supply Nchannels) -! rttov_ZenAng=50.0, ! Satellite Zenith Angle -! CO2=5.241e-04, ! Mixing ratios of trace gases -! CH4=9.139e-07, -! N2O=4.665e-07, -! CO=2.098e-07 +! rttov_Ninstruments=1, +! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt', + rttov_verbose=.false. / diff --git a/driver/run/cosp2_input_nl.um_global.txt b/driver/run/cosp2_input_nl.um_global.txt index ff5ba86407..1e5f011289 100644 --- a/driver/run/cosp2_input_nl.um_global.txt +++ b/driver/run/cosp2_input_nl.um_global.txt @@ -82,15 +82,7 @@ !---------------------------------------------------------------------------------- !-------------- RTTOV inputs !---------------------------------------------------------------------------------- - !rttov_Platform=1, ! satellite platform - !rttov_Satellite=15, ! satellite - !rttov_Instrument=5, ! instrument - !rttov_Nchannels=3, ! Number of channels to be computed - !rttov_Channels=1,2,3, ! Channel numbers (please be sure that you supply Nchannels) - !rttov_Surfem=0.0,0.0,0.0, ! Surface emissivity (please be sure that you supply Nchannels) - !rttov_ZenAng=50.0, ! Satellite Zenith Angle - !CO2=5.241e-04, ! Mixing ratios of trace gases - !CH4=9.139e-07, - !N2O=4.665e-07, - !CO=2.098e-07 +! rttov_Ninstruments=1, +! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt', + rttov_verbose=.false. / diff --git a/driver/run/cosp2_input_nl.um_global_model_levels.txt b/driver/run/cosp2_input_nl.um_global_model_levels.txt index 72e968372e..4e917c55a9 100644 --- a/driver/run/cosp2_input_nl.um_global_model_levels.txt +++ b/driver/run/cosp2_input_nl.um_global_model_levels.txt @@ -82,15 +82,7 @@ !---------------------------------------------------------------------------------- !-------------- RTTOV inputs !---------------------------------------------------------------------------------- - rttov_Platform=1, ! satellite platform - rttov_Satellite=15, ! satellite - rttov_Instrument=5, ! instrument - rttov_Nchannels=3, ! Number of channels to be computed - rttov_Channels=1,2,3, ! Channel numbers (please be sure that you supply Nchannels) - rttov_Surfem=0.0,0.0,0.0, ! Surface emissivity (please be sure that you supply Nchannels) - rttov_ZenAng=50.0, ! Satellite Zenith Angle - CO2=5.241e-04, ! Mixing ratios of trace gases - CH4=9.139e-07, - N2O=4.665e-07, - CO=2.098e-07 +! rttov_Ninstruments=1, +! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt', + rttov_verbose=.false. / From d10be9ffc491f0f3a82528a648fe733a7ae0993d Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 2 Jul 2025 15:16:49 -0600 Subject: [PATCH 151/159] Simplify RTTOV namelist logic by only requiring changes to the input namelist. --- driver/run/cosp2_output_nl.txt | 2 -- .../run/cosp2_output_nl.um_global_model_levels.txt | 2 -- driver/src/cosp2_test.F90 | 13 ++----------- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/driver/run/cosp2_output_nl.txt b/driver/run/cosp2_output_nl.txt index be75d7d0a9..4c61520a2f 100755 --- a/driver/run/cosp2_output_nl.txt +++ b/driver/run/cosp2_output_nl.txt @@ -132,8 +132,6 @@ Llwpmodis=.true., Liwpmodis=.true., Lclmodis=.true., - !- RTTOV -! Ltbrttov=.false., ! -CLOUDSAT precipitation frequency/occurence diagnostics Lptradarflag0=.true., Lptradarflag1=.true., diff --git a/driver/run/cosp2_output_nl.um_global_model_levels.txt b/driver/run/cosp2_output_nl.um_global_model_levels.txt index 76a6400c51..c4b382a8fc 100755 --- a/driver/run/cosp2_output_nl.um_global_model_levels.txt +++ b/driver/run/cosp2_output_nl.um_global_model_levels.txt @@ -132,8 +132,6 @@ Llwpmodis=.true., Liwpmodis=.true., Lclmodis=.true., - !- RTTOV - Ltbrttov=.false., ! -CLOUDSAT precipitation frequency/occurence diagnostics Lptradarflag0=.true., Lptradarflag1=.true., diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 41b87ddadb..3e75cffc51 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -437,16 +437,7 @@ program cosp2_test Lradarpia) Lcloudsat = .true. if (Lparasolrefl) Lparasol = .true. - ! JKS - This will need to be revamped. Each instrument needs these flags - if (Lrttov .and. (rttov_Ninstruments .gt. 0)) Lrttov = .true. - if (Lrttov .and. (rttov_Ninstruments .le. 0)) then - print*,'Lrttov is "true" but rttov_Ninstruments < 1. COSP-RTTOV will not run.' - Lrttov = .false. - endif - if ((.not. Lrttov) .and. (rttov_Ninstruments .gt. 0)) then - print*,'rttov_Ninstruments > 0 but Lrttov is "false". COSP-RTTOV will not run.' - Lrttov = .false. - endif + if (rttov_Ninstruments .gt. 0) Lrttov = .true. !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1574,7 +1565,7 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& ! RTTOV - Allocate output for multiple instruments ! Do I not need to allocate the number of instruments? Because each rttov output DDT will be a pointer? - if ((Ninst_rttov .gt. 0) .and. (Lrttov)) then + if (Lrttov) then x % Ninst_rttov = Ninst_rttov allocate(x % rttov_outputs(Ninst_rttov)) ! Need to allocate a pointer? do i=1,Ninst_rttov From 0dc70c4cda0ea32abc2728f17ca517c16572eec0 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 16 Jul 2025 12:39:21 -0600 Subject: [PATCH 152/159] Rename masking/assignment routines --- src/cosp.F90 | 42 +++++++++++------------ src/simulator/cosp_atlid_interface.F90 | 12 +++---- src/simulator/cosp_calipso_interface.F90 | 12 +++---- src/simulator/cosp_cloudsat_interface.F90 | 12 +++---- src/simulator/cosp_isccp_interface.F90 | 12 +++---- src/simulator/cosp_misr_interface.F90 | 12 +++---- src/simulator/cosp_modis_interface.F90 | 6 ++-- src/simulator/cosp_parasol_interface.F90 | 12 +++---- 8 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/cosp.F90 b/src/cosp.F90 index 54651fe8a8..51eae9608b 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -53,22 +53,22 @@ MODULE MOD_COSP modis_histTauCenters,tau_binCenters, & cloudsat_preclvl,grLidar532_histBsct,atlid_histBsct USE MOD_COSP_MODIS_INTERFACE, ONLY: cosp_modis_init, modis_IN, & - cosp_modis_mask + COSP_ASSIGN_modisIN USE MOD_COSP_RTTOV_INTERFACE, ONLY: cosp_rttov_init, cosp_rttov_simulate USE MOD_COSP_RTTOV_UTIL, ONLY: rttov_cfg, rttov_output USE MOD_COSP_MISR_INTERFACE, ONLY: cosp_misr_init, misr_IN, & - cosp_misr_mask, cosp_misr_mask_clean + COSP_ASSIGN_misrIN, COSP_ASSIGN_misrIN_clean USE MOD_COSP_ISCCP_INTERFACE, ONLY: cosp_isccp_init, isccp_IN, & - cosp_isccp_mask, cosp_isccp_mask_clean + COSP_ASSIGN_isccpIN, COSP_ASSIGN_isccpIN_clean USE MOD_COSP_CALIPSO_INTERFACE, ONLY: cosp_calipso_init, calipso_IN, & - cosp_calipso_mask, cosp_calipso_mask_clean + COSP_ASSIGN_calipsoIN, COSP_ASSIGN_calipsoIN_clean USE MOD_COSP_ATLID_INTERFACE, ONLY: cosp_atlid_init, atlid_IN, & - cosp_atlid_mask, cosp_atlid_mask_clean - USE MOD_COSP_GRLIDAR532_INTERFACE, ONLY: cosp_grLidar532_init, grLidar532_IN + COSP_ASSIGN_atlidIN, COSP_ASSIGN_atlidIN_clean + USE MOD_COSP_GRLIDAR532_INTERFACE, ONLY: cosp_grLidar532_init, grLidar532_IN USE MOD_COSP_PARASOL_INTERFACE, ONLY: cosp_parasol_init, parasol_in, & - cosp_parasol_mask, cosp_parasol_mask_clean + COSP_ASSIGN_parasolIN, COSP_ASSIGN_parasolIN_clean USE MOD_COSP_CLOUDSAT_INTERFACE, ONLY: cosp_cloudsat_init, cloudsat_IN, & - cosp_cloudsat_mask, cosp_cloudsat_mask_clean + COSP_ASSIGN_cloudsatIN,COSP_ASSIGN_cloudsatIN_clean USE quickbeam, ONLY: quickbeam_subcolumn, quickbeam_column USE MOD_ICARUS, ONLY: icarus_subcolumn, icarus_column USE MOD_MISR_SIMULATOR, ONLY: misr_subcolumn, misr_column @@ -624,15 +624,15 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) ! Indexing order for "cospIN % cospswathsIN" is ISCCP, MISR, CLOUDSAT-CALIPSO, ATLID, PARASOL, MODIS if (Lisccp_subcolumn .or. Lmodis_subcolumn) then - call COSP_ISCCP_MASK(cospIN,cospgridIN,Npoints,isccpIN,ISCCP_MASK_INDICES) + call COSP_ASSIGN_isccpIN(cospIN,cospgridIN,Npoints,isccpIN,ISCCP_MASK_INDICES) !COSP_ASSIGN_isccpIN endif if (Lmisr_subcolumn) then - call COSP_MISR_MASK(cospIN,cospgridIN,Npoints,misrIN,MISR_MASK_INDICES) + call COSP_ASSIGN_misrIN(cospIN,cospgridIN,Npoints,misrIN,MISR_MASK_INDICES) endif if (Lcalipso_subcolumn) then - call COSP_CALIPSO_MASK(cospIN,cospgridIN,Npoints,calipsoIN,CSCAL_MASK_INDICES,CSCAL_SWATH_MASK) + call COSP_ASSIGN_calipsoIN(cospIN,cospgridIN,Npoints,calipsoIN,CSCAL_MASK_INDICES,CSCAL_SWATH_MASK) endif if (LgrLidar532_subcolumn) then @@ -646,19 +646,19 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) endif if (Latlid_subcolumn) then - call COSP_ATLID_MASK(cospIN,cospgridIN,Npoints,atlidIN,ATLID_MASK_INDICES) + call COSP_ASSIGN_atlidIN(cospIN,cospgridIN,Npoints,atlidIN,ATLID_MASK_INDICES) endif if (Lparasol_subcolumn) then - call COSP_PARASOL_MASK(cospIN,cospgridIN,Npoints,parasolIN,PARASOL_MASK_INDICES) + call COSP_ASSIGN_parasolIN(cospIN,cospgridIN,Npoints,parasolIN,PARASOL_MASK_INDICES) endif if (Lcloudsat_subcolumn) then - call COSP_CLOUDSAT_MASK(cospIN,cospgridIN,Npoints,cloudsatIN,CSCAL_MASK_INDICES,CSCAL_SWATH_MASK) + call COSP_ASSIGN_cloudsatIN(cospIN,cospgridIN,Npoints,cloudsatIN,CSCAL_MASK_INDICES,CSCAL_SWATH_MASK) endif if (Lmodis_subcolumn) then - call COSP_MODIS_MASK(cospIN,cospgridIN,Npoints,modisIN,CSCAL_SWATH_MASK,MODIS_CSCAL_MASK_INDICES) + call COSP_ASSIGN_modisIN(cospIN,cospgridIN,Npoints,modisIN,CSCAL_SWATH_MASK,MODIS_CSCAL_MASK_INDICES) endif if (Lrttov_column) then @@ -2165,13 +2165,13 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) nullify(isccpIN%Ncolumns,isccpIN%Nlevels,isccpIN%emsfc_lw, & isccpIN%skt,isccpIN%qv,isccpIN%at,isccpIN%frac_out,isccpIN%dtau, & isccpIN%dem,isccpIN%phalf,isccpIN%sunlit,isccpIN%pfull) - call COSP_ISCCP_MASK_CLEAN() + call COSP_ASSIGN_isccpIN_CLEAN() endif if (Lmisr_subcolumn) then nullify(misrIN%Ncolumns,misrIN%Nlevels,misrIN%dtau,misrIN%sunlit, & misrIN%zfull,misrIN%at) - call COSP_MISR_MASK_CLEAN() + call COSP_ASSIGN_misrIN_CLEAN() endif if (Lcalipso_subcolumn) then @@ -2180,7 +2180,7 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) calipsoIN%tau_mol,calipsoIN%tautot,calipsoIN%tautot_liq,calipsoIN%tautot_ice) if (allocated(CSCAL_MASK_INDICES)) deallocate(CSCAL_MASK_INDICES) if (allocated(CSCAL_SWATH_MASK)) deallocate(CSCAL_SWATH_MASK) - call COSP_CALIPSO_MASK_CLEAN() + call COSP_ASSIGN_calipsoIN_CLEAN() endif if (LgrLidar532_subcolumn) then @@ -2191,19 +2191,19 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) if (Latlid_subcolumn) then nullify(atlidIN%Ncolumns,atlidIN%Nlevels,atlidIN%beta_mol_atlid, & atlidIN%betatot_atlid,atlidIN%tau_mol_atlid,atlidIN%tautot_atlid) - call COSP_ATLID_MASK_CLEAN() + call COSP_ASSIGN_atlidIN_CLEAN() endif if (Lparasol_subcolumn) then nullify(parasolIN%Nlevels,parasolIN%Ncolumns,parasolIN%Nrefl, & parasolIN%tautot_S_liq,parasolIN%tautot_S_ice) - call COSP_PARASOL_MASK_CLEAN() + call COSP_ASSIGN_parasolIN_CLEAN() endif if (Lcloudsat_subcolumn) then nullify(cloudsatIN%Nlevels,cloudsatIN%Ncolumns,cloudsatIN%rcfg,& cloudsatIN%kr_vol,cloudsatIN%g_vol,cloudsatIN%z_vol,cloudsatIN%hgt_matrix) - call COSP_CLOUDSAT_MASK_CLEAN() + call COSP_ASSIGN_cloudsatIN_CLEAN() if (allocated(CSCAL_MASK_INDICES)) deallocate(CSCAL_MASK_INDICES) if (allocated(CSCAL_SWATH_MASK)) deallocate(CSCAL_SWATH_MASK) endif diff --git a/src/simulator/cosp_atlid_interface.F90 b/src/simulator/cosp_atlid_interface.F90 index c947c64d8b..d622921e34 100644 --- a/src/simulator/cosp_atlid_interface.F90 +++ b/src/simulator/cosp_atlid_interface.F90 @@ -72,9 +72,9 @@ subroutine cosp_atlid_init() end subroutine cosp_atlid_init !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE COSP_ATLID_MASK + ! SUBROUTINE COSP_ASSIGN_atlidIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_ATLID_MASK(cospIN,cospgridIN,Npoints,atlidIN,ATLID_MASK_INDICES) + SUBROUTINE COSP_ASSIGN_atlidIN(cospIN,cospgridIN,Npoints,atlidIN,ATLID_MASK_INDICES) type(cosp_optical_inputs),intent(in),target :: cospIN ! Optical inputs to COSP simulator type(cosp_column_inputs), intent(in),target :: cospgridIN ! Host model inputs to COSP integer,intent(in),target :: & @@ -135,19 +135,19 @@ SUBROUTINE COSP_ATLID_MASK(cospIN,cospgridIN,Npoints,atlidIN,ATLID_MASK_INDICES) atlidIN%tautot_atlid => cospIN%tautot_atlid end if - END SUBROUTINE COSP_ATLID_MASK + END SUBROUTINE COSP_ASSIGN_atlidIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE COSP_ATLID_CLEAN + ! SUBROUTINE COSP_ASSIGN_atlidIN_CLEAN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_ATLID_MASK_CLEAN() + SUBROUTINE COSP_ASSIGN_atlidIN_CLEAN() ! Deallocate temporary arrays if (allocated(temp_beta_mol_atlid)) deallocate(temp_beta_mol_atlid) if (allocated(temp_tau_mol_atlid)) deallocate(temp_tau_mol_atlid) if (allocated(temp_betatot_atlid)) deallocate(temp_betatot_atlid) if (allocated(temp_tautot_atlid)) deallocate(temp_tautot_atlid) - END SUBROUTINE COSP_ATLID_MASK_CLEAN + END SUBROUTINE COSP_ASSIGN_atlidIN_CLEAN ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! END MODULE diff --git a/src/simulator/cosp_calipso_interface.F90 b/src/simulator/cosp_calipso_interface.F90 index fe1da45715..4179deaeb0 100644 --- a/src/simulator/cosp_calipso_interface.F90 +++ b/src/simulator/cosp_calipso_interface.F90 @@ -94,9 +94,9 @@ subroutine cosp_calipso_init() end subroutine cosp_calipso_init !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE COSP_CALIPSO_MASK + ! SUBROUTINE COSP_ASSIGN_calipsoIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_CALIPSO_MASK(cospIN,cospgridIN,Npoints,calipsoIN,CSCAL_MASK_INDICES,CSCAL_SWATH_MASK) + SUBROUTINE COSP_ASSIGN_calipsoIN(cospIN,cospgridIN,Npoints,calipsoIN,CSCAL_MASK_INDICES,CSCAL_SWATH_MASK) type(cosp_optical_inputs),intent(in),target :: cospIN ! Optical inputs to COSP simulator type(cosp_column_inputs), intent(in),target :: cospgridIN ! Host model inputs to COSP integer,intent(in),target :: & @@ -172,12 +172,12 @@ SUBROUTINE COSP_CALIPSO_MASK(cospIN,cospgridIN,Npoints,calipsoIN,CSCAL_MASK_INDI calipsoIN%tautot_ice => cospIN%tautot_ice_calipso end if - END SUBROUTINE COSP_CALIPSO_MASK + END SUBROUTINE COSP_ASSIGN_calipsoIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE COSP_CALIPSO_CLEAN + ! SUBROUTINE COSP_ASSIGN_calipsoIN_CLEAN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_CALIPSO_MASK_CLEAN() + SUBROUTINE COSP_ASSIGN_calipsoIN_CLEAN() ! Deallocate temporary arrays if (allocated(temp_beta_mol_calipso)) deallocate(temp_beta_mol_calipso) if (allocated(temp_tau_mol_calipso)) deallocate(temp_tau_mol_calipso) @@ -188,7 +188,7 @@ SUBROUTINE COSP_CALIPSO_MASK_CLEAN() if (allocated(temp_betatot_ice_calipso)) deallocate(temp_betatot_ice_calipso) if (allocated(temp_tautot_ice_calipso)) deallocate(temp_tautot_ice_calipso) - END SUBROUTINE COSP_CALIPSO_MASK_CLEAN + END SUBROUTINE COSP_ASSIGN_calipsoIN_CLEAN ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! END MODULE diff --git a/src/simulator/cosp_cloudsat_interface.F90 b/src/simulator/cosp_cloudsat_interface.F90 index 5ed458ebcf..ff61417104 100644 --- a/src/simulator/cosp_cloudsat_interface.F90 +++ b/src/simulator/cosp_cloudsat_interface.F90 @@ -149,9 +149,9 @@ SUBROUTINE COSP_CLOUDSAT_INIT(radar_freq,k2,use_gas_abs,do_ray,undef,nhydro, & END SUBROUTINE COSP_CLOUDSAT_INIT !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE COSP_CLOUDSAT_MASK + ! SUBROUTINE COSP_ASSIGN_cloudsatIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_CLOUDSAT_MASK(cospIN, cospgridIN, Npoints, cloudsatIN, & + SUBROUTINE COSP_ASSIGN_cloudsatIN(cospIN, cospgridIN, Npoints, cloudsatIN, & CSCAL_MASK_INDICES, CSCAL_SWATH_MASK) type(cosp_optical_inputs),intent(in),target :: cospIN ! Optical inputs to COSP simulator type(cosp_column_inputs), intent(in),target :: cospgridIN ! Host model inputs to COSP @@ -214,19 +214,19 @@ SUBROUTINE COSP_CLOUDSAT_MASK(cospIN, cospgridIN, Npoints, cloudsatIN, cloudsatIN%hgt_matrix => cospgridIN%hgt_matrix end if - END SUBROUTINE COSP_CLOUDSAT_MASK + END SUBROUTINE COSP_ASSIGN_cloudsatIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE COSP_CLOUDSAT_CLEAN + ! SUBROUTINE COSP_ASSIGN_cloudsatIN_CLEAN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_CLOUDSAT_MASK_CLEAN() + SUBROUTINE COSP_ASSIGN_cloudsatIN_CLEAN() ! Deallocate temporary arrays if (allocated(temp_z_vol_cloudsat)) deallocate(temp_z_vol_cloudsat) if (allocated(temp_kr_vol_cloudsat)) deallocate(temp_kr_vol_cloudsat) if (allocated(temp_g_vol_cloudsat)) deallocate(temp_g_vol_cloudsat) if (allocated(temp_hgt_matrix)) deallocate(temp_hgt_matrix) - END SUBROUTINE COSP_CLOUDSAT_MASK_CLEAN + END SUBROUTINE COSP_ASSIGN_cloudsatIN_CLEAN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! END MODULE diff --git a/src/simulator/cosp_isccp_interface.F90 b/src/simulator/cosp_isccp_interface.F90 index 3807e855a9..d18e09b7c7 100644 --- a/src/simulator/cosp_isccp_interface.F90 +++ b/src/simulator/cosp_isccp_interface.F90 @@ -98,9 +98,9 @@ SUBROUTINE COSP_ISCCP_INIT(top_height,top_height_direction) END SUBROUTINE COSP_ISCCP_INIT !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE COSP_ISCCP_MASK + ! SUBROUTINE COSP_ASSIGN_isccpIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_ISCCP_MASK(cospIN,cospgridIN,Npoints,isccpIN,ISCCP_MASK_INDICES) + SUBROUTINE COSP_ASSIGN_isccpIN(cospIN,cospgridIN,Npoints,isccpIN,ISCCP_MASK_INDICES) type(cosp_optical_inputs),intent(in),target :: cospIN ! Optical inputs to COSP simulator type(cosp_column_inputs), intent(in),target :: cospgridIN ! Host model inputs to COSP integer,intent(in),target :: & @@ -178,12 +178,12 @@ SUBROUTINE COSP_ISCCP_MASK(cospIN,cospgridIN,Npoints,isccpIN,ISCCP_MASK_INDICES) isccpIN%sunlit => cospgridIN%sunlit end if - END SUBROUTINE COSP_ISCCP_MASK + END SUBROUTINE COSP_ASSIGN_isccpIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE COSP_ISCCP_CLEAN + ! SUBROUTINE COSP_ASSIGN_isccpIN_CLEAN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_ISCCP_MASK_CLEAN() + SUBROUTINE COSP_ASSIGN_isccpIN_CLEAN() ! Deallocate temporary arrays if (allocated(temp_isccp_sunlit)) deallocate(temp_isccp_sunlit) if (allocated(temp_isccp_skt)) deallocate(temp_isccp_skt) @@ -195,7 +195,7 @@ SUBROUTINE COSP_ISCCP_MASK_CLEAN() if (allocated(temp_isccp_tau_067)) deallocate(temp_isccp_tau_067) if (allocated(temp_isccp_emiss_11)) deallocate(temp_isccp_emiss_11) - END SUBROUTINE COSP_ISCCP_MASK_CLEAN + END SUBROUTINE COSP_ASSIGN_isccpIN_CLEAN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! END MODULE diff --git a/src/simulator/cosp_misr_interface.F90 b/src/simulator/cosp_misr_interface.F90 index b166cba6a8..3d2e0e6cac 100644 --- a/src/simulator/cosp_misr_interface.F90 +++ b/src/simulator/cosp_misr_interface.F90 @@ -74,9 +74,9 @@ SUBROUTINE COSP_MISR_INIT() END SUBROUTINE COSP_MISR_INIT !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE COSP_MISR_MASK + ! SUBROUTINE COSP_ASSIGN_misrIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_MISR_MASK(cospIN,cospgridIN,Npoints,misrIN,MISR_MASK_INDICES) + SUBROUTINE COSP_ASSIGN_misrIN(cospIN,cospgridIN,Npoints,misrIN,MISR_MASK_INDICES) type(cosp_optical_inputs),intent(in),target :: cospIN ! Optical inputs to COSP simulator type(cosp_column_inputs), intent(in),target :: cospgridIN ! Host model inputs to COSP integer,intent(in),target :: & @@ -137,19 +137,19 @@ SUBROUTINE COSP_MISR_MASK(cospIN,cospgridIN,Npoints,misrIN,MISR_MASK_INDICES) misrIN%at => cospgridIN%at end if - END SUBROUTINE COSP_MISR_MASK + END SUBROUTINE COSP_ASSIGN_misrIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE COSP_MISR_CLEAN + ! SUBROUTINE COSP_ASSIGN_misrIN_CLEAN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_MISR_MASK_CLEAN() + SUBROUTINE COSP_ASSIGN_misrIN_CLEAN() ! Deallocate temporary arrays if (allocated(temp_misr_sunlit)) deallocate(temp_misr_sunlit) if (allocated(temp_misr_zfull)) deallocate(temp_misr_zfull) if (allocated(temp_misr_at)) deallocate(temp_misr_at) if (allocated(temp_misr_dtau)) deallocate(temp_misr_dtau) - END SUBROUTINE COSP_MISR_MASK_CLEAN + END SUBROUTINE COSP_ASSIGN_misrIN_CLEAN ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! END MODULE diff --git a/src/simulator/cosp_modis_interface.F90 b/src/simulator/cosp_modis_interface.F90 index 26c820e16b..02e4dfc3ce 100644 --- a/src/simulator/cosp_modis_interface.F90 +++ b/src/simulator/cosp_modis_interface.F90 @@ -110,9 +110,9 @@ SUBROUTINE COSP_MODIS_INIT() END SUBROUTINE COSP_MODIS_INIT !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE COSP_MODIS_MASK + ! SUBROUTINE COSP_ASSIGN_modisIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_MODIS_MASK(cospIN,cospgridIN,Npoints,modisIN,CSCAL_SWATH_MASK,MODIS_CSCAL_MASK_INDICES) + SUBROUTINE COSP_ASSIGN_modisIN(cospIN,cospgridIN,Npoints,modisIN,CSCAL_SWATH_MASK,MODIS_CSCAL_MASK_INDICES) type(cosp_optical_inputs),intent(in),target :: cospIN ! Optical inputs to COSP simulator type(cosp_column_inputs), intent(in),target :: cospgridIN ! Host model inputs to COSP integer,intent(in),target :: & @@ -189,7 +189,7 @@ SUBROUTINE COSP_MODIS_MASK(cospIN,cospgridIN,Npoints,modisIN,CSCAL_SWATH_MASK,MO endif end if - END SUBROUTINE COSP_MODIS_MASK + END SUBROUTINE COSP_ASSIGN_modisIN ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! END MODULE MOD_COSP_Modis_INTERFACE diff --git a/src/simulator/cosp_parasol_interface.F90 b/src/simulator/cosp_parasol_interface.F90 index dde889f359..795b381a2f 100644 --- a/src/simulator/cosp_parasol_interface.F90 +++ b/src/simulator/cosp_parasol_interface.F90 @@ -93,9 +93,9 @@ SUBROUTINE COSP_PARASOL_INIT() end subroutine COSP_PARASOL_INIT !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE COSP_PARASOL_MASK + ! SUBROUTINE COSP_ASSIGN_parasolIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_PARASOL_MASK(cospIN,cospgridIN,Npoints,parasolIN,PARASOL_MASK_INDICES) + SUBROUTINE COSP_ASSIGN_parasolIN(cospIN,cospgridIN,Npoints,parasolIN,PARASOL_MASK_INDICES) type(cosp_optical_inputs),intent(in),target :: cospIN ! Optical inputs to COSP simulator type(cosp_column_inputs), intent(in),target :: cospgridIN ! Host model inputs to COSP integer,intent(in),target :: & @@ -150,17 +150,17 @@ SUBROUTINE COSP_PARASOL_MASK(cospIN,cospgridIN,Npoints,parasolIN,PARASOL_MASK_IN parasolIN%tautot_S_ice => cospIN%tautot_S_ice end if - END SUBROUTINE COSP_PARASOL_MASK + END SUBROUTINE COSP_ASSIGN_parasolIN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE COSP_PARASOL_CLEAN + ! SUBROUTINE COSP_ASSIGN_parasolIN_CLEAN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE COSP_PARASOL_MASK_CLEAN() + SUBROUTINE COSP_ASSIGN_parasolIN_CLEAN() ! Deallocate temporary arrays if (allocated(temp_tautot_S_liq)) deallocate(temp_tautot_S_liq) if (allocated(temp_tautot_S_ice)) deallocate(temp_tautot_S_ice) - END SUBROUTINE COSP_PARASOL_MASK_CLEAN + END SUBROUTINE COSP_ASSIGN_parasolIN_CLEAN !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! END MODULE From 6162bb4bf4721b2e4e8ecc88a0a8bda165ebcb11 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 16 Jul 2025 12:40:07 -0600 Subject: [PATCH 153/159] Add swathing consistent handling of CALIPSO, CloudSat, and PARASOL outputs that were being assigned R_UNDEF values inconsistently. --- src/cosp.F90 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/cosp.F90 b/src/cosp.F90 index 51eae9608b..51f3783189 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -1221,6 +1221,16 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospOUT%calipso_cldthinemis(ij:ik) = R_UNDEF cospOUT%calipso_cldlayerphase(ij:ik,:,:) = R_UNDEF cospOUT%calipso_lidarcldtmp(ij:ik,:,:) = R_UNDEF + ! Note: The active simulators use R_UNDEF to indicate unretrieved and clear-sky values. + ! Decisions on how to treat these values are delegeate to the host user, and fields + ! are often set to zero. + ! Using R_UNDEF in this way is incompatible with the swath approach, where R_UNDEF means + ! that a field should not be used in statistically averaging, etc. + ! To avoid this error, when swathing we set R_UNDEF value to zero here. + where (temp_calipso_cfad_sr(:,:,:) == R_UNDEF) temp_calipso_cfad_sr(:,:,:) = 0._wp + where (temp_calipso_lidarcldphase(:,:,:) == R_UNDEF) temp_calipso_lidarcldphase(:,:,:) = 0._wp + where (temp_calipso_lidarcld(:,:) == R_UNDEF) temp_calipso_lidarcld(:,:) = 0._wp + ! Unpack into the full lat-lon structure if (associated(cospOUT%calipso_cfad_sr)) cospOUT%calipso_cfad_sr(ij+int(CSCAL_MASK_INDICES)-1,:,:) = temp_calipso_cfad_sr(:,:,:) if (associated(cospOUT%calipso_lidarcld)) cospOUT%calipso_lidarcld(ij+int(CSCAL_MASK_INDICES)-1,:) = temp_calipso_lidarcld(:,:) if (associated(cospOUT%calipso_cldlayer)) cospOUT%calipso_cldlayer(ij+int(CSCAL_MASK_INDICES)-1,:) = temp_calipso_cldlayer(:,:) @@ -1442,6 +1452,13 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) temp_parasolGrid_refl(:,:)) ! Decode back to the cospOUT shapes cospOUT%parasolGrid_refl(ij:ik,:) = R_UNDEF + ! Note: The active simulators use R_UNDEF to indicate unretrieved and clear-sky values. + ! Decisions on how to treat these values are delegeate to the host user, and fields + ! are often set to zero. + ! Using R_UNDEF in this way is incompatible with the swath approach, where R_UNDEF means + ! that a field should not be used in statistically averaging, etc. + ! To avoid this error, when swathing we set R_UNDEF value to zero here. + where (temp_parasolGrid_refl(:,:) == R_UNDEF) temp_parasolGrid_refl(:,:) = 0._wp if (associated(cospOUT%parasolGrid_refl)) cospOUT%parasolGrid_refl(ij+int(PARASOL_MASK_INDICES)-1,:) = temp_parasolGrid_refl(:,:) deallocate(temp_parasolGrid_refl) else @@ -1490,6 +1507,13 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospOUT%cloudsat_cfad_ze(ij:ik,:,:) = R_UNDEF cospOUT%cloudsat_precip_cover(ij:ik,:) = R_UNDEF cospOUT%cloudsat_pia(ij:ik) = R_UNDEF + ! Note: The active simulators use R_UNDEF to indicate unretrieved and clear-sky values. + ! Decisions on how to treat these values are delegeate to the host user, and fields + ! are often set to zero. + ! Using R_UNDEF in this way is incompatible with the swath approach, where R_UNDEF means + ! that a field should not be used in statistically averaging, etc. + ! To avoid this error, when swathing we set R_UNDEF value to zero here. + where (temp_cloudsat_cfad_ze(:,:,:) == R_UNDEF) temp_cloudsat_cfad_ze(:,:,:) = 0._wp if (associated(cospOUT%cloudsat_cfad_ze)) cospOUT%cloudsat_cfad_ze(ij+int(CSCAL_MASK_INDICES)-1,:,:) = temp_cloudsat_cfad_ze(:,:,:) if (associated(cospOUT%cloudsat_precip_cover)) cospOUT%cloudsat_precip_cover(ij+int(CSCAL_MASK_INDICES)-1,:) = temp_cloudsat_precip_cover(:,:) if (associated(cospOUT%cloudsat_pia)) cospOUT%cloudsat_pia(ij+int(CSCAL_MASK_INDICES)-1) = temp_cloudsat_pia(:) From 2ff2dc138d748b4f2d40a2b81134b96086ce0b10 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Mon, 21 Jul 2025 08:33:13 -0600 Subject: [PATCH 154/159] update kgo versions for CI --- .github/workflows/containerized-ci.yml | 2 +- .github/workflows/continuous_integration.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/containerized-ci.yml b/.github/workflows/containerized-ci.yml index 0fff82c015..13a227184d 100644 --- a/.github/workflows/containerized-ci.yml +++ b/.github/workflows/containerized-ci.yml @@ -21,7 +21,7 @@ jobs: - compiler: ifx image: ghcr.io/earth-system-radiation/rte-rrtmgp-ci:oneapi # Common variables - - kgo_version: v005 + - kgo_version: v006 defaults: run: shell: bash -el {0} diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 1e210fc189..a5fef1c1c1 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -41,7 +41,7 @@ jobs: python-version: [3.11] include: - compiler_short_name: gfortran - - kgo_version: v004 + - kgo_version: v005 defaults: run: shell: bash -el {0} From 55096d1f909867bec6d3da076253d4b7ae5a1edd Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 3 Sep 2025 11:30:17 -0600 Subject: [PATCH 155/159] remove nchan reference --- driver/src/cosp2_test.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver/src/cosp2_test.F90 b/driver/src/cosp2_test.F90 index 033d7b4ba5..3f04be1722 100755 --- a/driver/src/cosp2_test.F90 +++ b/driver/src/cosp2_test.F90 @@ -1283,7 +1283,7 @@ subroutine construct_cosp_outputs(Lpctisccp,Lclisccp,& Lptradarflag6,Lptradarflag7,Lptradarflag8, & Lptradarflag9,Lradarpia,Lwr_occfreq,Lcfodd, & Ninst_rttov,rttov_configs, & - Npoints,Ncolumns,Nlevels,Nlvgrid,Nchan,use_vgrid,x) + Npoints,Ncolumns,Nlevels,Nlvgrid,use_vgrid,x) ! Inputs logical,intent(in) :: & Lpctisccp, & ! ISCCP mean cloud top pressure From a83824ea7c5969a8a3c76a13ad09d020fe3d5214 Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 3 Sep 2025 13:28:39 -0600 Subject: [PATCH 156/159] Remove non-essential namelist fields and old rttov interface files. --- cospsimulator_intr.F90 | 4690 ----------------- .../cosp2_input_AIRS_L1C_validation_nl.txt | 110 - driver/run/cosp2_input_iasi_nl.txt | 0 .../run/cosp2_input_rrtmg_validation_nl.txt | 113 - driver/run/cosp2_input_rttov_nl.txt | 117 - driver/run/cosp2_input_rttov_nl.um_global.txt | 90 - driver/run/cosp2_input_rttov_swathleak_nl.txt | 109 - driver/run/cosp2_output_AIRS_L1C_nl.txt | 152 - driver/run/cosp2_output_iasi_nl.txt | 152 - driver/run/cosp2_output_pcrttov_nl.txt | 152 - driver/run/cosp2_output_rttov_nl.txt | 152 - .../run/cosp2_output_rttov_swathleak_nl.txt | 152 - driver/run/cosp2_pcrttov_nl.txt | 62 - driver/run/cosp2_rttov_nl.txt | 59 - .../cosp2_rttov_AIRS_L1C_CESM2.txt | 85 - .../cosp2_rttov_AIRS_L1C_CESM2_asc.txt | 85 - .../cosp2_rttov_AIRS_L1C_CESM2_des.txt | 85 - .../cosp2_rttov_AIRS_L1C_SCAMval.txt | 84 - .../cosp2_rttov_AIRS_L1C_val1.txt | 75 - .../cosp2_rttov_AIRS_L1C_val2.txt | 75 - .../cosp2_rttov_AIRS_L1C_val3.txt | 79 - .../cosp2_rttov_FORUM_CESM2_val1.txt | 75 - .../cosp2_rttov_FORUM_CESM2_val2.txt | 75 - .../cosp2_rttov_FORUM_CESM2_val3.txt | 75 - .../cosp2_rttov_IASI_CESM2_val.txt | 78 - .../cosp2_rttov_IASI_CESM2_val1.txt | 78 - .../cosp2_rttov_IASI_CESM2_val2.txt | 78 - .../cosp2_rttov_IASI_CESM2_val3.txt | 78 - .../run/instrument_nls/cosp2_rttov_inst1.txt | 85 - .../run/instrument_nls/cosp2_rttov_inst2.txt | 80 - .../run/instrument_nls/cosp2_rttov_inst3.txt | 77 - .../run/instrument_nls/cosp2_rttov_inst4.txt | 79 - .../cosp2_rttov_inst5_PREFIRE_CESM2.txt | 89 - .../cosp2_rttov_inst6_AIRS_CESM2.txt | 86 - .../cosp2_rttov_inst6_AIRS_CESM2_bin.txt | 84 - .../cosp2_rttov_inst7_VIIRS_CESM2.txt | 87 - ...osp2_input_rrtmg_6stream_validation_nl.txt | 110 - .../cosp2_rttov_FORUM_CESM2_vza1.txt | 84 - .../cosp2_rttov_FORUM_CESM2_vza2.txt | 84 - .../cosp2_rttov_FORUM_CESM2_vza3.txt | 84 - .../cosp2_rttov_FORUM_CESM2_vza4.txt | 84 - .../cosp2_rttov_FORUM_CESM2_vza5.txt | 84 - .../cosp2_rttov_FORUM_CESM2_vza6.txt | 84 - .../cosp2_rttov_IASI_CESM2_vza1.txt | 85 - .../cosp2_rttov_IASI_CESM2_vza2.txt | 85 - .../cosp2_rttov_IASI_CESM2_vza3.txt | 85 - .../cosp2_rttov_IASI_CESM2_vza4.txt | 85 - .../cosp2_rttov_IASI_CESM2_vza5.txt | 85 - .../cosp2_rttov_IASI_CESM2_vza6.txt | 85 - driver/run/rttov_channel_input2.csv | 100 - driver/run/rttov_channel_input_AIRS.csv | 2500 --------- .../rttov_channel_input_AIRSL1C_subset.csv | 45 - .../run/rttov_channel_input_AIRS_subset.csv | 26 - driver/run/rttov_channel_input_MODIS16.csv | 16 - .../rttov_channel_input_PREFIRE_subset.csv | 55 - .../run/rttov_channel_input_VIIRS_subset.csv | 2 - src/simulator/rttov/cosp_rttov.F90 | 592 --- src/simulator/rttov/cosp_rttov11.F90 | 1060 ---- 58 files changed, 13402 deletions(-) delete mode 100644 cospsimulator_intr.F90 delete mode 100644 driver/run/cosp2_input_AIRS_L1C_validation_nl.txt delete mode 100644 driver/run/cosp2_input_iasi_nl.txt delete mode 100644 driver/run/cosp2_input_rrtmg_validation_nl.txt delete mode 100644 driver/run/cosp2_input_rttov_nl.txt delete mode 100644 driver/run/cosp2_input_rttov_nl.um_global.txt delete mode 100644 driver/run/cosp2_input_rttov_swathleak_nl.txt delete mode 100644 driver/run/cosp2_output_AIRS_L1C_nl.txt delete mode 100644 driver/run/cosp2_output_iasi_nl.txt delete mode 100644 driver/run/cosp2_output_pcrttov_nl.txt delete mode 100755 driver/run/cosp2_output_rttov_nl.txt delete mode 100644 driver/run/cosp2_output_rttov_swathleak_nl.txt delete mode 100644 driver/run/cosp2_pcrttov_nl.txt delete mode 100644 driver/run/cosp2_rttov_nl.txt delete mode 100644 driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2.txt delete mode 100644 driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2_asc.txt delete mode 100644 driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2_des.txt delete mode 100644 driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_SCAMval.txt delete mode 100644 driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val1.txt delete mode 100644 driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val2.txt delete mode 100644 driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val3.txt delete mode 100644 driver/run/instrument_nls/cosp2_rttov_FORUM_CESM2_val1.txt delete mode 100644 driver/run/instrument_nls/cosp2_rttov_FORUM_CESM2_val2.txt delete mode 100644 driver/run/instrument_nls/cosp2_rttov_FORUM_CESM2_val3.txt delete mode 100644 driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val.txt delete mode 100644 driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val1.txt delete mode 100644 driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val2.txt delete mode 100644 driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val3.txt delete mode 100644 driver/run/instrument_nls/cosp2_rttov_inst1.txt delete mode 100644 driver/run/instrument_nls/cosp2_rttov_inst2.txt delete mode 100644 driver/run/instrument_nls/cosp2_rttov_inst3.txt delete mode 100644 driver/run/instrument_nls/cosp2_rttov_inst4.txt delete mode 100644 driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt delete mode 100644 driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2.txt delete mode 100644 driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt delete mode 100644 driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt delete mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_input_rrtmg_6stream_validation_nl.txt delete mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt delete mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt delete mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt delete mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt delete mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt delete mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt delete mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt delete mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt delete mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt delete mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt delete mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt delete mode 100644 driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt delete mode 100644 driver/run/rttov_channel_input2.csv delete mode 100644 driver/run/rttov_channel_input_AIRS.csv delete mode 100644 driver/run/rttov_channel_input_AIRSL1C_subset.csv delete mode 100644 driver/run/rttov_channel_input_AIRS_subset.csv delete mode 100644 driver/run/rttov_channel_input_MODIS16.csv delete mode 100644 driver/run/rttov_channel_input_PREFIRE_subset.csv delete mode 100644 driver/run/rttov_channel_input_VIIRS_subset.csv delete mode 100644 src/simulator/rttov/cosp_rttov.F90 delete mode 100644 src/simulator/rttov/cosp_rttov11.F90 diff --git a/cospsimulator_intr.F90 b/cospsimulator_intr.F90 deleted file mode 100644 index eb8c97a387..0000000000 --- a/cospsimulator_intr.F90 +++ /dev/null @@ -1,4690 +0,0 @@ -module cospsimulator_intr - ! ###################################################################################### - ! Purpose: CAM interface to - ! Name: CFMIP Observational Simulator Package Version 2 (COSP2) - ! What: Simulate ISCCP/CloudSat/CALIPSO/MISR/MODIS cloud products from - ! GCM inputs - ! Version: v2.1.4 (August 2019) - ! Authors: Dustin Swales (dustin.swales@noaa.gov) - ! - ! Modifications: - ! - ! ###################################################################################### - use shr_kind_mod, only: r8 => shr_kind_r8 - use spmd_utils, only: masterproc - use ppgrid, only: pcols, pver, pverp, begchunk, endchunk - use perf_mod, only: t_startf, t_stopf, t_adj_detailf - use cam_abortutils, only: endrun - use phys_control, only: cam_physpkg_is - use cam_logfile, only: iulog -#ifdef USE_COSP - use quickbeam, only: radar_cfg - use mod_quickbeam_optics, only: size_distribution - use mod_cosp, only: cosp_outputs,cosp_optical_inputs,cosp_column_inputs - use mod_cosp_config, only: pres_binCenters, pres_binEdges, tau_binCenters, & - tau_binEdges, cloudsat_binCenters, cloudsat_binEdges, calipso_binCenters, & - calipso_binEdges, misr_histHgtCenters, misr_histHgtEdges, PARASOL_SZA, & - R_UNDEF, PARASOL_NREFL, LIDAR_NCAT,SR_BINS, N_HYDRO, & - numMISRHgtBins, CLOUDSAT_DBZE_BINS, LIDAR_NTEMP, calipso_histBsct, & - numMODISTauBins, numMODISPresBins, numMODISReffIceBins, numMODISReffLiqBins, & - numISCCPTauBins, numISCCPPresBins, numMISRTauBins, reffICE_binEdges, & - reffICE_binCenters, reffLIQ_binEdges, reffLIQ_binCenters, LIDAR_NTYPE, & - nCloudsatPrecipClass, & - nsza_cosp => PARASOL_NREFL, & - nprs_cosp => npres, & - ntau_cosp => ntau, & - ntau_cosp_modis => ntau, & - nsr_cosp => SR_BINS, & - nhtmisr_cosp => numMISRHgtBins, & - nhydro => N_HYDRO, & - cloudsat_preclvl - use mod_cosp_stats, only: cosp_change_vertical_grid - use mod_cosp_rttov_interface, only: rttov_cfg ! JKS -#endif - implicit none - private - save - - ! Public functions/subroutines - public :: & - cospsimulator_intr_readnl, & - cospsimulator_intr_register,& - cospsimulator_intr_init, & - cospsimulator_intr_run - - ! ###################################################################################### - ! Public declarations - ! ###################################################################################### - ! Whether to do COSP calcs and I/O, default is false. If docosp is specified in - ! the atm_in namelist, this value is overwritten and cosp is run - logical, public :: docosp = .false. - - ! Frequency at which cosp is called, every cosp_nradsteps radiation timestep - integer, public :: cosp_nradsteps = 1! CAM namelist variable default, not in COSP namelist - -#ifdef USE_COSP - - ! ###################################################################################### - ! Local declarations - ! ###################################################################################### - integer, parameter :: & - nhtml_cosp = pver ! Mumber of model levels is pver - integer :: & - nscol_cosp, & ! Number of subcolumns, use namelist input Ncolumns to set. - nht_cosp ! Number of height for COSP radar and calipso simulator outputs. - ! *set to 40 if csat_vgrid=.true., else set to Nlr* - - ! ###################################################################################### - ! Bin-boundaries for mixed dimensions. Calculated in cospsetupvales OR in cosp_config.F90 - ! ###################################################################################### - real(r8), target :: prsmid_cosp(nprs_cosp) ! pressure midpoints of COSP ISCCP output - real(r8), target :: prslim_cosp(2,nprs_cosp) - real(r8), target :: taumid_cosp(ntau_cosp) ! optical depth midpoints of COSP ISCCP output - real(r8), target :: taulim_cosp(2,ntau_cosp) - real(r8), target :: srmid_cosp(nsr_cosp) ! sr midpoints of COSP lidar output - real(r8), target :: srlim_cosp(2,nsr_cosp) - real(r8), target :: sza_cosp(nsza_cosp) - real(r8), target :: dbzemid_cosp(CLOUDSAT_DBZE_BINS) ! dbze midpoints of COSP radar output - real(r8), target :: dbzelim_cosp(2,CLOUDSAT_DBZE_BINS) - real(r8), target :: htmisrmid_cosp(nhtmisr_cosp) ! htmisr midpoints of COSP misr simulator output - real(r8), target :: htmisrlim_cosp(2,nhtmisr_cosp) - real(r8), target :: taumid_cosp_modis(ntau_cosp_modis)! optical depth midpoints of COSP MODIS output - real(r8), target :: taulim_cosp_modis(2,ntau_cosp_modis) - real(r8), target :: reffICE_binEdges_cosp(2,numMODISReffIceBins) - real(r8), target :: reffLIQ_binEdges_cosp(2,numMODISReffLiqBins) - real(r8), target :: reffICE_binCenters_cosp(numMODISReffIceBins) - real(r8), target :: reffLIQ_binCenters_cosp(numMODISReffLiqBins) - - real(r8) :: htmlmid_cosp(nhtml_cosp) ! Model level height midpoints for output - integer :: prstau_cosp(nprs_cosp*ntau_cosp) ! ISCCP mixed output dimension index - integer :: prstau_cosp_modis(nprs_cosp*ntau_cosp_modis) ! MODIS mixed output dimension index - integer :: htmisrtau_cosp(nhtmisr_cosp*ntau_cosp) ! MISR mixed output dimension index - real(r8) :: prstau_prsmid_cosp(nprs_cosp*ntau_cosp) - real(r8) :: prstau_taumid_cosp(nprs_cosp*ntau_cosp) - real(r8) :: prstau_prsmid_cosp_modis(nprs_cosp*ntau_cosp_modis) - real(r8) :: prstau_taumid_cosp_modis(nprs_cosp*ntau_cosp_modis) - real(r8) :: htmisrtau_htmisrmid_cosp(nhtmisr_cosp*ntau_cosp) - real(r8) :: htmisrtau_taumid_cosp(nhtmisr_cosp*ntau_cosp) - real(r8),allocatable, public :: htdbze_dbzemid_cosp(:) ! (nht_cosp*CLOUDSAT_DBZE_BINS) - real(r8),allocatable, target :: htlim_cosp(:,:) ! height limits for COSP outputs (nht_cosp+1) - real(r8),allocatable, target :: htmid_cosp(:) ! height midpoints of COSP radar/lidar output (nht_cosp) - real(r8),allocatable :: htlim_cosp_1d(:) ! height limits for COSP outputs (nht_cosp+1) - real(r8),allocatable :: htdbze_htmid_cosp(:) ! (nht_cosp*CLOUDSAT_DBZE_BINS) - real(r8),allocatable :: htsr_htmid_cosp(:) ! (nht_cosp*nsr_cosp) - real(r8),allocatable :: htsr_srmid_cosp(:) ! (nht_cosp*nsr_cosp) - real(r8),allocatable :: htmlscol_htmlmid_cosp(:) ! (nhtml_cosp*nscol_cosp) - real(r8),allocatable :: htmlscol_scol_cosp(:) ! (nhtml_cosp*nscol_cosp) - integer, allocatable, target :: scol_cosp(:) ! sub-column number (nscol_cosp) - integer, allocatable :: htdbze_cosp(:) ! radar CFAD mixed output dimension index (nht_cosp*CLOUDSAT_DBZE_BINS) - integer, allocatable :: htsr_cosp(:) ! lidar CFAD mixed output dimension index (nht_cosp*nsr_cosp) - integer, allocatable :: htmlscol_cosp(:) ! html-subcolumn mixed output dimension index (nhtml_cosp*nscol_cosp) - - ! ###################################################################################### - ! Default namelists - ! The CAM and COSP namelists defaults are set below. Some of the COSP namelist - ! variables are part of the CAM namelist - they all begin with "cosp_" to keep their - ! names specific to COSP. I set their CAM namelist defaults here, not in namelist_defaults_cam.xml - ! Variables identified as namelist variables are defined in - ! ../models/atm/cam/bld/namelist_files/namelist_definition.xml - ! ###################################################################################### - ! CAM - logical :: cosp_amwg = .false. ! CAM namelist variable default, not in COSP namelist - logical :: cosp_lite = .false. ! CAM namelist variable default, not in COSP namelist - logical :: cosp_passive = .false. ! CAM namelist variable default, not in COSP namelist - logical :: cosp_active = .false. ! CAM namelist variable default, not in COSP namelist - logical :: cosp_isccp = .false. ! CAM namelist variable default, not in COSP namelist - logical :: cosp_lradar_sim = .false. ! CAM namelist variable default - logical :: cosp_llidar_sim = .false. ! CAM namelist variable default - logical :: cosp_lisccp_sim = .false. ! CAM namelist variable default - logical :: cosp_lmisr_sim = .false. ! CAM namelist variable default - logical :: cosp_lmodis_sim = .false. ! CAM namelist variable default - logical :: cosp_lrttov_sim = .false. ! CAM namelist variable default - logical :: cosp_histfile_aux = .false. ! CAM namelist variable default - logical :: cosp_lfrac_out = .false. ! CAM namelist variable default - logical :: cosp_runall = .false. ! flag to run all of the cosp simulator package - integer :: cosp_ncolumns = 50 ! CAM namelist variable default - integer :: cosp_histfile_num =1 ! CAM namelist variable default, not in COSP namelist - integer :: cosp_histfile_aux_num =-1 ! CAM namelist variable default, not in COSP namelist - - ! COSP - logical :: lradar_sim = .false. ! COSP namelist variable, can be changed from default by CAM namelist - logical :: llidar_sim = .false. ! - logical :: lparasol_sim = .false. ! - logical :: lgrLidar532 = .false. ! - logical :: latlid = .false. ! - logical :: lisccp_sim = .false. ! "" - logical :: lmisr_sim = .false. ! "" - logical :: lmodis_sim = .false. ! "" - logical :: lrttov_sim = .false. ! not running rttov, always set to .false. - logical :: lfrac_out = .false. ! COSP namelist variable, can be changed from default by CAM namelist - - ! ###################################################################################### - ! COSP parameters - ! ###################################################################################### - ! Note: Unless otherwise specified, these are parameters that cannot be set by the CAM namelist. - integer, parameter :: Npoints_it = 10000 ! Max # gridpoints to be processed in one iteration (10,000) - integer :: ncolumns = 50 ! Number of subcolumns in SCOPS (50), can be changed from default by CAM namelist - integer :: nlr = 40 ! Number of levels in statistical outputs - ! (only used if USE_VGRID=.true.) (40) - logical :: use_vgrid = .true. ! Use fixed vertical grid for outputs? - ! (if .true. then define # of levels with nlr) (.true.) - logical :: csat_vgrid = .true. ! CloudSat vertical grid? - ! (if .true. then the CloudSat standard grid is used. - ! If set, overides use_vgrid.) (.true.) - ! namelist variables for COSP input related to radar simulator - real(r8) :: radar_freq = 94.0_r8 ! CloudSat radar frequency (GHz) (94.0) - integer :: surface_radar = 0 ! surface=1, spaceborne=0 (0) - integer :: use_mie_tables = 0 ! use a precomputed lookup table? yes=1,no=0 (0) - integer :: use_gas_abs = 1 ! include gaseous absorption? yes=1,no=0 (1) - integer :: do_ray = 0 ! calculate/output Rayleigh refl=1, not=0 (0) - integer :: melt_lay = 0 ! melting layer model off=0, on=1 (0) - real(r8) :: k2 = -1 ! |K|^2, -1=use frequency dependent default (-1) - ! namelist variables for COSP input related to lidar simulator - integer, parameter :: Nprmts_max_hydro = 12 ! Max # params for hydrometeor size distributions (12) - integer, parameter :: Naero = 1 ! Number of aerosol species (Not used) (1) - integer, parameter :: Nprmts_max_aero = 1 ! Max # params for aerosol size distributions (not used) (1) - integer :: lidar_ice_type = 0 ! Ice particle shape in lidar calculations - ! (0=ice-spheres ; 1=ice-non-spherical) (0) - integer, parameter :: overlap = 3 ! overlap type: 1=max, 2=rand, 3=max/rand (3) - - !! namelist variables for COSP input related to ISCCP simulator - integer :: isccp_topheight = 1 ! 1 = adjust top height using both a computed infrared - ! brightness temperature and the visible - ! optical depth to adjust cloud top pressure. - ! Note that this calculation is most appropriate to compare - ! to ISCCP data during sunlit hours. - ! 2 = do not adjust top height, that is cloud top pressure - ! is the actual cloud top pressure in the model - ! 3 = adjust top height using only the computed infrared - ! brightness temperature. Note that this calculation is most - ! appropriate to compare to ISCCP IR only algortihm (i.e. - ! you can compare to nighttime ISCCP data with this option) (1) - integer :: isccp_topheight_direction = 2 ! direction for finding atmosphere pressure level with - ! interpolated temperature equal to the radiance - ! determined cloud-top temperature - ! 1 = find the *lowest* altitude (highest pressure) level - ! with interpolated temperature - ! equal to the radiance determined cloud-top temperature - ! 2 = find the *highest* altitude (lowest pressure) level - ! with interpolated temperature - ! equal to the radiance determined cloud-top temperature - ! ONLY APPLICABLE IF top_height EQUALS 1 or 3 - ! 1 = default setting in COSP v1.1, matches all versions of - ! ISCCP simulator with versions numbers 3.5.1 and lower - ! 2 = default setting in COSP v1.3. default since V4.0 of ISCCP simulator - - ! ###################################################################################### - ! Other variables - ! ###################################################################################### - logical,allocatable :: first_run_cosp(:) !.true. if run_cosp has been populated (allocatable->begchunk:endchunk) - logical,allocatable :: run_cosp(:,:) !.true. if cosp should be run by column and - ! chunk (allocatable->1:pcols,begchunk:endchunk) - ! pbuf indices - integer :: cld_idx, concld_idx, lsreffrain_idx, lsreffsnow_idx, cvreffliq_idx - integer :: cvreffice_idx, dpcldliq_idx, dpcldice_idx - integer :: shcldliq_idx, shcldice_idx, shcldliq1_idx, shcldice1_idx, dpflxprc_idx - integer :: dpflxsnw_idx, shflxprc_idx, shflxsnw_idx, lsflxprc_idx, lsflxsnw_idx - integer :: rei_idx, rel_idx -! integer :: ubot_idx, vbot_idx - - ! ###################################################################################### - ! Declarations specific to COSP2 - ! ###################################################################################### - type(radar_cfg) :: rcfg_cloudsat ! Radar configuration (Cloudsat) - type(radar_cfg), allocatable :: rcfg_cs(:) ! chunked version of rcfg_cloudsat - type(rttov_cfg), allocatable, target :: rttov_configs(:) ! Chunked RTTOV configuration - type(size_distribution) :: sd ! Size distribution used by radar simulator - type(size_distribution), allocatable :: sd_cs(:) ! chunked version of sd - character(len=64) :: cloudsat_micro_scheme = 'MMF_v3.5_single_moment' - - ! JKS hardcoding RTTOV features in initial functionality - character(len=256), dimension(50) :: rttov_instrument_namelists != 'None' ! Input of paths to RTTOV instrument namelists - - integer :: rttov_Ninstruments = 0 ! Default is zero - - integer,parameter :: & - I_LSCLIQ = 1, & ! Large-scale (stratiform) liquid - I_LSCICE = 2, & ! Large-scale (stratiform) ice - I_LSRAIN = 3, & ! Large-scale (stratiform) rain - I_LSSNOW = 4, & ! Large-scale (stratiform) snow - I_CVCLIQ = 5, & ! Convective liquid - I_CVCICE = 6, & ! Convective ice - I_CVRAIN = 7, & ! Convective rain - I_CVSNOW = 8, & ! Convective snow - I_LSGRPL = 9 ! Large-scale (stratiform) groupel - - ! Stratiform and convective clouds in frac_out (scops output). - integer, parameter :: & - I_LSC = 1, & ! Large-scale clouds - I_CVC = 2 ! Convective clouds - - ! Microphysical settings for the precipitation flux to mixing ratio conversion - real(r8),parameter,dimension(nhydro) :: & - ! LSL LSI LSR LSS CVL CVI CVR CVS LSG - N_ax = (/-1._r8, -1._r8, 8.e6_r8, 3.e6_r8, -1._r8, -1._r8, 8.e6_r8, 3.e6_r8, 4.e6_r8/),& - N_bx = (/-1._r8, -1._r8, 0.0_r8, 0.0_r8, -1._r8, -1._r8, 0.0_r8, 0.0_r8, 0.0_r8/),& - alpha_x = (/-1._r8, -1._r8, 0.0_r8, 0.0_r8, -1._r8, -1._r8, 0.0_r8, 0.0_r8, 0.0_r8/),& - c_x = (/-1._r8, -1._r8, 842.0_r8, 4.84_r8, -1._r8, -1._r8, 842.0_r8, 4.84_r8, 94.5_r8/),& - d_x = (/-1._r8, -1._r8, 0.8_r8, 0.25_r8, -1._r8, -1._r8, 0.8_r8, 0.25_r8, 0.5_r8/),& - g_x = (/-1._r8, -1._r8, 0.5_r8, 0.5_r8, -1._r8, -1._r8, 0.5_r8, 0.5_r8, 0.5_r8/),& - a_x = (/-1._r8, -1._r8, 524.0_r8, 52.36_r8, -1._r8, -1._r8, 524.0_r8, 52.36_r8, 209.44_r8/),& - b_x = (/-1._r8, -1._r8, 3.0_r8, 3.0_r8, -1._r8, -1._r8, 3.0_r8, 3.0_r8, 3.0_r8/),& - gamma_1 = (/-1._r8, -1._r8, 17.83725_r8, 8.284701_r8, -1._r8, -1._r8, 17.83725_r8, 8.284701_r8, 11.63230_r8/),& - gamma_2 = (/-1._r8, -1._r8, 6.0_r8, 6.0_r8, -1._r8, -1._r8, 6.0_r8, 6.0_r8, 6.0_r8/),& - gamma_3 = (/-1._r8, -1._r8, 2.0_r8, 2.0_r8, -1._r8, -1._r8, 2.0_r8, 2.0_r8, 2.0_r8/),& - gamma_4 = (/-1._r8, -1._r8, 6.0_r8, 6.0_r8, -1._r8, -1._r8, 6.0_r8, 6.0_r8, 6.0_r8/) - - type rttov_output_write - integer :: & - nchan_out -! integer,allocatable :: & -! channel_indices(:) - real(r8),allocatable :: & - bt_total(:,:), & - bt_clear(:,:), & - rad_total(:,:), & - rad_clear(:,:), & - rad_cloudy(:,:), & - refl_total(:,:), & - refl_clear(:,:), & - bt_total_pc(:,:), & - rad_total_pc(:,:) - end type rttov_output_write - -#endif - -CONTAINS - - ! ###################################################################################### - ! SUBROUTINE setcosp2values - ! ###################################################################################### -#ifdef USE_COSP - subroutine setcosp2values(Nlr_in,use_vgrid_in,csat_vgrid_in,Ncolumns_in,cosp_nradsteps_in) - use mod_cosp, only: cosp_init - use mod_cosp_config, only: vgrid_zl, vgrid_zu, vgrid_z - use mod_quickbeam_optics, only: hydro_class_init, quickbeam_optics_init - - use units, only: getunit, freeunit ! JKS testing - - - ! Inputs - integer, intent(in) :: Nlr_in ! Number of vertical levels for CALIPSO and Cloudsat products - integer, intent(in) :: Ncolumns_in ! Number of sub-columns - integer, intent(in) :: cosp_nradsteps_in ! How often to call COSP? - logical, intent(in) :: use_vgrid_in ! Logical switch to use interpolated, to Nlr_in, grid for CALIPSO and Cloudsat - logical, intent(in) :: csat_vgrid_in ! - - ! Local - logical :: ldouble=.false. - logical :: lsingle=.true. ! Default is to use single moment - integer :: i,k, unitn ! JKS testing - - character(len=256), allocatable :: rttov_instrument_namelists_final(:) -! type(character(len=256)), allocatable :: & -! rttov_instrument_namelists_final(:) ! Array of paths to RTTOV instrument namelists - - prsmid_cosp = pres_binCenters - prslim_cosp = pres_binEdges - taumid_cosp = tau_binCenters - taulim_cosp = tau_binEdges - srmid_cosp = calipso_binCenters - srlim_cosp = calipso_binEdges - sza_cosp = parasol_sza - dbzemid_cosp = cloudsat_binCenters - dbzelim_cosp = cloudsat_binEdges - htmisrmid_cosp = misr_histHgtCenters - htmisrlim_cosp = misr_histHgtEdges - taumid_cosp_modis = tau_binCenters - taulim_cosp_modis = tau_binEdges - reffICE_binCenters_cosp = reffICE_binCenters - reffICE_binEdges_cosp = reffICE_binEdges - reffLIQ_binCenters_cosp = reffLIQ_binCenters - reffLIQ_binEdges_cosp = reffLIQ_binEdges - - ! Initialize the distributional parameters for hydrometeors in radar simulator. In COSPv1.4, this was declared in - ! cosp_defs.f. - if (cloudsat_micro_scheme == 'MMF_v3.5_two_moment') then - ldouble = .true. - lsingle = .false. - endif - call hydro_class_init(lsingle,ldouble,sd) - call quickbeam_optics_init() - - ! DS2017: The setting up of the vertical grid for regridding the CALIPSO and Cloudsat products is - ! now donein cosp_init, but these fields are stored in cosp_config.F90. - ! Additionally all static fields used by the individual simulators are set up by calls - ! to _init functions in cosp_init. - ! DS2019: Add logicals, default=.false., for new Lidar simuldators (Earthcare (atlid) and ground-based - ! lidar at 532nm) - - ! JKS adding flexible namelist I/O - if (masterproc) then ! Write to the atm log. - write(iulog,*)'rttov_Ninstruments: ',rttov_Ninstruments - write(iulog,*)' ' - end if - - allocate(rttov_instrument_namelists_final(rttov_Ninstruments)) - rttov_instrument_namelists_final(:) = rttov_instrument_namelists(1:rttov_Ninstruments) - -! if (rttov_Ninstruments .eq. 1) then -! rttov_instrument_namelists_final(1) = rttov_instrument_namelists -! else -! rttov_instrument_namelists_final(1:rttov_Ninstruments) = rttov_instrument_namelists -! end if - - if (masterproc) then ! Write to the atm log. - write(iulog,*)'cosp_lrttov_sim: ',cosp_lrttov_sim - write(iulog,*)'Lrttov_sim: ',Lrttov_sim - write(iulog,*)'rttov_Ninstruments: ',rttov_Ninstruments - write(iulog,*)'rttov_instrument_namelists_final: ',rttov_instrument_namelists_final - write(iulog,*)' ' - end if - deallocate(rttov_instrument_namelists_final) - ! JKS end adding flexible namelist I/O - - ! JKS - hardcoding initial functionality. - rttov_Ninstruments = 1 !2 !3 - allocate(rttov_instrument_namelists_final(rttov_Ninstruments)) - rttov_instrument_namelists(:) = '' ! Initialize?? - rttov_instrument_namelists_final(1:1) = (/'instrument_nls/cosp2_rttov_inst1.txt'/) -! rttov_instrument_namelists_final(1:2) = (/'instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst3.txt'/) -! rttov_instrument_namelists_final(1:3) = (/'instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt'/) - - - ! rttov_Ninstruments and rttov_instrument_namelists should have been broadcast to all processors when namelists were read - -! allocate(rttov_instrument_namelists_final(rttov_Ninstruments)) -! rttov_instrument_namelists_final(:) = rttov_instrument_namelists(1:rttov_Ninstruments) - - if (masterproc) then ! Write to the atm log. - write(iulog,*)'cosp_lrttov_sim: ',cosp_lrttov_sim - write(iulog,*)'Lrttov_sim: ',Lrttov_sim - write(iulog,*)'rttov_Ninstruments: ',rttov_Ninstruments - write(iulog,*)'rttov_instrument_namelists_final: ',rttov_instrument_namelists_final - write(iulog,*)' ' - end if - - unitn = getunit() ! JKS handle many files. - - call COSP_INIT(Lisccp_sim, Lmodis_sim, Lmisr_sim, Lradar_sim, Llidar_sim, LgrLidar532, & - Latlid, Lparasol_sim, Lrttov_sim, radar_freq, k2, use_gas_abs, do_ray, & - isccp_topheight, isccp_topheight_direction, surface_radar, rcfg_cloudsat, & - use_vgrid_in, csat_vgrid_in, Nlr_in, pver, cloudsat_micro_scheme, & - rttov_Ninstruments, rttov_instrument_namelists_final, rttov_configs,unitn=unitn) ! JKS add functionality for multiple files - ! Could add mpi commands here to parallelize load coefficients if slow. - ! Yes, this should really only be run on the main processor, but I might need to bcast everything since the call is wrapped around all of COSP. - ! Could be done a few different ways. - call freeunit(unitn) ! JKS handle many files - deallocate(rttov_instrument_namelists_final) - - ! Set number of sub-columns, from namelist - nscol_cosp = Ncolumns_in - - if (use_vgrid_in) then !! using fixed vertical grid - if (csat_vgrid_in) then - nht_cosp = 40 - else - nht_cosp = Nlr_in - endif - endif - - ! Set COSP call frequency, from namelist. - cosp_nradsteps = cosp_nradsteps_in - - ! DJS2017: In COSP2, most of the bin boundaries, centers, and edges are declared in src/cosp_config.F90. - ! Above I just assign them accordingly in the USE statement. Other bin bounds needed by CAM - ! are calculated here. - ! Allocate - allocate(htlim_cosp(2,nht_cosp),htlim_cosp_1d(nht_cosp+1),htmid_cosp(nht_cosp),scol_cosp(nscol_cosp), & - htdbze_cosp(nht_cosp*CLOUDSAT_DBZE_BINS),htsr_cosp(nht_cosp*nsr_cosp),htmlscol_cosp(nhtml_cosp*nscol_cosp),& - htdbze_htmid_cosp(nht_cosp*CLOUDSAT_DBZE_BINS),htdbze_dbzemid_cosp(nht_cosp*CLOUDSAT_DBZE_BINS), & - htsr_htmid_cosp(nht_cosp*nsr_cosp),htsr_srmid_cosp(nht_cosp*nsr_cosp), & - htmlscol_htmlmid_cosp(nhtml_cosp*nscol_cosp),htmlscol_scol_cosp(nhtml_cosp*nscol_cosp)) - - ! DJS2017: Just pull from cosp_config - if (use_vgrid_in) then - htlim_cosp_1d(1) = vgrid_zu(1) - htlim_cosp_1d(2:nht_cosp+1) = vgrid_zl - endif - htmid_cosp = vgrid_z - htlim_cosp(1,:) = vgrid_zu - htlim_cosp(2,:) = vgrid_zl - - scol_cosp(:) = (/(k,k=1,nscol_cosp)/) - - ! Just using an index here, model height is a prognostic variable - htmlmid_cosp(:) = (/(k,k=1,nhtml_cosp)/) - - ! assign mixed dimensions an integer index for cam_history.F90 - do k=1,nprs_cosp*ntau_cosp - prstau_cosp(k) = k - end do - do k=1,nprs_cosp*ntau_cosp_modis - prstau_cosp_modis(k) = k - end do - do k=1,nht_cosp*CLOUDSAT_DBZE_BINS - htdbze_cosp(k) = k - end do - do k=1,nht_cosp*nsr_cosp - htsr_cosp(k) = k - end do - do k=1,nhtml_cosp*nscol_cosp - htmlscol_cosp(k) = k - end do - do k=1,nhtmisr_cosp*ntau_cosp - htmisrtau_cosp(k) = k - end do - - ! next, assign collapsed reference vectors for cam_history.F90 - ! convention for saving output = prs1,tau1 ... prs1,tau7 ; prs2,tau1 ... prs2,tau7 etc. - ! actual output is specified in cospsimulator1_intr.F90 - do k=1,nprs_cosp - prstau_taumid_cosp(ntau_cosp*(k-1)+1:k*ntau_cosp)=taumid_cosp(1:ntau_cosp) - prstau_prsmid_cosp(ntau_cosp*(k-1)+1:k*ntau_cosp)=prsmid_cosp(k) - prstau_taumid_cosp_modis(ntau_cosp_modis*(k-1)+1:k*ntau_cosp_modis)=taumid_cosp_modis(1:ntau_cosp_modis) - prstau_prsmid_cosp_modis(ntau_cosp_modis*(k-1)+1:k*ntau_cosp_modis)=prsmid_cosp(k) - enddo - - do k=1,nht_cosp - htdbze_dbzemid_cosp(CLOUDSAT_DBZE_BINS*(k-1)+1:k*CLOUDSAT_DBZE_BINS)=dbzemid_cosp(1:CLOUDSAT_DBZE_BINS) - htdbze_htmid_cosp(CLOUDSAT_DBZE_BINS*(k-1)+1:k*CLOUDSAT_DBZE_BINS)=htmid_cosp(k) - enddo - - do k=1,nht_cosp - htsr_srmid_cosp(nsr_cosp*(k-1)+1:k*nsr_cosp)=srmid_cosp(1:nsr_cosp) - htsr_htmid_cosp(nsr_cosp*(k-1)+1:k*nsr_cosp)=htmid_cosp(k) - enddo - - do k=1,nhtml_cosp - htmlscol_scol_cosp(nscol_cosp*(k-1)+1:k*nscol_cosp)=scol_cosp(1:nscol_cosp) - htmlscol_htmlmid_cosp(nscol_cosp*(k-1)+1:k*nscol_cosp)=htmlmid_cosp(k) - enddo - - do k=1,nhtmisr_cosp - htmisrtau_taumid_cosp(ntau_cosp*(k-1)+1:k*ntau_cosp)=taumid_cosp(1:ntau_cosp) - htmisrtau_htmisrmid_cosp(ntau_cosp*(k-1)+1:k*ntau_cosp)=htmisrmid_cosp(k) - enddo - - end subroutine setcosp2values -#endif - - ! ###################################################################################### - ! SUBROUTINE cospsimulator_intr_readnl - ! - ! PURPOSE: to read namelist variables and run setcospvalues subroutine.note: cldfrc_readnl - ! is a good template in cloud_fraction.F90. Make sure that this routine is reading in a - ! namelist. models/atm/cam/bld/build-namelist is the perl script to check. - ! ###################################################################################### - subroutine cospsimulator_intr_readnl(nlfile) - use namelist_utils, only: find_group_name - use units, only: getunit, freeunit -#ifdef SPMD - use mpishorthand, only: mpicom, mpilog, mpiint, mpichar -#endif - - character(len=*), intent(in) :: nlfile ! filepath for file containing namelist input (nlfile=atm_in) - - ! Local variables - integer :: unitn, ierr - character(len=*), parameter :: subname = 'cospsimulator_intr_readnl' - character(len=256), dimension(50) :: rttov_instrument_namelists ! Input of paths to RTTOV instrument namelists - - integer :: i ! JKS remove later -#ifdef USE_COSP - - ! Initialize - rttov_instrument_namelists(:) = '' - -!!! this list should include any variable that you might want to include in the namelist -!!! philosophy is to not include COSP output flags but just important COSP settings and cfmip controls. - namelist /cospsimulator_nl/ docosp, cosp_active, cosp_amwg, & - cosp_histfile_num, cosp_histfile_aux, cosp_histfile_aux_num, cosp_isccp, cosp_lfrac_out, & - cosp_lite, cosp_lradar_sim, cosp_llidar_sim, cosp_lisccp_sim, cosp_lmisr_sim, cosp_lmodis_sim, cosp_lrttov_sim, & - cosp_ncolumns, cosp_nradsteps, cosp_passive, cosp_runall, rttov_Ninstruments, rttov_instrument_namelists -! cosp_ncolumns, cosp_nradsteps, cosp_passive, cosp_runall, rttov_Ninstruments - - !! read in the namelist - if (masterproc) then - unitn = getunit() - open( unitn, file=trim(nlfile), status='old' ) !! presumably opens the namelist file "nlfile" - !! position the file to write to the cospsimulator portion of the cam_in namelist - call find_group_name(unitn, 'cospsimulator_nl', status=ierr) - if (ierr == 0) then - read(unitn, cospsimulator_nl, iostat=ierr) - if (ierr /= 0) then - call endrun(subname // ':: ERROR reading namelist') - end if - end if - close(unitn) - call freeunit(unitn) - end if - -#ifdef SPMD - ! Broadcast namelist variables - call mpibcast(docosp, 1, mpilog, 0, mpicom) - call mpibcast(cosp_amwg, 1, mpilog, 0, mpicom) - call mpibcast(cosp_lite, 1, mpilog, 0, mpicom) - call mpibcast(cosp_passive, 1, mpilog, 0, mpicom) - call mpibcast(cosp_active, 1, mpilog, 0, mpicom) - call mpibcast(cosp_isccp, 1, mpilog, 0, mpicom) - call mpibcast(cosp_runall, 1, mpilog, 0, mpicom) - call mpibcast(cosp_lfrac_out, 1, mpilog, 0, mpicom) - call mpibcast(cosp_lradar_sim, 1, mpilog, 0, mpicom) - call mpibcast(cosp_llidar_sim, 1, mpilog, 0, mpicom) - call mpibcast(cosp_lisccp_sim, 1, mpilog, 0, mpicom) - call mpibcast(cosp_lmisr_sim, 1, mpilog, 0, mpicom) - call mpibcast(cosp_lmodis_sim, 1, mpilog, 0, mpicom) - call mpibcast(cosp_lrttov_sim, 1, mpilog, 0, mpicom) - call mpibcast(cosp_ncolumns, 1, mpiint, 0, mpicom) - call mpibcast(cosp_histfile_num, 1, mpiint, 0, mpicom) - call mpibcast(cosp_histfile_aux_num,1, mpiint, 0, mpicom) - call mpibcast(cosp_histfile_aux, 1, mpilog, 0, mpicom) - call mpibcast(cosp_nradsteps, 1, mpiint, 0, mpicom) - call mpibcast(rttov_Ninstruments, 1, mpiint, 0, mpicom) ! JKS - Additional RTTOV variable. This should work. - - do i=1,rttov_Ninstruments ! JKS broadcast array of strings iteratively - print*,'In mpibcast loop. i = ',i - call mpibcast(rttov_instrument_namelists(i), len(rttov_instrument_namelists(i)), mpichar, 0, mpicom) ! JKS - Additional RTTOV variable, len could be 256 - end do -! call mpibcast(rttov_instrument_namelists, len(rttov_instrument_namelists(1))*rttov_Ninstruments, mpichar, 0, mpicom) ! JKS - Additional RTTOV variable, len could be 256 - - ! Example code from Dustin S. - ! call mpi_bcast(gas_namesLW(iChar),len(gas_namesLW(iChar)),MPI_CHARACTER,mpiroot, mpicomm, mpierr) - -#endif - -! It makes sense to broadcast the full string array since we can't allocate the shorter array until after the broadcasting step -! call mpibcast(rttov_Ninstruments, 1, mpiint, 0, mpicom) ! JKS - Additional RTTOV variable. This should work. -! call mpibcast(rttov_instrument_namelists, len(rttov_instrument_namelists(1))*rttov_Ninstruments, mpichar, 0, mpicom) ! JKS - Additional RTTOV variable, len could be 256 -! call mpibcast(rttov_instrument_namelists, len(rttov_instrument_namelists), mpichar, 0, mpicom) ! JKS - Additional RTTOV variable - ! First argument is the object to bcast, second is dimension, third is type. - - if (masterproc) then - if (docosp) then - write(iulog,*)'cosp_lrttov_sim: ', cosp_lrttov_sim - write(iulog,*)'lrttov_sim: ', lrttov_sim - write(iulog,*)'rttov_Ninstruments: ', cosp_ncolumns - write(iulog,*)'rttov_instrument_namelists: ', rttov_instrument_namelists - end if - end if - -! if (masterproc) then -! if (docosp) then -! write(iulog,*)'rttov_instrument_namelists(2): ', rttov_instrument_namelists -! end if -! end if - - if (cosp_lfrac_out) then - lfrac_out = .true. - end if - if (cosp_lradar_sim) then - lradar_sim = .true. - end if - if (cosp_llidar_sim) then - llidar_sim = .true. - lparasol_sim = .true. - end if - if (cosp_lisccp_sim) then - lisccp_sim = .true. - end if - if (cosp_lmisr_sim) then - lmisr_sim = .true. - end if - if (cosp_lmodis_sim) then - lmodis_sim = .true. - end if - if (cosp_lrttov_sim) then - lrttov_sim = .true. - end if - - if (masterproc) then - if (docosp) then - write(iulog,*)'lrttov_sim: ', lrttov_sim - end if - end if - - if (cosp_histfile_aux .and. cosp_histfile_aux_num == -1) then - cosp_histfile_aux_num = cosp_histfile_num - end if - - if (cosp_lite) then - llidar_sim = .true. - lparasol_sim = .true. - lisccp_sim = .true. - lmisr_sim = .true. - lmodis_sim = .true. - cosp_ncolumns = 10 - cosp_nradsteps = 3 - end if - - if (cosp_passive) then - lisccp_sim = .true. - lmisr_sim = .true. - lmodis_sim = .true. - cosp_ncolumns = 10 - cosp_nradsteps = 3 - end if - - if (cosp_active) then - lradar_sim = .true. - llidar_sim = .true. - lparasol_sim = .true. - cosp_ncolumns = 10 - cosp_nradsteps = 3 - end if - - if (cosp_isccp) then - lisccp_sim = .true. - cosp_ncolumns = 10 - cosp_nradsteps = 3 - end if - - if (cosp_runall) then - lradar_sim = .true. - llidar_sim = .true. - lparasol_sim = .true. - lisccp_sim = .true. - lmisr_sim = .true. - lmodis_sim = .true. - lfrac_out = .true. - lrttov_sim = .true. ! - JKS - end if - - !! if no simulators are turned on at all and docosp is, set cosp_amwg = .true. - if((docosp) .and. (.not.lradar_sim) .and. (.not.llidar_sim) .and. (.not.lisccp_sim) .and. & - (.not.lmisr_sim) .and. (.not.lmodis_sim) .and. (.not.lrttov_sim)) then - cosp_amwg = .true. - end if - if (cosp_amwg) then - lradar_sim = .true. - llidar_sim = .true. - lparasol_sim = .true. - lisccp_sim = .true. - lmisr_sim = .true. - lmodis_sim = .true. - cosp_ncolumns = 10 - cosp_nradsteps = 3 - end if - - !! reset COSP namelist variables based on input from cam namelist variables - if (cosp_ncolumns .ne. ncolumns) then - ncolumns = cosp_ncolumns - end if - - ! *NOTE* COSP is configured in CAM such that if a simulator is requested, all diagnostics - ! are output. So no need turn on/aff outputs if simulator is requested. - - ! Set vertical coordinate, subcolumn, and calculation frequency cosp options based on namelist inputs - call setcosp2values(nlr,use_vgrid,csat_vgrid,ncolumns,cosp_nradsteps) - - if (masterproc) then - if (docosp) then - write(iulog,*)'COSP configuration:' - write(iulog,*)' Number of COSP subcolumns = ', cosp_ncolumns - write(iulog,*)' Frequency at which cosp is called = ', cosp_nradsteps - write(iulog,*)' Enable radar simulator = ', lradar_sim - write(iulog,*)' Enable calipso simulator = ', llidar_sim - write(iulog,*)' Enable ISCCP simulator = ', lisccp_sim - write(iulog,*)' Enable MISR simulator = ', lmisr_sim - write(iulog,*)' Enable MODIS simulator = ', lmodis_sim - write(iulog,*)' Enable RTTOV simulator = ', lrttov_sim ! JKS - This isn't working for some reason. - write(iulog,*)' RADAR_SIM microphysics scheme = ', trim(cloudsat_micro_scheme) - write(iulog,*)' Write COSP output to history file = ', cosp_histfile_num - write(iulog,*)' Write COSP input fields = ', cosp_histfile_aux - write(iulog,*)' Write COSP input fields to history file = ', cosp_histfile_aux_num - write(iulog,*)' Write COSP subcolumn fields = ', cosp_lfrac_out - else - write(iulog,*)'COSP not enabled' - end if - end if -#endif - end subroutine cospsimulator_intr_readnl - - ! ###################################################################################### - ! SUBROUTINE cospsimulator_intr_register - ! ###################################################################################### - subroutine cospsimulator_intr_register() - - use cam_history_support, only: add_hist_coord - -#ifdef USE_COSP - integer :: i - character(len=8) :: & - fmt, & ! format descriptor for flexible RTTOV output - i_str - - fmt = '(I3.3)' ! an integer of width 3 with zeros at the left - - ! register non-standard variable dimensions - if (lisccp_sim .or. lmodis_sim) then - call add_hist_coord('cosp_prs', nprs_cosp, 'COSP Mean ISCCP pressure', & - 'hPa', prsmid_cosp, bounds_name='cosp_prs_bnds', bounds=prslim_cosp) - end if - - if (lisccp_sim .or. lmisr_sim) then - call add_hist_coord('cosp_tau', ntau_cosp, & - 'COSP Mean ISCCP optical depth', '1', taumid_cosp, & - bounds_name='cosp_tau_bnds', bounds=taulim_cosp) - end if - - if (lisccp_sim .or. llidar_sim .or. lradar_sim .or. lmisr_sim) then - call add_hist_coord('cosp_scol', nscol_cosp, 'COSP subcolumn', & - values=scol_cosp) - end if - - if (llidar_sim .or. lradar_sim) then - call add_hist_coord('cosp_ht', nht_cosp, & - 'COSP Mean Height for calipso and radar simulator outputs', 'm', & - htmid_cosp, bounds_name='cosp_ht_bnds', bounds=htlim_cosp, & - vertical_coord=.true.) - end if - - if (llidar_sim) then - call add_hist_coord('cosp_sr', nsr_cosp, & - 'COSP Mean Scattering Ratio for calipso simulator CFAD output', '1', & - srmid_cosp, bounds_name='cosp_sr_bnds', bounds=srlim_cosp) - end if - - if (llidar_sim) then - call add_hist_coord('cosp_sza', nsza_cosp, 'COSP Parasol SZA', & - 'degrees', sza_cosp) - end if - - if (lradar_sim) then - call add_hist_coord('cosp_dbze', CLOUDSAT_DBZE_BINS, & - 'COSP Mean dBZe for radar simulator CFAD output', 'dBZ', & - dbzemid_cosp, bounds_name='cosp_dbze_bnds', bounds=dbzelim_cosp) - end if - - if (lmisr_sim) then - call add_hist_coord('cosp_htmisr', nhtmisr_cosp, 'COSP MISR height', & - 'km', htmisrmid_cosp, & - bounds_name='cosp_htmisr_bnds', bounds=htmisrlim_cosp) - end if - - if (lmodis_sim) then - call add_hist_coord('cosp_tau_modis', ntau_cosp_modis, & - 'COSP Mean MODIS optical depth', '1', taumid_cosp_modis, & - bounds_name='cosp_tau_modis_bnds', bounds=taulim_cosp_modis) - call add_hist_coord('cosp_reffice',numMODISReffIceBins, & - 'COSP Mean MODIS effective radius (ice)', 'microns', reffICE_binCenters_cosp, & - bounds_name='cosp_reffice_bnds',bounds=reffICE_binEdges_cosp) - call add_hist_coord('cosp_reffliq',numMODISReffLiqBins, & - 'COSP Mean MODIS effective radius (liquid)', 'microns', reffLIQ_binCenters_cosp, & - bounds_name='cosp_reffliq_bnds',bounds=reffLIQ_binEdges_cosp) - end if - - ! JKS - For RTTOV, I will need to add history coordinates related to the channel outputs, which is determined during the init step - ! So I might need a separate subroutine that is called later but triggered by a logical set here? - ! Also, where is this subroutine called from? - - if (masterproc) then - if (docosp) then - write(iulog,*)'Reached RTTOV section in cospsimulator_intr_register' - write(iulog,*)'lrttov_sim: ', lrttov_sim - end if - end if - - ! Assume the rttov_configs object is accessible and set up here - if ((lrttov_sim) .and. (rttov_Ninstruments .gt. 0)) then - do i=1,rttov_Ninstruments - write (i_str,fmt) i ! converting integer to string i_str using a 'internal file' - - call add_hist_coord("RTTOV_CHAN_I"//trim(i_str), & ! This string needs to be 16 characters or less - rttov_configs(i) % nchan_out, & - 'RTTOV Channel Indices for Instrument '//trim(i_str), & - 'Channel Index', & - rttov_configs(i) % iChannel_out) - end do - end if - - if (masterproc) then - if (docosp) then - write(iulog,*)'Finished RTTOV section in cospsimulator_intr_register' - write(iulog,*)'lrttov_sim: ', lrttov_sim - end if - end if - -#endif - end subroutine cospsimulator_intr_register - - ! ###################################################################################### - ! SUBROUTINE cospsimulator_intr_init - ! ###################################################################################### - subroutine cospsimulator_intr_init() - -#ifdef USE_COSP - - use cam_history, only: addfld, add_default, horiz_only -#ifdef SPMD - use mpishorthand, only : mpir8, mpiint, mpicom -#endif - use netcdf, only : nf90_open, nf90_inq_varid, nf90_get_var, nf90_close, nf90_nowrite - use error_messages, only : handle_ncerr, alloc_err - - use physics_buffer, only: pbuf_get_index - - use mod_cosp_config, only : R_UNDEF - - integer :: ncid,latid,lonid,did,hrid,minid,secid, istat - integer :: i - character(len=8) :: & - fmt, & ! format descriptor for flexible RTTOV output - i_str - - fmt = '(I3.3)' ! an integer of width 3 with zeros at the left - - ! ISCCP OUTPUTS - if (lisccp_sim) then - !! addfld calls for all - !*cfMon,cfDa* clisccp2 (time,tau,plev,profile), CFMIP wants 7 p bins, 7 tau bins - call addfld('FISCCP1_COSP',(/'cosp_tau','cosp_prs'/),'A','percent', & - 'Grid-box fraction covered by each ISCCP D level cloud type',& - flag_xyfill=.true., fill_value=R_UNDEF) - - !*cfMon,cfDa* tclisccp (time,profile), CFMIP wants "gridbox mean cloud cover from ISCCP" - call addfld('CLDTOT_ISCCP', horiz_only,'A','percent', & - 'Total Cloud Fraction Calculated by the ISCCP Simulator ',flag_xyfill=.true., fill_value=R_UNDEF) - !*cfMon,cfDa* albisccp (time,profile) - ! Per CFMIP request - weight by ISCCP Total Cloud Fraction (divide by CLDTOT_ISSCP in history file to get weighted average) - call addfld('MEANCLDALB_ISCCP',horiz_only,'A','1','Mean cloud albedo*CLDTOT_ISCCP',flag_xyfill=.true., fill_value=R_UNDEF) - !*cfMon,cfDa* ctpisccp (time,profile) - ! Per CFMIP request - weight by ISCCP Total Cloud Fraction (divide by CLDTOT_ISSCP in history file to get weighted average) - call addfld('MEANPTOP_ISCCP',horiz_only,'A','Pa','Mean cloud top pressure*CLDTOT_ISCCP',flag_xyfill=.true., & - fill_value=R_UNDEF) - ! tauisccp (time,profile) - ! For averaging, weight by ISCCP Total Cloud Fraction (divide by CLDTOT_ISSCP in history file to get weighted average) - call addfld ('MEANTAU_ISCCP',horiz_only,'A','1','Mean optical thickness*CLDTOT_ISCCP',flag_xyfill=.true., & - fill_value=R_UNDEF) - ! meantbisccp (time,profile), at 10.5 um - call addfld ('MEANTB_ISCCP',horiz_only,'A','K','Mean Infrared Tb from ISCCP simulator',flag_xyfill=.true., & - fill_value=R_UNDEF) - ! meantbclrisccp (time,profile) - call addfld ('MEANTBCLR_ISCCP',horiz_only,'A','K','Mean Clear-sky Infrared Tb from ISCCP simulator', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! boxtauisccp (time,column,profile) - call addfld ('TAU_ISCCP',(/'cosp_scol'/),'I','1','Optical Depth in each Subcolumn',flag_xyfill=.true., fill_value=R_UNDEF) - ! boxptopisccp (time,column,profile) - call addfld ('CLDPTOP_ISCCP',(/'cosp_scol'/),'I','Pa','Cloud Top Pressure in each Subcolumn', & - flag_xyfill=.true., fill_value=R_UNDEF) - - !! add all isccp outputs to the history file specified by the CAM namelist variable cosp_histfile_num - call add_default ('FISCCP1_COSP',cosp_histfile_num,' ') - call add_default ('CLDTOT_ISCCP',cosp_histfile_num,' ') - call add_default ('MEANCLDALB_ISCCP',cosp_histfile_num,' ') - call add_default ('MEANPTOP_ISCCP',cosp_histfile_num,' ') - call add_default ('MEANTAU_ISCCP',cosp_histfile_num,' ') - call add_default ('MEANTB_ISCCP',cosp_histfile_num,' ') - call add_default ('MEANTBCLR_ISCCP',cosp_histfile_num,' ') - - end if - - ! CALIPSO SIMULATOR OUTPUTS - if (llidar_sim) then - !! addfld calls for all - !*cfMon,cfOff,cfDa,cf3hr* cllcalipso (time,profile) - call addfld('CLDLOW_CAL',horiz_only,'A','percent','Calipso Low-level Cloud Fraction',flag_xyfill=.true., fill_value=R_UNDEF) - !*cfMon,cfOff,cfDa,cf3hr* clmcalipso (time,profile) - call addfld('CLDMED_CAL',horiz_only,'A','percent','Calipso Mid-level Cloud Fraction',flag_xyfill=.true., fill_value=R_UNDEF) - !*cfMon,cfOff,cfDa,cf3hr* clhcalipso (time,profile) - call addfld('CLDHGH_CAL',horiz_only,'A','percent','Calipso High-level Cloud Fraction',flag_xyfill=.true., fill_value=R_UNDEF) - !*cfMon,cfOff,cfDa,cf3hr* cltcalipso (time,profile) - call addfld('CLDTOT_CAL',horiz_only,'A','percent','Calipso Total Cloud Fraction',flag_xyfill=.true., fill_value=R_UNDEF) - !*cfMon,cfOff,cfDa,cf3hr* clcalipso (time,height,profile) - call addfld('CLD_CAL',(/'cosp_ht'/),'A','percent','Calipso Cloud Fraction (532 nm)', flag_xyfill=.true., fill_value=R_UNDEF) - !*cfMon,cfOff,cfDa,cf3hr* parasol_refl (time,sza,profile) - call addfld ('RFL_PARASOL',(/'cosp_sza'/),'A','fraction','PARASOL-like mono-directional reflectance ', & - flag_xyfill=.true., fill_value=R_UNDEF) - !*cfOff,cf3hr* cfad_calipsosr532 (time,height,scat_ratio,profile), %11%, default is 40 vert levs, 15 SR bins - call addfld('CFAD_SR532_CAL',(/'cosp_sr','cosp_ht'/),'A','fraction', & - 'Calipso Scattering Ratio CFAD (532 nm)', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! beta_mol532 (time,height_mlev,profile) - call addfld ('MOL532_CAL',(/'lev'/),'A','m-1sr-1','Calipso Molecular Backscatter (532 nm) ', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! atb532 (time,height_mlev,column,profile) - call addfld ('ATB532_CAL',(/'cosp_scol','lev '/),'I','no_unit_log10(x)', & - 'Calipso Attenuated Total Backscatter (532 nm) in each Subcolumn', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! lclcalipsoliq (time,alt40,loc) !!+cosp1.4 - call addfld('CLD_CAL_LIQ', (/'cosp_ht'/), 'A','percent', 'Calipso Liquid Cloud Fraction', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! lclcalipsoice (time,alt40,loc) - call addfld('CLD_CAL_ICE', (/'cosp_ht'/), 'A','percent', 'Calipso Ice Cloud Fraction', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! lclcalipsoun (time,alt40,loc) - call addfld('CLD_CAL_UN', (/'cosp_ht'/),'A','percent', 'Calipso Undefined-Phase Cloud Fraction', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! lclcalipsotmp (time,alt40,loc) - call addfld('CLD_CAL_TMP', (/'cosp_ht'/), 'A','percent', 'NOT SURE WHAT THIS IS Cloud Fraction', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! lclcalipsotmpliq (time,alt40,loc) - call addfld('CLD_CAL_TMPLIQ', (/'cosp_ht'/), 'A','percent', 'NOT SURE WHAT THIS IS Cloud Fraction', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! lclcalipsotmpice (time,alt40,loc) - call addfld('CLD_CAL_TMPICE', (/'cosp_ht'/), 'A','percent', 'NOT SURE WHAT THIS IS Cloud Fraction', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! lclcalipsotmpun (time,alt40,loc) - call addfld('CLD_CAL_TMPUN', (/'cosp_ht'/), 'A','percent', 'NOT SURE WHAT THIS IS Cloud Fraction', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! lcltcalipsoice (time,loc) - call addfld('CLDTOT_CAL_ICE', horiz_only,'A','percent','Calipso Total Ice Cloud Fraction', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! lcltcalipsoliq (time,loc) - call addfld('CLDTOT_CAL_LIQ', horiz_only,'A','percent','Calipso Total Liquid Cloud Fraction', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! lcltcalipsoun (time,loc) - call addfld('CLDTOT_CAL_UN',horiz_only,'A','percent','Calipso Total Undefined-Phase Cloud Fraction', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! lclhcalipsoice (time,loc) - call addfld('CLDHGH_CAL_ICE',horiz_only,'A','percent','Calipso High-level Ice Cloud Fraction', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! lclhcalipsoliq (time,loc) - call addfld('CLDHGH_CAL_LIQ',horiz_only,'A','percent','Calipso High-level Liquid Cloud Fraction', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! lclhcalipsoun (time,loc) - call addfld('CLDHGH_CAL_UN',horiz_only,'A','percent','Calipso High-level Undefined-Phase Cloud Fraction', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! lclmcalipsoice (time,loc) - call addfld('CLDMED_CAL_ICE',horiz_only,'A','percent','Calipso Mid-level Ice Cloud Fraction', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! lclmcalipsoliq (time,loc) - call addfld('CLDMED_CAL_LIQ',horiz_only,'A','percent','Calipso Mid-level Liquid Cloud Fraction', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! lclmcalipsoun (time,loc) - call addfld('CLDMED_CAL_UN',horiz_only,'A','percent','Calipso Mid-level Undefined-Phase Cloud Fraction', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! lcllcalipsoice (time,loc) - call addfld('CLDLOW_CAL_ICE',horiz_only,'A','percent','Calipso Low-level Ice Cloud Fraction', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! lcllcalipsoliq (time,loc) - call addfld('CLDLOW_CAL_LIQ',horiz_only,'A','percent','Calipso Low-level Liquid Cloud Fraction', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! lcllcalipsoun (time,loc) !+cosp1.4 - call addfld('CLDLOW_CAL_UN',horiz_only,'A','percent','Calipso Low-level Undefined-Phase Cloud Fraction', & - flag_xyfill=.true., fill_value=R_UNDEF) - -! ! Calipso Opaque/thin cloud diagnostics -! call addfld('CLDOPQ_CAL', horiz_only, 'A', 'percent', 'CALIPSO Opaque Cloud Cover', & -! flag_xyfill=.true., fill_value=R_UNDEF) -! call addfld('CLDTHN_CAL', horiz_only, 'A', 'percent', 'CALIPSO Thin Cloud Cover', & -! flag_xyfill=.true., fill_value=R_UNDEF) -! call addfld('CLDZOPQ_CAL', horiz_only, 'A', 'm', 'CALIPSO z_opaque Altitude', & -! flag_xyfill=.true., fill_value=R_UNDEF) -! call addfld('CLDOPQ_CAL_2D', (/'cosp_ht'/), 'A', 'percent', 'CALIPSO Opaque Cloud Fraction', & -! flag_xyfill=.true., fill_value=R_UNDEF) -! call addfld('CLDTHN_CAL_2D', (/'cosp_ht'/), 'A', 'percent', 'CALIPSO Thin Cloud Fraction', & -! flag_xyfill=.true., fill_value=R_UNDEF) -! call addfld('CLDZOPQ_CAL_2D', (/'cosp_ht'/), 'A', 'percent', 'CALIPSO z_opaque Fraction', & -! flag_xyfill=.true., fill_value=R_UNDEF) -! call addfld('OPACITY_CAL_2D', (/'cosp_ht'/), 'A', 'percent', 'CALIPSO opacity Fraction', & -! flag_xyfill=.true., fill_value=R_UNDEF) -! call addfld('CLDOPQ_CAL_TMP', horiz_only, 'A', 'K', 'CALIPSO Opaque Cloud Temperature', & -! flag_xyfill=.true., fill_value=R_UNDEF) -! call addfld('CLDTHN_CAL_TMP', horiz_only, 'A', 'K', 'CALIPSO Thin Cloud Temperature', & -! flag_xyfill=.true., fill_value=R_UNDEF) -! call addfld('CLDZOPQ_CAL_TMP', horiz_only, 'A', 'K', 'CALIPSO z_opaque Temperature', & -! flag_xyfill=.true., fill_value=R_UNDEF) -! call addfld('CLDOPQ_CAL_Z', horiz_only, 'A', 'm', 'CALIPSO Opaque Cloud Altitude', & -! flag_xyfill=.true., fill_value=R_UNDEF) -! call addfld('CLDTHN_CAL_Z', horiz_only, 'A', 'm', 'CALIPSO Thin Cloud Altitude', & -! flag_xyfill=.true., fill_value=R_UNDEF) -! call addfld('CLDTHN_CAL_EMIS', horiz_only, 'A', '1', 'CALIPSO Thin Cloud Emissivity', & -! flag_xyfill=.true., fill_value=R_UNDEF) -! call addfld('CLDOPQ_CAL_SE', horiz_only, 'A', 'm', 'CALIPSO Opaque Cloud Altitude with respect to surface-elevation', & -! flag_xyfill=.true., fill_value=R_UNDEF) -! call addfld('CLDTHN_CAL_SE', horiz_only, 'A', 'm', 'CALIPSO Thin Cloud Altitude with respect to surface-elevation', & -! flag_xyfill=.true., fill_value=R_UNDEF) -! call addfld('CLDZOPQ_CAL_SE', horiz_only, 'A', 'm', 'CALIPSO z_opaque Altitude with respect to surface-elevation', & -! flag_xyfill=.true., fill_value=R_UNDEF) - - ! add_default calls for CFMIP experiments or else all fields are added to history file - ! except those with sub-column dimension/experimental variables - !! add all calipso outputs to the history file specified by the CAM namelist variable cosp_histfile_num - call add_default ('CLDLOW_CAL',cosp_histfile_num,' ') - call add_default ('CLDMED_CAL',cosp_histfile_num,' ') - call add_default ('CLDHGH_CAL',cosp_histfile_num,' ') - call add_default ('CLDTOT_CAL',cosp_histfile_num,' ') - call add_default ('CLD_CAL',cosp_histfile_num,' ') - call add_default ('RFL_PARASOL',cosp_histfile_num,' ') - call add_default ('CFAD_SR532_CAL',cosp_histfile_num,' ') - call add_default ('CLD_CAL_LIQ',cosp_histfile_num,' ') !+COSP1.4 - call add_default ('CLD_CAL_ICE',cosp_histfile_num,' ') - call add_default ('CLD_CAL_UN',cosp_histfile_num,' ') - call add_default ('CLDTOT_CAL_ICE',cosp_histfile_num,' ') - call add_default ('CLDTOT_CAL_LIQ',cosp_histfile_num,' ') - call add_default ('CLDTOT_CAL_UN',cosp_histfile_num,' ') - call add_default ('CLDHGH_CAL_ICE',cosp_histfile_num,' ') - call add_default ('CLDHGH_CAL_LIQ',cosp_histfile_num,' ') - call add_default ('CLDHGH_CAL_UN',cosp_histfile_num,' ') - call add_default ('CLDMED_CAL_ICE',cosp_histfile_num,' ') - call add_default ('CLDMED_CAL_LIQ',cosp_histfile_num,' ') - call add_default ('CLDMED_CAL_UN',cosp_histfile_num,' ') - call add_default ('CLDLOW_CAL_ICE',cosp_histfile_num,' ') - call add_default ('CLDLOW_CAL_LIQ',cosp_histfile_num,' ') - call add_default ('CLDLOW_CAL_UN',cosp_histfile_num,' ') -! call add_default ('CLDOPQ_CAL',cosp_histfile_num,' ') -! call add_default ('CLDTHN_CAL',cosp_histfile_num,' ') -! call add_default ('CLDZOPQ_CAL',cosp_histfile_num,' ') -! call add_default ('CLDOPQ_CAL_2D',cosp_histfile_num,' ') -! call add_default ('CLDTHN_CAL_2D',cosp_histfile_num,' ') -! call add_default ('CLDZOPQ_CAL_2D',cosp_histfile_num,' ') -! call add_default ('OPACITY_CAL_2D',cosp_histfile_num,' ') -! call add_default ('CLDOPQ_CAL_TMP',cosp_histfile_num,' ') -! call add_default ('CLDTHN_CAL_TMP',cosp_histfile_num,' ') -! call add_default ('CLDZOPQ_CAL_TMP',cosp_histfile_num,' ') -! call add_default ('CLDOPQ_CAL_Z',cosp_histfile_num,' ') -! call add_default ('CLDTHN_CAL_Z',cosp_histfile_num,' ') -! call add_default ('CLDTHN_CAL_EMIS',cosp_histfile_num,' ') -! call add_default ('CLDOPQ_CAL_SE',cosp_histfile_num,' ') -! call add_default ('CLDTHN_CAL_SE',cosp_histfile_num,' ') -! call add_default ('CLDZOPQ_CAL_SE',cosp_histfile_num,' ') - - if ((.not.cosp_amwg) .and. (.not.cosp_lite) .and. (.not.cosp_passive) .and. (.not.cosp_active) & - .and. (.not.cosp_isccp)) then - call add_default ('MOL532_CAL',cosp_histfile_num,' ') - end if - end if - - ! RADAR SIMULATOR OUTPUTS - if (lradar_sim) then - - allocate(sd_cs(begchunk:endchunk), rcfg_cs(begchunk:endchunk)) - do i = begchunk, endchunk - sd_cs(i) = sd - rcfg_cs(i) = rcfg_cloudsat - end do - - ! addfld calls - !*cfOff,cf3hr* cfad_dbze94 (time,height,dbze,profile), default is 40 vert levs, 15 dBZ bins - call addfld('CFAD_DBZE94_CS',(/'cosp_dbze','cosp_ht '/),'A','fraction',& - 'Radar Reflectivity Factor CFAD (94 GHz)',& - flag_xyfill=.true., fill_value=R_UNDEF) - !*cfOff,cf3hr* clcalipso2 (time,height,profile) - call addfld ('CLD_CAL_NOTCS',(/'cosp_ht'/),'A','percent','Cloud occurrence seen by CALIPSO but not CloudSat ', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! cltcalipsoradar (time,profile) - call addfld ('CLDTOT_CALCS',horiz_only,'A','percent',' Calipso and Radar Total Cloud Fraction ',flag_xyfill=.true., & - fill_value=R_UNDEF) - call addfld ('CLDTOT_CS',horiz_only,'A','percent',' Radar total cloud amount ',flag_xyfill=.true., fill_value=R_UNDEF) - call addfld ('CLDTOT_CS2',horiz_only,'A','percent', & - ' Radar total cloud amount without the data for the first kilometer above surface ', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! dbze94 (time,height_mlev,column,profile),! height_mlevel = height when vgrid_in = .true. (default) - call addfld ('DBZE_CS',(/'cosp_scol','lev '/),'I','dBZe',' Radar dBZe (94 GHz) in each Subcolumn',& - flag_xyfill=.true., fill_value=R_UNDEF) - - ! Cloudsat near-sfc precipitation diagnostics - call addfld('CS_NOPRECIP', horiz_only, 'A', '1', 'CloudSat No Rain Fraction', flag_xyfill=.true., fill_value=R_UNDEF) - call addfld('CS_RAINPOSS', horiz_only, 'A', '1', 'Cloudsat Rain Possible Fraction', flag_xyfill=.true., fill_value=R_UNDEF) - call addfld('CS_RAINPROB', horiz_only, 'A', '1', 'CloudSat Rain Probable Fraction', flag_xyfill=.true., fill_value=R_UNDEF) - call addfld('CS_RAINCERT', horiz_only, 'A', '1', 'CloudSat Rain Certain Fraction', flag_xyfill=.true., fill_value=R_UNDEF) - call addfld('CS_SNOWPOSS', horiz_only, 'A', '1', 'CloudSat Snow Possible Fraction', flag_xyfill=.true., fill_value=R_UNDEF) - call addfld('CS_SNOWCERT', horiz_only, 'A', '1', 'CloudSat Snow Certain Fraction', flag_xyfill=.true., fill_value=R_UNDEF) - call addfld('CS_MIXPOSS', horiz_only, 'A', '1', 'CloudSat Mixed Possible Fraction', flag_xyfill=.true., fill_value=R_UNDEF) - call addfld('CS_MIXCERT', horiz_only, 'A', '1', 'CloudSat Mixed Certain Fraction', flag_xyfill=.true., fill_value=R_UNDEF) - call addfld('CS_RAINHARD', horiz_only, 'A', '1', 'CloudSat Heavy Rain Fraction', flag_xyfill=.true., fill_value=R_UNDEF) - call addfld('CS_UN', horiz_only, 'A', '1', 'CloudSat Unclassified Precipitation Fraction',flag_xyfill=.true., fill_value=R_UNDEF) - call addfld('CS_PIA', horiz_only, 'A', 'dBZ', 'CloudSat Radar Path Integrated Attenuation', flag_xyfill=.true., fill_value=R_UNDEF) - ! Associated CAM microphysics - !call addfld('CAM_MP_CVRAIN',horiz_only, 'A', 'kg/kg','CAM Microphysics Convective Rain', flag_xyfill=.true., fill_value=R_UNDEF) - !call addfld('CAM_MP_CVSNOW',horiz_only, 'A', 'kg/kg','CAM Microphysics Convective Snow', flag_xyfill=.true., fill_value=R_UNDEF) - !call addfld('CAM_MP_LSRAIN',horiz_only, 'A', 'kg/kg','CAM Microphysics Large-Scale Rain', flag_xyfill=.true., fill_value=R_UNDEF) - !call addfld('CAM_MP_LSSNOW',horiz_only, 'A', 'kg/kg','CAM Microphysics Large-Scale Snow', flag_xyfill=.true., fill_value=R_UNDEF) - !call addfld('CAM_MP_LSGRPL',horiz_only, 'A', 'kg/kg','CAM Microphysics Large-Scale Graupel', flag_xyfill=.true., fill_value=R_UNDEF) - - - ! add_default calls for CFMIP experiments or else all fields are added to history file except those with sub-column dimension - !! add all radar outputs to the history file specified by the CAM namelist variable cosp_histfile_num - call add_default ('CFAD_DBZE94_CS',cosp_histfile_num,' ') - call add_default ('CLD_CAL_NOTCS', cosp_histfile_num,' ') - call add_default ('CLDTOT_CALCS', cosp_histfile_num,' ') - call add_default ('CLDTOT_CS', cosp_histfile_num,' ') - call add_default ('CLDTOT_CS2', cosp_histfile_num,' ') - call add_default ('CS_NOPRECIP', cosp_histfile_num,' ') - call add_default ('CS_RAINPOSS', cosp_histfile_num,' ') - call add_default ('CS_RAINPROB', cosp_histfile_num,' ') - call add_default ('CS_RAINCERT', cosp_histfile_num,' ') - call add_default ('CS_SNOWPOSS', cosp_histfile_num,' ') - call add_default ('CS_SNOWCERT', cosp_histfile_num,' ') - call add_default ('CS_MIXPOSS', cosp_histfile_num,' ') - call add_default ('CS_MIXCERT', cosp_histfile_num,' ') - call add_default ('CS_RAINHARD', cosp_histfile_num,' ') - call add_default ('CS_UN', cosp_histfile_num,' ') - call add_default ('CS_PIA', cosp_histfile_num,' ') - end if - - ! MISR SIMULATOR OUTPUTS - if (lmisr_sim) then - ! clMISR (time,tau,CTH_height_bin,profile) - call addfld ('CLD_MISR',(/'cosp_tau ','cosp_htmisr'/),'A','percent','Cloud Fraction from MISR Simulator', & - flag_xyfill=.true., fill_value=R_UNDEF) - !! add all misr outputs to the history file specified by the CAM namelist variable cosp_histfile_num - call add_default ('CLD_MISR',cosp_histfile_num,' ') - end if - - ! MODIS OUTPUT - if (lmodis_sim) then - ! float cltmodis ( time, loc ) - call addfld ('CLTMODIS',horiz_only,'A','%','MODIS Total Cloud Fraction',flag_xyfill=.true., fill_value=R_UNDEF) - ! float clwmodis ( time, loc ) - call addfld ('CLWMODIS',horiz_only,'A','%','MODIS Liquid Cloud Fraction',flag_xyfill=.true., fill_value=R_UNDEF) - ! float climodis ( time, loc ) - call addfld ('CLIMODIS',horiz_only,'A','%','MODIS Ice Cloud Fraction',flag_xyfill=.true., fill_value=R_UNDEF) - ! float clhmodis ( time, loc ) - call addfld ('CLHMODIS',horiz_only,'A','%','MODIS High Level Cloud Fraction',flag_xyfill=.true., fill_value=R_UNDEF) - ! float clmmodis ( time, loc ) - call addfld ('CLMMODIS',horiz_only,'A','%','MODIS Mid Level Cloud Fraction',flag_xyfill=.true., fill_value=R_UNDEF) - ! float cllmodis ( time, loc ) - call addfld ('CLLMODIS',horiz_only,'A','%','MODIS Low Level Cloud Fraction',flag_xyfill=.true., fill_value=R_UNDEF) - ! float tautmodis ( time, loc ) - call addfld ('TAUTMODIS',horiz_only,'A','1','MODIS Total Cloud Optical Thickness*CLTMODIS', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! float tauwmodis ( time, loc ) - call addfld ('TAUWMODIS',horiz_only,'A','1','MODIS Liquid Cloud Optical Thickness*CLWMODIS', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! float tauimodis ( time, loc ) - call addfld ('TAUIMODIS',horiz_only,'A','1','MODIS Ice Cloud Optical Thickness*CLIMODIS', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! float tautlogmodis ( time, loc ) - call addfld ('TAUTLOGMODIS',horiz_only,'A','1','MODIS Total Cloud Optical Thickness (Log10 Mean)*CLTMODIS', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! float tauwlogmodis ( time, loc ) - call addfld ('TAUWLOGMODIS',horiz_only,'A','1','MODIS Liquid Cloud Optical Thickness (Log10 Mean)*CLWMODIS', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! float tauilogmodis ( time, loc ) - call addfld ('TAUILOGMODIS',horiz_only,'A','1','MODIS Ice Cloud Optical Thickness (Log10 Mean)*CLIMODIS', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! float reffclwmodis ( time, loc ) - call addfld ('REFFCLWMODIS',horiz_only,'A','m','MODIS Liquid Cloud Particle Size*CLWMODIS', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! float reffclimodis ( time, loc ) - call addfld ('REFFCLIMODIS',horiz_only,'A','m','MODIS Ice Cloud Particle Size*CLIMODIS', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! float pctmodis ( time, loc ) - call addfld ('PCTMODIS',horiz_only,'A','Pa','MODIS Cloud Top Pressure*CLTMODIS',flag_xyfill=.true., fill_value=R_UNDEF) - ! float lwpmodis ( time, loc ) - call addfld ('LWPMODIS',horiz_only,'A','kg m-2','MODIS Cloud Liquid Water Path*CLWMODIS', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! float iwpmodis ( time, loc ) - call addfld ('IWPMODIS',horiz_only,'A','kg m-2','MODIS Cloud Ice Water Path*CLIMODIS',flag_xyfill=.true., fill_value=R_UNDEF) - ! float clmodis ( time, plev, tau, loc ) - call addfld ('CLMODIS',(/'cosp_tau_modis','cosp_prs '/),'A','%','MODIS Cloud Area Fraction', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! float clrimodis ( time, plev, tau, loc ) - call addfld ('CLRIMODIS',(/'cosp_tau_modis','cosp_reffice '/),'A','%','MODIS Cloud Area Fraction', & - flag_xyfill=.true., fill_value=R_UNDEF) - ! float clrlmodis ( time, plev, tau, loc ) - call addfld ('CLRLMODIS',(/'cosp_tau_modis','cosp_reffliq '/),'A','%','MODIS Cloud Area Fraction', & - flag_xyfill=.true., fill_value=R_UNDEF) - - !! add MODIS output to history file specified by the CAM namelist variable cosp_histfile_num - call add_default ('CLTMODIS',cosp_histfile_num,' ') - call add_default ('CLWMODIS',cosp_histfile_num,' ') - call add_default ('CLIMODIS',cosp_histfile_num,' ') - call add_default ('CLHMODIS',cosp_histfile_num,' ') - call add_default ('CLMMODIS',cosp_histfile_num,' ') - call add_default ('CLLMODIS',cosp_histfile_num,' ') - call add_default ('TAUTMODIS',cosp_histfile_num,' ') - call add_default ('TAUWMODIS',cosp_histfile_num,' ') - call add_default ('TAUIMODIS',cosp_histfile_num,' ') - call add_default ('TAUTLOGMODIS',cosp_histfile_num,' ') - call add_default ('TAUWLOGMODIS',cosp_histfile_num,' ') - call add_default ('TAUILOGMODIS',cosp_histfile_num,' ') - call add_default ('REFFCLWMODIS',cosp_histfile_num,' ') - call add_default ('REFFCLIMODIS',cosp_histfile_num,' ') - call add_default ('PCTMODIS',cosp_histfile_num,' ') - call add_default ('LWPMODIS',cosp_histfile_num,' ') - call add_default ('IWPMODIS',cosp_histfile_num,' ') - call add_default ('CLMODIS',cosp_histfile_num,' ') - call add_default ('CLRIMODIS',cosp_histfile_num,' ') - call add_default ('CLRLMODIS',cosp_histfile_num,' ') - end if - - ! SUB-COLUMN OUTPUT - if (lfrac_out) then - ! frac_out (time,height_mlev,column,profile) - call addfld ('SCOPS_OUT',(/'cosp_scol','lev '/),'I','0=nocld,1=strcld,2=cnvcld','SCOPS Subcolumn output', & - flag_xyfill=.true., fill_value=R_UNDEF) - !! add scops ouptut to history file specified by the CAM namelist variable cosp_histfile_num - call add_default ('SCOPS_OUT',cosp_histfile_num,' ') - ! save sub-column outputs from ISCCP if ISCCP is run - if (lisccp_sim) then - call add_default ('TAU_ISCCP',cosp_histfile_num,' ') - call add_default ('CLDPTOP_ISCCP',cosp_histfile_num,' ') - end if - ! save sub-column outputs from calipso if calipso is run - if (llidar_sim) then - call add_default ('ATB532_CAL',cosp_histfile_num,' ') - end if - ! save sub-column outputs from radar if radar is run - if (lradar_sim) then - call add_default ('DBZE_CS',cosp_histfile_num,' ') - end if - end if - - if (masterproc) then - if (docosp) then - write(iulog,*)'Reached RTTOV section in cospsimulator_intr_init' - write(iulog,*)'lrttov_sim: ', lrttov_sim - end if - end if - - ! RTTOV - if (lrttov_sim) then - do i=1,rttov_Ninstruments - write (i_str,fmt) i ! converting integer to string i_str using a 'internal file' - if (not(rttov_configs(i) % Lrttov_pc)) then - if (rttov_configs(i) % Lrttov_bt) then - ! Just add one variable for now. - call addfld ("rttov_bt_total_inst"//trim(i_str), & - (/"RTTOV_CHAN_I"//trim(i_str)/), & - 'A', & ! A - 'average', I - 'instantaneous' - 'Degrees Kelvin', & ! Units - 'RTTOV All-sky Brightness Temperature', & - flag_xyfill=.true., & - fill_value=R_UNDEF) - call add_default ("rttov_bt_total_inst"//trim(i_str),cosp_histfile_num,' ') - end if - - if (rttov_configs(i) % Lrttov_bt .and. ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer))) then - call addfld ("rttov_bt_clear_inst"//trim(i_str), & - (/"RTTOV_CHAN_I"//trim(i_str)/), & - 'A', & - 'Degrees Kelvin', & - 'RTTOV Clear-sky Brightness Temperature', & - flag_xyfill=.true., & - fill_value=R_UNDEF) - call add_default ("rttov_bt_clear_inst"//trim(i_str),cosp_histfile_num,' ') - end if - - if (rttov_configs(i) % Lrttov_rad) then - call addfld ("rttov_rad_total_inst"//trim(i_str), & - (/"RTTOV_CHAN_I"//trim(i_str)/), & - 'A', & - 'mW/cm-1/sr/m2', & - 'RTTOV All-sky Radiance', & - flag_xyfill=.true., & - fill_value=R_UNDEF) - call add_default ("rttov_rad_total_inst"//trim(i_str),cosp_histfile_num,' ') - end if - - if (rttov_configs(i) % Lrttov_rad .and. ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer))) then - call addfld ("rttov_rad_clear_inst"//trim(i_str), & - (/"RTTOV_CHAN_I"//trim(i_str)/), & - 'A', & - 'mW/cm-1/sr/m2', & - 'RTTOV Clear-sky Radiance', & - flag_xyfill=.true., & - fill_value=R_UNDEF) - call add_default ("rttov_rad_clear_inst"//trim(i_str),cosp_histfile_num,' ') - call addfld ("rttov_rad_cloudy_inst"//trim(i_str), & - (/"RTTOV_CHAN_I"//trim(i_str)/), & - 'A', & - 'mW/cm-1/sr/m2', & - 'RTTOV Cloudy-sky Radiance', & - flag_xyfill=.true., & - fill_value=R_UNDEF) - call add_default ("rttov_rad_cloudy_inst"//trim(i_str),cosp_histfile_num,' ') - end if - - if (rttov_configs(i) % Lrttov_refl) then - call addfld ("rttov_refl_total_inst"//trim(i_str), & - (/"RTTOV_CHAN_I"//trim(i_str)/), & - 'A', & - '1', & - 'RTTOV All-sky Reflectance', & - flag_xyfill=.true., & - fill_value=R_UNDEF) - call add_default ("rttov_refl_total_inst"//trim(i_str),cosp_histfile_num,' ') - end if - - if (rttov_configs(i) % Lrttov_refl .and. ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer))) then - call addfld ("rttov_refl_clear_inst"//trim(i_str), & - (/"RTTOV_CHAN_I"//trim(i_str)/), & - 'A', & - '1', & - 'RTTOV Clear-sky Reflectance', & - flag_xyfill=.true., & - fill_value=R_UNDEF) - call add_default ("rttov_refl_clear_inst"//trim(i_str),cosp_histfile_num,' ') - end if - else - if (rttov_configs(i) % Lrttov_bt) then - call addfld ("rttov_btpc_clr_inst"//trim(i_str), & - (/"RTTOV_CHAN_I"//trim(i_str)/), & - 'A', & - 'Degrees Kelvin', & - 'PC-RTTOV Clear-sky Brightness Temperature', & - flag_xyfill=.true., & - fill_value=R_UNDEF) - call add_default ("rttov_btpc_clr_inst"//trim(i_str),cosp_histfile_num,' ') - end if - - if (rttov_configs(i) % Lrttov_rad) then - call addfld ("rttov_radpc_clr_inst"//trim(i_str), & - (/"RTTOV_CHAN_I"//trim(i_str)/), & - 'A', & - 'mW/cm-1/sr/m2', & - 'PC-RTTOV Clear-sky Radiance', & - flag_xyfill=.true., & - fill_value=R_UNDEF) - call add_default ("rttov_radpc_clr_inst"//trim(i_str),cosp_histfile_num,' ') - end if - end if - end do - end if - - if (masterproc) then - if (docosp) then - write(iulog,*)'Finished RTTOV section in cospsimulator_intr_init' - write(iulog,*)'lrttov_sim: ', lrttov_sim - end if - end if - - !! ADDFLD, ADD_DEFAULT, OUTFLD CALLS FOR COSP OUTPUTS IF RUNNING COSP OFF-LINE - !! Note: A suggestion was to add all of the CAM variables needed to add to make it possible to run COSP off-line - !! These fields are available and can be called from the namelist though. Here, when the cosp_runall mode is invoked - !! all of the inputs are saved on the cam history file. This is good de-bugging functionality we should maintain. - if (cosp_histfile_aux) then - call addfld ('PS_COSP', horiz_only, 'I','Pa', 'PS_COSP', & - flag_xyfill=.true., fill_value=R_UNDEF) - call addfld ('TS_COSP', horiz_only, 'I','K', 'TS_COSP', & - flag_xyfill=.true., fill_value=R_UNDEF) - call addfld ('P_COSP', (/ 'lev'/), 'I','Pa', 'P_COSP', & - flag_xyfill=.true., fill_value=R_UNDEF) - call addfld ('PH_COSP', (/ 'lev'/), 'I','Pa', 'PH_COSP', & - flag_xyfill=.true., fill_value=R_UNDEF) - call addfld ('ZLEV_COSP', (/ 'lev'/), 'I','m', 'ZLEV_COSP', & - flag_xyfill=.true., fill_value=R_UNDEF) - call addfld ('ZLEV_HALF_COSP', (/ 'lev'/), 'I','m', 'ZLEV_HALF_COSP', & - flag_xyfill=.true., fill_value=R_UNDEF) - call addfld ('T_COSP', (/ 'lev'/), 'I','K', 'T_COSP', & - flag_xyfill=.true., fill_value=R_UNDEF) - call addfld ('RH_COSP', (/ 'lev'/), 'I','percent','RH_COSP', & - flag_xyfill=.true., fill_value=R_UNDEF) - call addfld ('Q_COSP', (/ 'lev'/), 'I','kg/kg', 'Q_COSP', & - flag_xyfill=.true., fill_value=R_UNDEF) - call addfld ('TAU_067', (/'cosp_scol','lev '/), 'I','1', 'Subcolumn 0.67micron optical depth', & - flag_xyfill=.true., fill_value=R_UNDEF) - call addfld ('EMISS_11', (/'cosp_scol','lev '/), 'I','1', 'Subcolumn 11micron emissivity', & - flag_xyfill=.true., fill_value=R_UNDEF) - call addfld ('MODIS_fracliq', (/'cosp_scol','lev '/), 'I','1', 'Fraction of tau from liquid water', & - flag_xyfill=.true., fill_value=R_UNDEF) - call addfld ('MODIS_asym', (/'cosp_scol','lev '/), 'I','1', 'Assymetry parameter (MODIS)', & - flag_xyfill=.true., fill_value=R_UNDEF) - call addfld ('MODIS_ssa', (/'cosp_scol','lev '/), 'I','1', 'Single-scattering albedo (MODIS)', & - flag_xyfill=.true., fill_value=R_UNDEF) - call addfld ('CAL_betatot', (/'cosp_scol','lev '/), 'I','1', 'Backscatter coefficient (CALIPSO)', & - flag_xyfill=.true., fill_value=R_UNDEF) - call addfld ('CAL_betatot_ice', (/'cosp_scol','lev '/), 'I','1', 'Backscatter coefficient (CALIPSO)', & - flag_xyfill=.true., fill_value=R_UNDEF) - call addfld ('CAL_betatot_liq', (/'cosp_scol','lev '/), 'I','1', 'Backscatter coefficient (CALIPSO)', & - flag_xyfill=.true., fill_value=R_UNDEF) - call addfld ('CAL_tautot', (/'cosp_scol','lev '/), 'I','1', 'Vertically integrated ptical-depth (CALIPSO)', & - flag_xyfill=.true., fill_value=R_UNDEF) - call addfld ('CAL_tautot_ice', (/'cosp_scol','lev '/), 'I','1', 'Vertically integrated ptical-depth (CALIPSO)', & - flag_xyfill=.true., fill_value=R_UNDEF) - call addfld ('CAL_tautot_liq', (/'cosp_scol','lev '/), 'I','1', 'Vertically integrated ptical-depth (CALIPSO)', & - flag_xyfill=.true., fill_value=R_UNDEF) - call addfld ('CS_z_vol', (/'cosp_scol','lev '/), 'I','1', 'Effective reflectivity factor (CLOUDSAT)', & - flag_xyfill=.true., fill_value=R_UNDEF) - call addfld ('CS_kr_vol', (/'cosp_scol','lev '/), 'I','1', 'Attenuation coefficient (hydro) (CLOUDSAT)', & - flag_xyfill=.true., fill_value=R_UNDEF) - call addfld ('CS_g_vol', (/'cosp_scol','lev '/), 'I','1', 'Attenuation coefficient (gases) (CLOUDSAT)', & - flag_xyfill=.true., fill_value=R_UNDEF) - - call add_default ('PS_COSP', cosp_histfile_aux_num,' ') - call add_default ('TS_COSP', cosp_histfile_aux_num,' ') - call add_default ('P_COSP', cosp_histfile_aux_num,' ') - call add_default ('PH_COSP', cosp_histfile_aux_num,' ') - call add_default ('ZLEV_COSP', cosp_histfile_aux_num,' ') - call add_default ('ZLEV_HALF_COSP', cosp_histfile_aux_num,' ') - call add_default ('T_COSP', cosp_histfile_aux_num,' ') - call add_default ('RH_COSP', cosp_histfile_aux_num,' ') - call add_default ('TAU_067', cosp_histfile_aux_num,' ') - call add_default ('EMISS_11', cosp_histfile_aux_num,' ') - call add_default ('MODIS_fracliq', cosp_histfile_aux_num,' ') - call add_default ('MODIS_asym', cosp_histfile_aux_num,' ') - call add_default ('MODIS_ssa', cosp_histfile_aux_num,' ') - call add_default ('CAL_betatot', cosp_histfile_aux_num,' ') - call add_default ('CAL_betatot_ice', cosp_histfile_aux_num,' ') - call add_default ('CAL_betatot_liq', cosp_histfile_aux_num,' ') - call add_default ('CAL_tautot', cosp_histfile_aux_num,' ') - call add_default ('CAL_tautot_ice', cosp_histfile_aux_num,' ') - call add_default ('CAL_tautot_liq', cosp_histfile_aux_num,' ') - call add_default ('CS_z_vol', cosp_histfile_aux_num,' ') - call add_default ('CS_kr_vol', cosp_histfile_aux_num,' ') - call add_default ('CS_g_vol', cosp_histfile_aux_num,' ') - end if - - rei_idx = pbuf_get_index('REI') - rel_idx = pbuf_get_index('REL') - cld_idx = pbuf_get_index('CLD') - concld_idx = pbuf_get_index('CONCLD') - lsreffrain_idx = pbuf_get_index('LS_REFFRAIN') - lsreffsnow_idx = pbuf_get_index('LS_REFFSNOW') - cvreffliq_idx = pbuf_get_index('CV_REFFLIQ') - cvreffice_idx = pbuf_get_index('CV_REFFICE') - dpcldliq_idx = pbuf_get_index('DP_CLDLIQ') - dpcldice_idx = pbuf_get_index('DP_CLDICE') - shcldliq_idx = pbuf_get_index('SH_CLDLIQ') - shcldice_idx = pbuf_get_index('SH_CLDICE') - shcldliq1_idx = pbuf_get_index('SH_CLDLIQ1') - shcldice1_idx = pbuf_get_index('SH_CLDICE1') - dpflxprc_idx = pbuf_get_index('DP_FLXPRC') - dpflxsnw_idx = pbuf_get_index('DP_FLXSNW') - shflxprc_idx = pbuf_get_index('SH_FLXPRC') - shflxsnw_idx = pbuf_get_index('SH_FLXSNW') - lsflxprc_idx = pbuf_get_index('LS_FLXPRC') - lsflxsnw_idx = pbuf_get_index('LS_FLXSNW') -! ubot_idx = pbuf_get_index('U10') ! alternate option is 10m winds (U10 and V10) -! vbot_idx = pbuf_get_index('V10') - - allocate(first_run_cosp(begchunk:endchunk)) - first_run_cosp(begchunk:endchunk)=.true. - allocate(run_cosp(1:pcols,begchunk:endchunk)) - run_cosp(1:pcols,begchunk:endchunk)=.false. - -#endif - end subroutine cospsimulator_intr_init - - ! ###################################################################################### - ! SUBROUTINE cospsimulator_intr_run - ! ###################################################################################### - subroutine cospsimulator_intr_run(state,pbuf, cam_in,emis,coszrs,cld_swtau_in,snow_tau_in,snow_emis_in) - use physics_types, only: physics_state - use physics_buffer, only: physics_buffer_desc, pbuf_get_field, pbuf_old_tim_idx - use camsrfexch, only: cam_in_t - use constituents, only: cnst_get_ind - use rad_constituents, only: rad_cnst_get_gas - use wv_saturation, only: qsat_water - use interpolate_data, only: lininterp_init,lininterp,lininterp_finish,interp_type - use physconst, only: pi, gravit - use cam_history, only: outfld,hist_fld_col_active - use cam_history_support, only: max_fieldname_len - use cmparray_mod, only: CmpDayNite, ExpDayNite -#ifdef USE_COSP - use mod_cosp_config, only: R_UNDEF,parasol_nrefl, Nlvgrid, vgrid_zl, vgrid_zu - use mod_cosp, only: cosp_simulator - use mod_quickbeam_optics, only: size_distribution - use time_manager, only: get_curr_date ! Gets the date/time valid at the end of the timestep. Should be fine. -#endif - - ! ###################################################################################### - ! Inputs - ! ###################################################################################### - type(physics_state), intent(in),target :: state - type(physics_buffer_desc), pointer :: pbuf(:) - type(cam_in_t), intent(in) :: cam_in - real(r8), intent(in) :: emis(pcols,pver) ! cloud longwave emissivity - real(r8), intent(in) :: coszrs(pcols) ! cosine solar zenith angle (to tell if day or night) - real(r8), intent(in),optional :: cld_swtau_in(pcols,pver) ! RRTM cld_swtau_in, read in using this variable - real(r8), intent(in),optional :: snow_tau_in(pcols,pver) ! RRTM grid-box mean SW snow optical depth, used for CAM5 simulations - real(r8), intent(in),optional :: snow_emis_in(pcols,pver) ! RRTM grid-box mean LW snow optical depth, used for CAM5 simulations - -#ifdef USE_COSP - ! ###################################################################################### - ! Local variables - ! ###################################################################################### - integer :: lchnk ! chunk identifier - integer :: ncol ! number of active atmospheric columns - integer :: i,k,ip,it,ipt,ih,id,ihd,is,ihs,isc,ihsc,ihm,ihmt,ihml,itim_old,ifld - - ! Variables for day/nite and orbital subsetting - ! Gathered indicies of day and night columns - ! chunk_column_index = IdxDay(daylight_column_index) - integer :: Nday ! Number of daylight columns - integer :: Nno ! Number of columns not using for simulator - integer, dimension(pcols) :: IdxDay ! Indices of daylight columns - integer, dimension(pcols) :: IdxNo ! Indices of columns not using for simulator - real(r8) :: tmp(pcols) ! tempororary variable for array expansion - real(r8) :: tmp1(pcols,pver) ! tempororary variable for array expansion - real(r8) :: tmp2(pcols,pver) ! tempororary variable for array expansion - real(r8) :: lon_cosp_day(pcols) ! tempororary variable for sunlit lons - real(r8) :: lat_cosp_day(pcols) ! tempororary variable for sunlit lats - real(r8) :: ptop_day(pcols,pver) ! tempororary variable for sunlit ptop - real(r8) :: pmid_day(pcols,pver) ! tempororary variable for sunlit pmid - real(r8) :: ztop_day(pcols,pver) ! tempororary variable for sunlit ztop - real(r8) :: zmid_day(pcols,pver) ! tempororary variable for sunlit zmid - real(r8) :: t_day(pcols,pver) ! tempororary variable for sunlit t - real(r8) :: rh_day(pcols,pver) ! tempororary variable for sunlit rh - real(r8) :: q_day(pcols,pver) ! tempororary variable for sunlit q - real(r8) :: concld_day(pcols,pver) ! tempororary variable for sunlit concld - real(r8) :: cld_day(pcols,pver) ! tempororary variable for sunlit cld - real(r8) :: ps_day(pcols) ! tempororary variable for sunlit ps - real(r8) :: ts_day(pcols) ! tempororary variable for sunlit ts - real(r8) :: landmask_day(pcols) ! tempororary variable for sunlit landmask - real(r8) :: o3_day(pcols,pver) ! tempororary variable for sunlit o3 - real(r8) :: us_day(pcols) ! tempororary variable for sunlit us - real(r8) :: vs_day(pcols) ! tempororary variable for sunlit vs - real(r8) :: mr_lsliq_day(pcols,pver) ! tempororary variable for sunlit mr_lsliq - real(r8) :: mr_lsice_day(pcols,pver) ! tempororary variable for sunlit mr_lsice - real(r8) :: mr_ccliq_day(pcols,pver) ! tempororary variable for sunlit mr_ccliq - real(r8) :: mr_ccice_day(pcols,pver) ! tempororary variable for sunlit mr_ccice - real(r8) :: rain_ls_interp_day(pcols,pver) ! tempororary variable for sunlit rain_ls_interp - real(r8) :: snow_ls_interp_day(pcols,pver) ! tempororary variable for sunlit snow_ls_interp - real(r8) :: grpl_ls_interp_day(pcols,pver) ! tempororary variable for sunlit grpl_ls_interp - real(r8) :: rain_cv_interp_day(pcols,pver) ! tempororary variable for sunlit rain_cv_interp - real(r8) :: snow_cv_interp_day(pcols,pver) ! tempororary variable for sunlit snow_cv_interp - real(r8) :: reff_cosp_day(pcols,pver,nhydro) ! tempororary variable for sunlit reff_cosp(:,:,:) - real(r8) :: dtau_s_day(pcols,pver) ! tempororary variable for sunlit dtau_s - real(r8) :: dtau_c_day(pcols,pver) ! tempororary variable for sunlit dtau_c - real(r8) :: dtau_s_snow_day(pcols,pver) ! tempororary variable for sunlit dtau_s_snow - real(r8) :: dem_s_day(pcols,pver) ! tempororary variable for sunlit dem_s - real(r8) :: dem_c_day(pcols,pver) ! tempororary variable for sunlit dem_c - real(r8) :: dem_s_snow_day(pcols,pver) ! tempororary variable for sunlit dem_s_snow - - ! Constants for optical depth calculation (from radcswmx.F90) - real(r8), parameter :: abarl = 2.817e-02_r8 ! A coefficient for extinction optical depth - real(r8), parameter :: bbarl = 1.305_r8 ! b coefficient for extinction optical depth - real(r8), parameter :: abari = 3.448e-03_r8 ! A coefficient for extinction optical depth - real(r8), parameter :: bbari = 2.431_r8 ! b coefficient for extinction optical depth - real(r8), parameter :: cldmin = 1.0e-80_r8 ! note: cldmin much less than cldmin from cldnrh - real(r8), parameter :: cldeps = 0.0_r8 - - ! Microphysics variables - integer, parameter :: ncnstmax=4 ! number of constituents - character(len=8), dimension(ncnstmax), parameter :: & ! constituent names - cnst_names = (/'CLDLIQ', 'CLDICE','NUMLIQ','NUMICE'/) - integer :: ncnst ! number of constituents (can vary) - integer :: ixcldliq ! cloud liquid amount index for state%q - integer :: ixcldice ! cloud ice amount index - integer :: ixnumliq ! cloud liquid number index - integer :: ixnumice ! cloud ice water index - - ! COSP-related local vars - type(cosp_outputs) :: cospOUT ! COSP simulator outputs - type(cosp_optical_inputs) :: cospIN ! COSP optical (or derived?) fields needed by simulators - type(cosp_column_inputs) :: cospstateIN ! COSP model fields needed by simulators - - ! COSP input variables that depend on CAM - ! 1) Npoints = number of gridpoints COSP will process (without subsetting, Npoints=ncol) - ! 2) Nlevels = number of model levels (Nlevels=pver) - real(r8), parameter :: time = 1.0_r8 ! time ! Time since start of run [days], set to 1 bc running over single CAM timestep - real(r8), parameter :: time_bnds(2)=(/0.5_r8,1.5_r8/) ! time_bnds ! Time boundaries - new in cosp v1.3, set following cosp_test.f90 line 121 - integer :: Npoints ! Number of gridpoints COSP will process - integer :: Nlevels ! Nlevels - logical :: use_reff ! True if effective radius to be used by radar simulator - ! (always used by lidar) - logical :: use_precipitation_fluxes ! True if precipitation fluxes are input to the algorithm - real(r8), parameter :: emsfc_lw = 0.99_r8 ! longwave emissivity of surface at 10.5 microns - ! set value same as in cloudsimulator.F90 - - ! Local vars related to calculations to go from CAM input to COSP input - ! cosp convective value includes both deep and shallow convection - real(r8) :: ptop(pcols,pver) ! top interface pressure (Pa) - real(r8) :: ztop(pcols,pver) ! top interface height asl (m) - real(r8) :: pbot(pcols,pver) ! bottom interface pressure (Pa) - real(r8) :: zbot(pcols,pver) ! bottom interface height asl (m) - real(r8) :: zmid(pcols,pver) ! middle interface height asl (m) - real(r8) :: lat_cosp(pcols) ! lat for cosp (degrees_north) - real(r8) :: lon_cosp(pcols) ! lon for cosp (degrees_east) - real(r8) :: landmask(pcols) ! landmask (0 or 1) - real(r8) :: mr_lsliq(pcols,pver) ! mixing_ratio_large_scale_cloud_liquid (kg/kg) - real(r8) :: mr_lsice(pcols,pver) ! mixing_ratio_large_scale_cloud_ice (kg/kg) - real(r8) :: mr_ccliq(pcols,pver) ! mixing_ratio_convective_cloud_liquid (kg/kg) - real(r8) :: mr_ccice(pcols,pver) ! mixing_ratio_convective_cloud_ice (kg/kg) - real(r8) :: rain_cv(pcols,pverp) ! interface flux_convective_cloud_rain (kg m^-2 s^-1) - real(r8) :: snow_cv(pcols,pverp) ! interface flux_convective_cloud_snow (kg m^-2 s^-1) - real(r8) :: rain_cv_interp(pcols,pver) ! midpoint flux_convective_cloud_rain (kg m^-2 s^-1) - real(r8) :: snow_cv_interp(pcols,pver) ! midpoint flux_convective_cloud_snow (kg m^-2 s^-1) - real(r8) :: grpl_ls_interp(pcols,pver) ! midpoint ls grp flux, should be 0 - real(r8) :: rain_ls_interp(pcols,pver) ! midpoint ls rain flux (kg m^-2 s^-1) - real(r8) :: snow_ls_interp(pcols,pver) ! midpoint ls snow flux - real(r8) :: reff_cosp(pcols,pver,nhydro) ! effective radius for cosp input - real(r8) :: rh(pcols,pver) ! relative_humidity_liquid_water (%) - real(r8) :: es(pcols,pver) ! saturation vapor pressure - real(r8) :: qs(pcols,pver) ! saturation mixing ratio (kg/kg), saturation specific humidity - real(r8) :: cld_swtau(pcols,pver) ! incloud sw tau for input to COSP - real(r8) :: dtau_s(pcols,pver) ! dtau_s - Optical depth of stratiform cloud at 0.67 um - real(r8) :: dtau_c(pcols,pver) ! dtau_c - Optical depth of convective cloud at 0.67 um - real(r8) :: dtau_s_snow(pcols,pver) ! dtau_s_snow - Grid-box mean Optical depth of stratiform snow at 0.67 um - real(r8) :: dem_s(pcols,pver) ! dem_s - Longwave emis of stratiform cloud at 10.5 um - real(r8) :: dem_c(pcols,pver) ! dem_c - Longwave emis of convective cloud at 10.5 um - real(r8) :: dem_s_snow(pcols,pver) ! dem_s_snow - Grid-box mean Optical depth of stratiform snow at 10.5 um - integer :: cam_sunlit(pcols) ! cam_sunlit - Sunlit flag(1-sunlit/0-dark). - integer :: nSunLit,nNoSunLit ! Number of sunlit (not sunlit) scenes. - integer :: rttov_sfcmask(pcols) ! Mask for RTTOV surface type (0=ocean, 1=land, 2=seaice) -! integer :: rttov_sza(pcols) ! Solar Zenith Angle calculated from coszrs ! JKS remove - ! ###################################################################################### - ! Simulator output info - ! ###################################################################################### - integer, parameter :: nf_radar=17 ! number of radar outputs - integer, parameter :: nf_calipso=28 ! number of calipso outputs - integer, parameter :: nf_isccp=9 ! number of isccp outputs - integer, parameter :: nf_misr=1 ! number of misr outputs - integer, parameter :: nf_modis=20 ! number of modis outputs - integer, parameter :: nf_rttov=9 ! JKS - I don't think I can do this so simply. 9 possible outputs + the channel indices? - - ! Cloudsat outputs - character(len=max_fieldname_len),dimension(nf_radar),parameter :: & - fname_radar = (/'CFAD_DBZE94_CS', 'CLD_CAL_NOTCS ', 'DBZE_CS ', & - 'CLDTOT_CALCS ', 'CLDTOT_CS ', 'CLDTOT_CS2 ', & - 'CS_NOPRECIP ', 'CS_RAINPOSS ', 'CS_RAINPROB ', & - 'CS_RAINCERT ', 'CS_SNOWPOSS ', 'CS_SNOWCERT ', & - 'CS_MIXPOSS ', 'CS_MIXCERT ', 'CS_RAINHARD ', & - 'CS_UN ', 'CS_PIA '/)!, 'CAM_MP_CVRAIN ', & - !'CAM_MP_CVSNOW ', 'CAM_MP_LSRAIN ', 'CAM_MP_LSSNOW ', & - !'CAM_MP_LSGRPL '/) - - ! CALIPSO outputs - character(len=max_fieldname_len),dimension(nf_calipso),parameter :: & - fname_calipso=(/'CLDLOW_CAL ','CLDMED_CAL ','CLDHGH_CAL ','CLDTOT_CAL ','CLD_CAL ',& - 'RFL_PARASOL ','CFAD_SR532_CAL ','ATB532_CAL ','MOL532_CAL ','CLD_CAL_LIQ ',& - 'CLD_CAL_ICE ','CLD_CAL_UN ','CLD_CAL_TMP ','CLD_CAL_TMPLIQ ','CLD_CAL_TMPICE ',& - 'CLD_CAL_TMPUN ','CLDTOT_CAL_ICE ','CLDTOT_CAL_LIQ ','CLDTOT_CAL_UN ','CLDHGH_CAL_ICE ',& - 'CLDHGH_CAL_LIQ ','CLDHGH_CAL_UN ','CLDMED_CAL_ICE ','CLDMED_CAL_LIQ ','CLDMED_CAL_UN ',& - 'CLDLOW_CAL_ICE ','CLDLOW_CAL_LIQ ','CLDLOW_CAL_UN '/)!, & -! 'CLDOPQ_CAL ','CLDTHN_CAL ','CLDZOPQ_CAL ','CLDOPQ_CAL_2D ','CLDTHN_CAL_2D ',& -! 'CLDZOPQ_CAL_2D ','OPACITY_CAL_2D ','CLDOPQ_CAL_TMP ','CLDTHN_CAL_TMP ','CLDZOPQ_CAL_TMP',& -! 'CLDOPQ_CAL_Z ','CLDTHN_CAL_Z ','CLDTHN_CAL_EMIS','CLDOPQ_CAL_SE ','CLDTHN_CAL_SE ',& -! 'CLDZOPQ_CAL_SE' /) - ! ISCCP outputs - character(len=max_fieldname_len),dimension(nf_isccp),parameter :: & - fname_isccp=(/'FISCCP1_COSP ','CLDTOT_ISCCP ','MEANCLDALB_ISCCP',& - 'MEANPTOP_ISCCP ','TAU_ISCCP ','CLDPTOP_ISCCP ','MEANTAU_ISCCP ',& - 'MEANTB_ISCCP ','MEANTBCLR_ISCCP '/) - ! MISR outputs - character(len=max_fieldname_len),dimension(nf_misr),parameter :: & - fname_misr=(/'CLD_MISR '/) - ! MODIS outputs - character(len=max_fieldname_len),dimension(nf_modis) :: & - fname_modis=(/'CLTMODIS ','CLWMODIS ','CLIMODIS ','CLHMODIS ','CLMMODIS ',& - 'CLLMODIS ','TAUTMODIS ','TAUWMODIS ','TAUIMODIS ','TAUTLOGMODIS',& - 'TAUWLOGMODIS','TAUILOGMODIS','REFFCLWMODIS','REFFCLIMODIS',& - 'PCTMODIS ','LWPMODIS ','IWPMODIS ','CLMODIS ','CLRIMODIS ',& - 'CLRLMODIS '/) - - character(len=8) :: & - fmt, & ! format descriptor for flexible RTTOV output - i_str - - ! JKS RTTOV outputs? - character(len=max_fieldname_len),dimension(rttov_Ninstruments,nf_rttov) :: & - fname_rttov - - logical :: run_radar(nf_radar,pcols) ! logical telling you if you should run radar simulator - logical :: run_calipso(nf_calipso,pcols) ! logical telling you if you should run calipso simulator - logical :: run_isccp(nf_isccp,pcols) ! logical telling you if you should run isccp simulator - logical :: run_misr(nf_misr,pcols) ! logical telling you if you should run misr simulator - logical :: run_modis(nf_modis,pcols) ! logical telling you if you should run modis simulator - logical :: run_rttov(rttov_Ninstruments,nf_rttov,pcols) ! logical telling you if you should run rttov simulator - - ! CAM pointers to get variables from radiation interface (get from rad_cnst_get_gas) - real(r8), pointer, dimension(:,:) :: q ! specific humidity (kg/kg) - real(r8), pointer, dimension(:,:) :: o3 ! Mass mixing ratio 03 - real(r8), pointer, dimension(:,:) :: co2 ! Mass mixing ratio C02 - real(r8), pointer, dimension(:,:) :: ch4 ! Mass mixing ratio CH4 - real(r8), pointer, dimension(:,:) :: n2o ! Mass mixing ratio N20 - real(r8), pointer, dimension(:,:) :: co ! Mass mixing ratio CO -! real(r8), pointer, dimension(:,:) :: so2 ! Mass mixing ratio SO2 - JKS - - ! CAM pointers to get variables from the physics buffer - real(r8), pointer, dimension(:,:) :: cld ! cloud fraction, tca - total_cloud_amount (0-1) - real(r8), pointer, dimension(:,:) :: concld ! concld fraction, cca - convective_cloud_amount (0-1) - real(r8), pointer, dimension(:,:) :: rel ! liquid effective drop radius (microns) - real(r8), pointer, dimension(:,:) :: rei ! ice effective drop size (microns) - real(r8), pointer, dimension(:,:) :: ls_reffrain ! rain effective drop radius (microns) - real(r8), pointer, dimension(:,:) :: ls_reffsnow ! snow effective drop size (microns) - real(r8), pointer, dimension(:,:) :: cv_reffliq ! convective cld liq effective drop radius (microns) - real(r8), pointer, dimension(:,:) :: cv_reffice ! convective cld ice effective drop size (microns) - - !! precip flux pointers (use for cam4 or cam5) - ! Added pointers; pbuff in zm_conv_intr.F90, calc in zm_conv.F90 - real(r8), pointer, dimension(:,:) :: dp_flxprc ! deep interface gbm flux_convective_cloud_rain+snow (kg m^-2 s^-1) - real(r8), pointer, dimension(:,:) :: dp_flxsnw ! deep interface gbm flux_convective_cloud_snow (kg m^-2 s^-1) - ! More pointers; pbuf in convect_shallow.F90, calc in hk_conv.F90/convect_shallow.F90 (CAM4), uwshcu.F90 (CAM5) - real(r8), pointer, dimension(:,:) :: sh_flxprc ! shallow interface gbm flux_convective_cloud_rain+snow (kg m^-2 s^-1) - real(r8), pointer, dimension(:,:) :: sh_flxsnw ! shallow interface gbm flux_convective_cloud_snow (kg m^-2 s^-1) - ! More pointers; pbuf in stratiform.F90, getting from pbuf here - ! a) added as output to pcond subroutine in cldwat.F90 and to nmicro_pcond subroutine in cldwat2m_micro.F90 - real(r8), pointer, dimension(:,:) :: ls_flxprc ! stratiform interface gbm flux_cloud_rain+snow (kg m^-2 s^-1) - real(r8), pointer, dimension(:,:) :: ls_flxsnw ! stratiform interface gbm flux_cloud_snow (kg m^-2 s^-1) - - !! cloud mixing ratio pointers (note: large-scale in state) - ! More pointers; pbuf in convect_shallow.F90 (cam4) or stratiform.F90 (cam5) - ! calc in hk_conv.F90 (CAM4 should be 0!), uwshcu.F90 but then affected by micro so values from stratiform.F90 (CAM5) - real(r8), pointer, dimension(:,:) :: sh_cldliq ! shallow gbm cloud liquid water (kg/kg) - real(r8), pointer, dimension(:,:) :: sh_cldice ! shallow gbm cloud ice water (kg/kg) - ! More pointers; pbuf in zm_conv_intr.F90, calc in zm_conv.F90, 0 for CAM4 and CAM5 (same convection scheme) - real(r8), pointer, dimension(:,:) :: dp_cldliq ! deep gbm cloud liquid water (kg/kg) - real(r8), pointer, dimension(:,:) :: dp_cldice ! deep gmb cloud ice water (kg/kg) - - ! Surface wind pointers for RTTOV -! real(r8), pointer, dimension(:) :: ubot ! Lowest model level zonal wind -! real(r8), pointer, dimension(:) :: vbot ! Lowest model level meridional wind - - ! Output CAM variables - ! Notes: - ! 1) use pcols (maximum number of columns that code could use, maybe 16) - ! pcols vs. ncol. ncol is the number of columns a chunk is actually using, pcols is maximum number - ! 2) Mixed variables rules/notes, need to collapse because CAM history does not support increased dimensionality - ! MIXED DIMS: ntau_cosp*nprs_cosp, CLOUDSAT_DBZE_BINS*nht_cosp, nsr_cosp*nht_cosp, nscol_cosp*nhtml_cosp, ntau_cosp*nhtmisr_cosp - ! a) always making mixed variables VERTICAL*OTHER, e.g., pressure*tau or ht*dbze - ! b) always collapsing output as V1_1/V2_1...V1_1/V2_N ; V1_2/V2_1 ...V1_2/V2_N etc. to V1_N/V2_1 ... V1_N/V2_N - ! c) here, need vars for both multi-dimensional output from COSP, and two-dimensional output from CAM - ! 3) ntime=1, nprofile=ncol - ! 4) dimensions listed in COSP units are from netcdf output from cosp test case, and are not necessarily in the - ! correct order. In fact, most of them are not as I discovered after trying to run COSP in-line. - ! BE says this could be because FORTRAN and C (netcdf defaults to C) have different conventions. - ! 5) !! Note: after running COSP, it looks like height_mlev is actually the model levels after all!! - real(r8) :: clisccp2(pcols,ntau_cosp,nprs_cosp) ! clisccp2 (time,tau,plev,profile) - real(r8) :: cfad_dbze94(pcols,CLOUDSAT_DBZE_BINS,nht_cosp) ! cfad_dbze94 (time,height,dbze,profile) - real(r8) :: cfad_lidarsr532(pcols,nsr_cosp,nht_cosp) ! cfad_lidarsr532 (time,height,scat_ratio,profile) - real(r8) :: dbze94(pcols,nscol_cosp,nhtml_cosp) ! dbze94 (time,height_mlev,column,profile) - real(r8) :: atb532(pcols,nscol_cosp,nhtml_cosp) ! atb532 (time,height_mlev,column,profile) - real(r8) :: clMISR(pcols,ntau_cosp,nhtmisr_cosp) ! clMISR (time,tau,CTH_height_bin,profile) - real(r8) :: frac_out(pcols,nscol_cosp,nhtml_cosp) ! frac_out (time,height_mlev,column,profile) - real(r8) :: cldtot_isccp(pcols) ! CAM tclisccp (time,profile) - real(r8) :: meancldalb_isccp(pcols) ! CAM albisccp (time,profile) - real(r8) :: meanptop_isccp(pcols) ! CAM ctpisccp (time,profile) - real(r8) :: cldlow_cal(pcols) ! CAM cllcalipso (time,profile) - real(r8) :: cldmed_cal(pcols) ! CAM clmcalipso (time,profile) - real(r8) :: cldhgh_cal(pcols) ! CAM clhcalipso (time,profile) - real(r8) :: cldtot_cal(pcols) ! CAM cltcalipso (time,profile) - real(r8) :: cldtot_cal_ice(pcols) ! CAM (time,profile) !!+cosp1.4 - real(r8) :: cldtot_cal_liq(pcols) ! CAM (time,profile) - real(r8) :: cldtot_cal_un(pcols) ! CAM (time,profile) - real(r8) :: cldhgh_cal_ice(pcols) ! CAM (time,profile) - real(r8) :: cldhgh_cal_liq(pcols) ! CAM (time,profile) - real(r8) :: cldhgh_cal_un(pcols) ! CAM (time,profile) - real(r8) :: cldmed_cal_ice(pcols) ! CAM (time,profile) - real(r8) :: cldmed_cal_liq(pcols) ! CAM (time,profile) - real(r8) :: cldmed_cal_un(pcols) ! CAM (time,profile) - real(r8) :: cldlow_cal_ice(pcols) ! CAM (time,profile) - real(r8) :: cldlow_cal_liq(pcols) ! CAM (time,profile) - real(r8) :: cldlow_cal_un(pcols) ! CAM (time,profile) !+cosp1.4 - real(r8) :: cld_cal(pcols,nht_cosp) ! CAM clcalipso (time,height,profile) - real(r8) :: cld_cal_liq(pcols,nht_cosp) ! CAM (time,height,profile) !+cosp1.4 - real(r8) :: cld_cal_ice(pcols,nht_cosp) ! CAM (time,height,profile) - real(r8) :: cld_cal_un(pcols,nht_cosp) ! CAM (time,height,profile) - real(r8) :: cld_cal_tmp(pcols,nht_cosp) ! CAM (time,height,profile) - real(r8) :: cld_cal_tmpliq(pcols,nht_cosp) ! CAM (time,height,profile) - real(r8) :: cld_cal_tmpice(pcols,nht_cosp) ! CAM (time,height,profile) - real(r8) :: cld_cal_tmpun(pcols,nht_cosp) ! CAM (time,height,profile) !+cosp1.4 -! real(r8) :: cldopaq_cal(pcols) -! real(r8) :: cldthin_cal(pcols) -! real(r8) :: cldopaqz_cal(pcols) -! real(r8) :: cldopaq_cal_temp(pcols) -! real(r8) :: cldthin_cal_temp(pcols) -! real(r8) :: cldzopaq_cal_temp(pcols) -! real(r8) :: cldopaq_cal_z(pcols) -! real(r8) :: cldthin_cal_z(pcols) -! real(r8) :: cldthin_cal_emis(pcols) -! real(r8) :: cldopaq_cal_se(pcols) -! real(r8) :: cldthin_cal_se(pcols) -! real(r8) :: cldzopaq_cal_se(pcols) -! real(r8) :: cldopaq_cal_2d(pcols,nht_cosp) -! real(r8) :: cldthin_cal_2d(pcols,nht_cosp) -! real(r8) :: cldzopaq_cal_2d(pcols,nht_cosp) -! real(r8) :: opacity_cal_2d(pcols,nht_cosp) - real(r8) :: cfad_dbze94_cs(pcols,nht_cosp*CLOUDSAT_DBZE_BINS)! CAM cfad_dbze94 (time,height,dbze,profile) - real(r8) :: cfad_sr532_cal(pcols,nht_cosp*nsr_cosp) ! CAM cfad_lidarsr532 (time,height,scat_ratio,profile) - real(r8) :: tau_isccp(pcols,nscol_cosp) ! CAM boxtauisccp (time,column,profile) - real(r8) :: cldptop_isccp(pcols,nscol_cosp) ! CAM boxptopisccp (time,column,profile) - real(r8) :: meantau_isccp(pcols) ! CAM tauisccp (time,profile) - real(r8) :: meantb_isccp(pcols) ! CAM meantbisccp (time,profile) - real(r8) :: meantbclr_isccp(pcols) ! CAM meantbclrisccp (time,profile) - real(r8) :: dbze_cs(pcols,nhtml_cosp*nscol_cosp) ! CAM dbze94 (time,height_mlev,column,profile) - real(r8) :: cldtot_calcs(pcols) ! CAM cltlidarradar (time,profile) - real(r8) :: cldtot_cs(pcols) ! CAM cltradar (time,profile) - real(r8) :: cldtot_cs2(pcols) ! CAM cltradar2 (time,profile) - real(r8) :: ptcloudsatflag0(pcols) - real(r8) :: ptcloudsatflag1(pcols) - real(r8) :: ptcloudsatflag2(pcols) - real(r8) :: ptcloudsatflag3(pcols) - real(r8) :: ptcloudsatflag4(pcols) - real(r8) :: ptcloudsatflag5(pcols) - real(r8) :: ptcloudsatflag6(pcols) - real(r8) :: ptcloudsatflag7(pcols) - real(r8) :: ptcloudsatflag8(pcols) - real(r8) :: ptcloudsatflag9(pcols) - real(r8) :: cloudsatpia(pcols) - real(r8) :: cld_cal_notcs(pcols,nht_cosp) ! CAM clcalipso2 (time,height,profile) - real(r8) :: atb532_cal(pcols,nhtml_cosp*nscol_cosp) ! CAM atb532 (time,height_mlev,column,profile) - real(r8) :: mol532_cal(pcols,nhtml_cosp) ! CAM beta_mol532 (time,height_mlev,profile) - real(r8) :: cld_misr(pcols,nhtmisr_cosp*ntau_cosp) ! CAM clMISR (time,tau,CTH_height_bin,profile) - real(r8) :: refl_parasol(pcols,nsza_cosp) ! CAM parasol_refl (time,sza,profile) - real(r8) :: scops_out(pcols,nhtml_cosp*nscol_cosp) ! CAM frac_out (time,height_mlev,column,profile) - real(r8) :: cltmodis(pcols) - real(r8) :: clwmodis(pcols) - real(r8) :: climodis(pcols) - real(r8) :: clhmodis(pcols) - real(r8) :: clmmodis(pcols) - real(r8) :: cllmodis(pcols) - real(r8) :: tautmodis(pcols) - real(r8) :: tauwmodis(pcols) - real(r8) :: tauimodis(pcols) - real(r8) :: tautlogmodis(pcols) - real(r8) :: tauwlogmodis(pcols) - real(r8) :: tauilogmodis(pcols) - real(r8) :: reffclwmodis(pcols) - real(r8) :: reffclimodis(pcols) - real(r8) :: pctmodis(pcols) - real(r8) :: lwpmodis(pcols) - real(r8) :: iwpmodis(pcols) - real(r8) :: clmodis_cam(pcols,ntau_cosp_modis*nprs_cosp) - real(r8) :: clmodis(pcols,ntau_cosp_modis,nprs_cosp) - real(r8) :: clrimodis_cam(pcols,ntau_cosp*numMODISReffIceBins) - real(r8) :: clrimodis(pcols,ntau_cosp,numMODISReffIceBins) - real(r8) :: clrlmodis_cam(pcols,ntau_cosp*numMODISReffLiqBins) - real(r8) :: clrlmodis(pcols,ntau_cosp,numMODISReffLiqBins) - !real(r8) :: tau067_out(pcols,nhtml_cosp*nscol_cosp),emis11_out(pcols,nhtml_cosp*nscol_cosp) - real(r8),dimension(pcols,nhtml_cosp*nscol_cosp) :: & - tau067_out,emis11_out,fracliq_out,cal_betatot,cal_betatot_ice, & - cal_betatot_liq,cal_tautot,cal_tautot_ice,cal_tautot_liq,cs_gvol_out,cs_krvol_out,cs_zvol_out,& - asym34_out,ssa34_out - - type(rttov_output_write),dimension(rttov_Ninstruments) :: rttov_outputs_cp - - type(interp_type) :: interp_wgts - integer, parameter :: extrap_method = 1 ! sets extrapolation method to boundary value (1) - - ! COSPv2 stuff - character(len=256),dimension(100) :: cosp_status - integer :: nerror - - ! Variables for determining the time. - integer :: yr, mon, day ! year, month, and day components of a date - integer :: ncsec ! current time of day [seconds] - - ! Create the fname string array for RTTOV - fmt = '(I3.3)' ! an integer of width 3 with zeros at the left - do i=1,rttov_Ninstruments - write (i_str,fmt) i ! converting integer to string i_str using a 'internal file' - do k=1,nf_rttov - fname_rttov(i,:) = (/"rttov_bt_total_inst"//trim(i_str), & - "rttov_bt_clear_inst"//trim(i_str), & - "rttov_rad_total_inst"//trim(i_str), & - "rttov_rad_clear_inst"//trim(i_str), & - "rttov_rad_cloudy_inst"//trim(i_str), & - "rttov_refl_total_inst"//trim(i_str), & - "rttov_refl_clear_inst"//trim(i_str), & - "rttov_btpc_clr_inst"//trim(i_str), & - "rttov_radpc_clr_inst"//trim(i_str) /) - end do - end do - - call t_startf("allocate rttov_outputs_cp") - ! Allocate the DDT for the RTTOV outputs (bleh?) - if (lrttov_sim) then - do i=1,rttov_Ninstruments - rttov_outputs_cp(i) % nchan_out = rttov_configs(i) % nchan_out - ! Only allocate output if the output has been requested? - - if (not(rttov_configs(i) % Lrttov_pc)) then - if (rttov_configs(i) % Lrttov_bt) then - allocate(rttov_outputs_cp(i) % bt_total(pcols,rttov_configs(i) % nchan_out)) - end if - if (rttov_configs(i) % Lrttov_bt .and. ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer))) then - allocate(rttov_outputs_cp(i) % bt_clear(pcols,rttov_configs(i) % nchan_out)) - end if - if (rttov_configs(i) % Lrttov_rad) then - allocate(rttov_outputs_cp(i) % rad_total(pcols,rttov_configs(i) % nchan_out)) - end if - if (rttov_configs(i) % Lrttov_rad .and. ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer))) then - allocate(rttov_outputs_cp(i) % rad_clear(pcols,rttov_configs(i) % nchan_out)) - allocate(rttov_outputs_cp(i) % rad_cloudy(pcols,rttov_configs(i) % nchan_out)) - end if - if (rttov_configs(i) % Lrttov_refl) then - allocate(rttov_outputs_cp(i) % refl_total(pcols,rttov_configs(i) % nchan_out)) - end if - if (rttov_configs(i) % Lrttov_refl .and. ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer))) then - allocate(rttov_outputs_cp(i) % refl_clear(pcols,rttov_configs(i) % nchan_out)) - end if - else - if (rttov_configs(i) % Lrttov_bt) then - allocate(rttov_outputs_cp(i) % bt_total_pc(pcols,rttov_configs(i) % nchan_out)) - end if - if (rttov_configs(i) % Lrttov_rad) then - allocate(rttov_outputs_cp(i) % rad_total_pc(pcols,rttov_configs(i) % nchan_out)) - end if - end if - end do - end if - call t_stopf("allocate rttov_outputs_cp") - - - call t_startf("init_and_stuff") - ! ###################################################################################### - ! Initialization - ! ###################################################################################### - ! Find the chunk and ncol from the state vector - lchnk = state%lchnk ! state variable contains a number of columns, one chunk - ncol = state%ncol ! number of columns in the chunk - - ! Initialize temporary variables as R_UNDEF - need to do this otherwise array expansion puts garbage in history - ! file for columns over which COSP did make calculations. - tmp(1:pcols) = R_UNDEF - tmp1(1:pcols,1:pver) = R_UNDEF - tmp2(1:pcols,1:pver) = R_UNDEF - - ! Initialize CAM variables as R_UNDEF, important for history files because it will exclude these from averages - ! (multi-dimensional output that will be collapsed) - ! initialize over all pcols, not just ncol. missing values needed in chunks where ncol 0.0_r8) .and. (run_cosp(i,lchnk))) then - cam_sunlit(i) = 1 - nSunLit = nSunLit+1 - else - nNoSunLit = nNoSunlit+1 - endif - enddo - endif - call t_stopf("init_and_stuff") - - ! ###################################################################################### - ! ###################################################################################### - ! END TRANSLATE CAM VARIABLES TO COSP INPUT VARIABLES - ! ###################################################################################### - ! ###################################################################################### - - ! ###################################################################################### - ! Construct COSP output derived type. - ! ###################################################################################### - - if (masterproc) then - if (docosp) then - write(iulog,*)'Starting RTTOV construct_cosp_outputs section in cospsimulator_intr_run' - end if - end if - - call t_startf("construct_cosp_outputs") - call construct_cosp_outputs(ncol,nscol_cosp,pver,Nlvgrid,rttov_Ninstruments,rttov_configs,cospOUT) - call t_stopf("construct_cosp_outputs") - print*,'post "construct_cosp_outputs" ' - print*,'associated(cospOUT % rttov_outputs(1) % refl_total): ',associated(cospOUT % rttov_outputs(1) % refl_total) - print*,'associated(cospOUT % rttov_outputs(1) % refl_clear): ',associated(cospOUT % rttov_outputs(1) % refl_clear) - - if (masterproc) then - if (docosp) then - write(iulog,*)'Finished RTTOV construct_cosp_outputs section in cospsimulator_intr_run' - end if - end if - - if (masterproc) then - if (docosp) then - write(iulog,*)'size(ch4): ',size(ch4) - write(iulog,*)'size(n2o): ',size(n2o) - end if - end if - - ! ###################################################################################### - ! Construct and populate COSP input types - ! ###################################################################################### - ! Model state - call t_startf("construct_cospstateIN") - call construct_cospstateIN(ncol,pver,cospstateIN) - cospstateIN%lat = lat_cosp(1:ncol) - cospstateIN%lon = lon_cosp(1:ncol) - cospstateIN%at = state%t(1:ncol,1:pver) - cospstateIN%qv = q(1:ncol,1:pver) - cospstateIN%tca = cld(1:ncol,1:pver) - cospstateIN%o3 = o3(1:ncol,1:pver) - cospstateIN%co2 = co2(1:ncol,1:pver) - cospstateIN%ch4 = ch4(1:ncol,1:pver) - cospstateIN%n2o = n2o(1:ncol,1:pver) - cospstateIN%co = 0._r8 -! For winds take the total 10m wind from cam_in and divide it such that the quadrature sum is the same. - cospstateIN%u_sfc = cam_in%u10(1:ncol) * (2**(-1/2)) - cospstateIN%v_sfc = cam_in%u10(1:ncol) * (2**(-1/2)) - cospstateIN%sunlit = cam_sunlit(1:ncol) - cospstateIN%skt = cam_in%ts(1:ncol) - cospstateIN%land = landmask(1:ncol) ! This is just a 0 or 1 logical. - cospstateIN%pfull = state%pmid(1:ncol,1:pver) - cospstateIN%phalf(1:ncol,1) = 0._r8 - cospstateIN%phalf(1:ncol,2:pver+1) = pbot(1:ncol,pver:1:-1) - cospstateIN%hgt_matrix = zmid(1:ncol,1:pver) - cospstateIN%hgt_matrix_half(1:ncol,1:pver) = zbot(1:ncol,pver:1:-1) - cospstateIN%surfelev(1:ncol) = zbot(1:ncol,1) - - cospstateIN%rttov_sfcmask = rttov_sfcmask(1:ncol) - -! cospstateIN%month(1:ncol) = 1 ! Arbitrary filler for now. -! cospstateIN%time_frac(1:ncol) = 0._r8 ! Arbitrary filler ! Time (UTC) expressed as a fraction on [0,1] - - ! Set time - call get_curr_date(yr, mon, day, ncsec) - -! rttov_sza = acosd(coszrs) - if (masterproc) then - if (docosp) then - write(iulog,*)'ncol: ',ncol - write(iulog,*)'mon: ',mon - write(iulog,*)'ncsec: ',ncsec - write(iulog,*)'coszrs: ',coszrs - write(iulog,*)'shape(coszrs): ',shape(coszrs) -! write(iulog,*)'rttov_sza: ',rttov_sza -! write(iulog,*)'shape(rttov_sza): ',shape(rttov_sza) - write(iulog,*)'shape(cospstateIN%sza): ',shape(cospstateIN%sza) - end if - end if - - ! JKS trying to figure out what is going on. -! if (ncol .ne. size(rttov_sza)) write(iulog,*)'ncol: ',ncol,'size(rttov_sza): ',size(rttov_sza) - - cospstateIN%month(1:ncol) = mon - cospstateIN%time_frac(1:ncol) = ncsec / (86400._r8) ! Seconds/day = 86,400 = 24 * 60 * 60 - - cospstateIN%sza(1:ncol) = acosd(coszrs(1:ncol)) ! Hokey because we get the SZA by taking the arcosine of cos(sza), but this seems to be the variable the radiation scheme can pass. - - if (masterproc) then - if (docosp) then - write(iulog,*)'cospstateIN%month: ',cospstateIN%month - write(iulog,*)'cospstateIN%time_frac: ',cospstateIN%time_frac - write(iulog,*)'coszrs: ',coszrs - write(iulog,*)'cospstateIN%sza: ',cospstateIN%sza - write(iulog,*)'cospstateIN%lat: ',cospstateIN%lat - write(iulog,*)'cospstateIN%lon: ',cospstateIN%lon - end if - end if - - ! JKS - ! Combine large-scale and convective cloud mixing ratios for RTTOV. Could pass in separately for cloud categories - cospstateIN%cloudIce = mr_lsice(1:ncol,1:pver) + mr_ccice(1:ncol,1:pver) - cospstateIN%cloudLiq = mr_lsliq(1:ncol,1:pver) + mr_ccliq(1:ncol,1:pver) - - - ! Combine large-scale and convective cloud effective radii into effective diameters for RTTOV - ! Reff(Npoints,Nlevels,N_HYDRO) - ! The weighted Reff is given by: Reff_net = (M_1 + M_2) / (M_1/Reff_1 + M_2/Reff_2) - cospstateIN%DeffLiq(:,:) = 0._r8 ! Initialize for zero everywhere. - where ((mr_lsliq(1:ncol,1:pver) .gt. 0._r8) .and. (mr_ccliq(1:ncol,1:pver) .gt. 0._r8)) - cospstateIN%DeffLiq(:,:) = 2._r8 * 1.0e6 * (mr_lsliq(1:ncol,1:pver) + mr_ccliq(1:ncol,1:pver)) / (mr_lsliq(1:ncol,1:pver) / reff_cosp(1:ncol,1:pver,I_LSCLIQ) + mr_ccliq(1:ncol,1:pver) / reff_cosp(1:ncol,1:pver,I_CVCLIQ)) - elsewhere (mr_lsliq(1:ncol,1:pver) .gt. 0._r8) - cospstateIN%DeffLiq(:,:) = 2._r8 * 1.0e6 * reff_cosp(1:ncol,1:pver,I_LSCLIQ) - elsewhere (mr_ccliq(:,Nlevels:1:-1) .gt. 0._r8) - cospstateIN%DeffLiq(:,:) = 2._r8 * 1.0e6 * reff_cosp(1:ncol,1:pver,I_CVCLIQ) - end where - - cospstateIN%DeffIce(:,:) = 0._r8 ! Initialize for zero everywhere. - where ((mr_lsice(1:ncol,1:pver) .gt. 0._r8) .and. (mr_ccice(1:ncol,1:pver) .gt. 0._r8)) - cospstateIN%DeffIce(:,:) = 2._r8 * 1.0e6 * (mr_lsice(1:ncol,1:pver) + mr_ccice(1:ncol,1:pver)) / (mr_lsice(1:ncol,1:pver) / reff_cosp(1:ncol,1:pver,I_LSCICE) + mr_ccice(1:ncol,1:pver) / reff_cosp(1:ncol,1:pver,I_CVCICE)) - elsewhere (mr_lsice(1:ncol,1:pver) .gt. 0._r8) - cospstateIN%DeffIce(:,:) = 2._r8 * 1.0e6 * reff_cosp(1:ncol,1:pver,I_LSCICE) - elsewhere (mr_ccice(1:ncol,1:pver) .gt. 0._r8) - cospstateIN%DeffIce(:,:) = 2._r8 * 1.0e6 * reff_cosp(1:ncol,1:pver,I_CVCICE) - end where - - ! RTTOV doesn't consider precip flux, but I think it was used previously. Here for completeness. Could pass in separately for cloud categories. - ! Graupel goes in the snow category, arbitrarily. -! cospstateIN%fl_rain = fl_lsrain(1:ncol,1:pver) + fl_ccrain(1:ncol,1:pver) -! cospstateIN%fl_snow = fl_lssnow(1:ncol,1:pver) + fl_ccsnow(1:ncol,1:pver) + & -! fl_lsgrpl(1:ncol,1:pver) - - ! JKS - this is commented because the cam_in values are not populated - ! 2-meter (ref height) temperature and moisture are optional, so they have to be explicitly allocated if used. -! allocate(cospstateIN%t2m(ncol),cospstateIN%q2m(ncol)) -! cospstateIN%t2m = cam_in%tref(1:ncol) -! cospstateIN%q2m = cam_in%qref(1:ncol) - - - - call t_stopf("construct_cospstateIN") - - if (masterproc) then - if (docosp) then - write(iulog,*)'size(cospstateIN%ch4): ',size(cospstateIN%ch4) - write(iulog,*)'size(cospstateIN%n2o): ',size(cospstateIN%n2o) -! write(iulog,*)'cospstateIN%t2m: ',cospstateIN%t2m -! write(iulog,*)'cospstateIN%q2m: ',cospstateIN%q2m - - write(iulog,*)'cam_in%tref: ',cam_in%tref - write(iulog,*)'cam_in%qref: ',cam_in%qref - write(iulog,*)'cam_in%u10: ',cam_in%u10 - end if - end if - - if (masterproc) then - if (docosp) then - write(iulog,*)'Finished RTTOV construct_cospstateIN section in cospsimulator_intr_run' - end if - end if - - ! Optical inputs - call t_startf("construct_cospIN") - call construct_cospIN(ncol,nscol_cosp,pver,rttov_Ninstruments,cospIN,emis_grey=1.0_r8) ! JKS apply unitary blackbody surface emissivity to be consistent with CESM physics - cospIN%emsfc_lw = emsfc_lw - if (lradar_sim) cospIN%rcfg_cloudsat = rcfg_cs(lchnk) - if (lrttov_sim) cospIN%cfg_rttov => rttov_configs - call t_stopf("construct_cospIN") - - if (masterproc) then - if (docosp) then - write(iulog,*)'Finished RTTOV construct_cospIN section in cospsimulator_intr_run' - end if - end if - - ! *NOTE* Fields passed into subsample_and_optics are ordered from TOA-2-SFC. - if (lradar_sim .or. (llidar_sim .or. (lisccp_sim .or. (lmisr_sim .or. lmodis_sim)))) then ! RTTOV does not use subsample_and_optics - call t_startf("subsample_and_optics") - call subsample_and_optics(ncol,pver,nscol_cosp,nhydro,overlap, & - use_precipitation_fluxes,lidar_ice_type,sd_cs(lchnk),cld(1:ncol,1:pver),& - concld(1:ncol,1:pver),rain_ls_interp(1:ncol,1:pver), & - snow_ls_interp(1:ncol,1:pver),grpl_ls_interp(1:ncol,1:pver), & - rain_cv_interp(1:ncol,1:pver),snow_cv_interp(1:ncol,1:pver), & - mr_lsliq(1:ncol,1:pver),mr_lsice(1:ncol,1:pver), & - mr_ccliq(1:ncol,1:pver),mr_ccice(1:ncol,1:pver), & - reff_cosp(1:ncol,1:pver,:),dtau_c(1:ncol,1:pver), & - dtau_s(1:ncol,1:pver),dem_c(1:ncol,1:pver), & - dem_s(1:ncol,1:pver),dtau_s_snow(1:ncol,1:pver), & - dem_s_snow(1:ncol,1:pver),state%ps(1:ncol),cospstateIN,cospIN) - call t_stopf("subsample_and_optics") - end if - - ! ###################################################################################### - ! Call COSP - ! ###################################################################################### - print*,'pre "COSP_SIMULATOR" ' - print*,'associated(cospOUT % rttov_outputs(1) % refl_total): ',associated(cospOUT % rttov_outputs(1) % refl_total) - print*,'associated(cospOUT % rttov_outputs(1) % refl_clear): ',associated(cospOUT % rttov_outputs(1) % refl_clear) - call t_startf("cosp_simulator") - cosp_status = COSP_SIMULATOR(cospIN, cospstateIN, cospOUT, start_idx=1, stop_idx=ncol,debug=.false.) - -! if (masterproc) then -! if (docosp) then -! write(iulog,*)'ERROR(rttov_simulator): cospIN%Npoints: ',cospIN%Npoints,', cospIN%Nlevels: ',cospIN%Nlevels -! write(iulog,*)'ERROR(rttov_simulator): size(cospstateIN%pfull,2): ',size(cospstateIN%pfull,2) -! write(iulog,*)'ERROR(rttov_simulator): size(cospstateIN%at,2): ',size(cospstateIN%at,2) -! write(iulog,*)'ERROR(rttov_simulator): size(cospstateIN%qv,2): ',size(cospstateIN%qv,2) -! write(iulog,*)'ERROR(rttov_simulator): size(cospstateIN%hgt_matrix_half,2): ',size(cospstateIN%hgt_matrix_half,2) -! write(iulog,*)'ERROR(rttov_simulator): size(cospstateIN%phalf,2): ',size(cospstateIN%phalf,2) -! write(iulog,*)'ERROR(rttov_simulator): cospstateIN%hgt_matrix_half(1,:): ',cospstateIN%hgt_matrix_half(1,:) -! end if -! end if - - ! Check status flags - nerror = 0 - do i = 1, ubound(cosp_status, 1) - if (len_trim(cosp_status(i)) > 0) then - write(iulog,*) "cosp_simulator: ERROR: "//trim(cosp_status(i)) - nerror = nerror + 1 - end if - end do - if (nerror > 0) then - call endrun('cospsimulator_intr_run: error return from cosp_simulator') - end if - call t_stopf("cosp_simulator") - - ! ###################################################################################### - ! Write COSP inputs to output file for offline use. - ! ###################################################################################### - call t_startf("cosp_histfile_aux") - if (cosp_histfile_aux) then - ! 1D outputs - call outfld('PS_COSP', state%ps(1:ncol), ncol,lchnk) - call outfld('TS_COSP', cospstateIN%skt, ncol,lchnk) - - ! 2D outputs - call outfld('P_COSP', cospstateIN%pfull, ncol,lchnk) - call outfld('PH_COSP', cospstateIN%phalf, ncol,lchnk) - call outfld('ZLEV_COSP', cospstateIN%hgt_matrix, ncol,lchnk) - call outfld('ZLEV_HALF_COSP', cospstateIN%hgt_matrix_half, ncol,lchnk) - call outfld('T_COSP', cospstateIN%at, ncol,lchnk) - call outfld('RH_COSP', cospstateIN%qv, ncol,lchnk) - call outfld('Q_COSP', q(1:ncol,1:pver), ncol,lchnk) - - ! 3D outputs, but first compress to 2D - do i=1,ncol - do ihml=1,nhtml_cosp - do isc=1,nscol_cosp - ihsc = (ihml-1)*nscol_cosp+isc - tau067_out(i,ihsc) = cospIN%tau_067(i,isc,ihml) - emis11_out(i,ihsc) = cospIN%emiss_11(i,isc,ihml) - ssa34_out(i,ihsc) = cospIN%ss_alb(i,isc,ihml) - asym34_out(i,ihsc) = cospIN%asym(i,isc,ihml) - fracLiq_out(i,ihsc) = cospIN%fracLiq(i,isc,ihml) - end do - end do - end do - call outfld('TAU_067', tau067_out, pcols,lchnk) - call outfld('EMISS_11', emis11_out, pcols,lchnk) - call outfld('MODIS_asym', asym34_out, pcols,lchnk) - call outfld('MODIS_ssa', ssa34_out, pcols,lchnk) - call outfld('MODIS_fracliq',fracLiq_out,pcols,lchnk) - end if - call t_stopf("cosp_histfile_aux") - - ! ###################################################################################### - ! Set dark-scenes to fill value. Only done for passive simulators and when cosp_runall=F - ! ###################################################################################### - call t_startf("sunlit_passive") - if (.not. cosp_runall) then - ! ISCCP simulator - if (lisccp_sim) then - ! 1D - where(cam_sunlit(1:ncol) .eq. 0) - cospOUT%isccp_totalcldarea(1:ncol) = R_UNDEF - cospOUT%isccp_meanptop(1:ncol) = R_UNDEF - cospOUT%isccp_meantaucld(1:ncol) = R_UNDEF - cospOUT%isccp_meanalbedocld(1:ncol) = R_UNDEF - cospOUT%isccp_meantb(1:ncol) = R_UNDEF - cospOUT%isccp_meantbclr(1:ncol) = R_UNDEF - end where - ! 2D - do i=1,nscol_cosp - where (cam_sunlit(1:ncol) .eq. 0) - cospOUT%isccp_boxtau(1:ncol,i) = R_UNDEF - cospOUT%isccp_boxptop(1:ncol,i) = R_UNDEF - end where - enddo - ! 3D - do i=1,nprs_cosp - do k=1,ntau_cosp - where(cam_sunlit(1:ncol) .eq. 0) - cospOUT%isccp_fq(1:ncol,k,i) = R_UNDEF - end where - end do - end do - endif - - ! MISR simulator - if (lmisr_sim) then - do i=1,nhtmisr_cosp - do k=1,ntau_cosp - where(cam_sunlit(1:ncol) .eq. 0) - cospOUT%misr_fq(1:ncol,k,i) = R_UNDEF - end where - end do - end do - end if - - ! MODIS simulator - if (lmodis_sim) then - ! 1D - where(cam_sunlit(1:ncol) .eq. 0) - cospOUT%modis_Cloud_Fraction_Total_Mean(1:ncol) = R_UNDEF - cospOUT%modis_Cloud_Fraction_Water_Mean(1:ncol) = R_UNDEF - cospOUT%modis_Cloud_Fraction_Ice_Mean(1:ncol) = R_UNDEF - cospOUT%modis_Cloud_Fraction_High_Mean(1:ncol) = R_UNDEF - cospOUT%modis_Cloud_Fraction_Mid_Mean(1:ncol) = R_UNDEF - cospOUT%modis_Cloud_Fraction_Low_Mean(1:ncol) = R_UNDEF - cospOUT%modis_Optical_Thickness_Total_Mean(1:ncol) = R_UNDEF - cospOUT%modis_Optical_Thickness_Water_Mean(1:ncol) = R_UNDEF - cospOUT%modis_Optical_Thickness_Ice_Mean(1:ncol) = R_UNDEF - cospOUT%modis_Optical_Thickness_Total_LogMean(1:ncol) = R_UNDEF - cospOUT%modis_Optical_Thickness_Water_LogMean(1:ncol) = R_UNDEF - cospOUT%modis_Optical_Thickness_Ice_LogMean(1:ncol) = R_UNDEF - cospOUT%modis_Cloud_Particle_Size_Water_Mean(1:ncol) = R_UNDEF - cospOUT%modis_Cloud_Particle_Size_Ice_Mean(1:ncol) = R_UNDEF - cospOUT%modis_Cloud_Top_Pressure_Total_Mean(1:ncol) = R_UNDEF - cospOUT%modis_Liquid_Water_Path_Mean(1:ncol) = R_UNDEF - cospOUT%modis_Ice_Water_Path_Mean(1:ncol) = R_UNDEF - endwhere - ! 3D - do i=1,ntau_cosp_modis - do k=1,nprs_cosp - where(cam_sunlit(1:ncol) .eq. 0) - cospOUT%modis_Optical_Thickness_vs_Cloud_Top_Pressure(1:ncol,i,k) = R_UNDEF - end where - enddo - do k=1,numMODISReffIceBins - where(cam_sunlit(1:ncol) .eq. 0) - cospOUT%modis_Optical_Thickness_vs_ReffICE(1:ncol,i,k) = R_UNDEF - end where - end do - do k=1,numMODISReffLiqBins - where(cam_sunlit(1:ncol) .eq. 0) - cospOUT%modis_Optical_Thickness_vs_ReffLIQ(1:ncol,i,k) = R_UNDEF - end where - enddo - enddo - end if - end if - call t_stopf("sunlit_passive") - - ! ###################################################################################### - ! Copy COSP outputs to CAM fields. - ! ###################################################################################### - call t_startf("output_copying") - if (allocated(cospIN%frac_out)) & - frac_out(1:ncol,1:nscol_cosp,1:nhtml_cosp) = cospIN%frac_out ! frac_out (time,height_mlev,column,profile) - - ! Cloudsat - if (lradar_sim) then - cfad_dbze94(1:ncol,1:CLOUDSAT_DBZE_BINS,1:nht_cosp) = cospOUT%cloudsat_cfad_ze ! cfad_dbze94 (time,height,dbze,profile) - dbze94(1:ncol,1:nscol_cosp,1:nhtml_cosp) = cospOUT%cloudsat_Ze_tot ! dbze94 (time,height_mlev,column,profile) - cldtot_cs(1:ncol) = 0._r8!cospOUT%cloudsat_radar_tcc ! CAM version of cltradar (time,profile) ! NOT COMPUTED IN COSP2 - cldtot_cs2(1:ncol) = 0._r8!cospOUT%cloudsat_radar_tcc2 ! CAM version of cltradar2 (time,profile) ! NOT COMPUTED IN COSP2 - ! *NOTE* These two fields are joint-simulator products, but in CAM they are controlled - ! by the radar simulator control. - cldtot_calcs(1:ncol) = cospOUT%radar_lidar_tcc ! CAM version of cltlidarradar (time,profile) - cld_cal_notcs(1:ncol,1:nht_cosp) = cospOUT%lidar_only_freq_cloud ! CAM version of clcalipso2 (time,height,profile) - - ! Cloudsat near-surface precipitation diagnostics - ptcloudsatflag0(1:ncol) = cospOUT%cloudsat_precip_cover(:,1) - ptcloudsatflag1(1:ncol) = cospOUT%cloudsat_precip_cover(:,2) - ptcloudsatflag2(1:ncol) = cospOUT%cloudsat_precip_cover(:,3) - ptcloudsatflag3(1:ncol) = cospOUT%cloudsat_precip_cover(:,4) - ptcloudsatflag4(1:ncol) = cospOUT%cloudsat_precip_cover(:,5) - ptcloudsatflag5(1:ncol) = cospOUT%cloudsat_precip_cover(:,6) - ptcloudsatflag6(1:ncol) = cospOUT%cloudsat_precip_cover(:,7) - ptcloudsatflag7(1:ncol) = cospOUT%cloudsat_precip_cover(:,8) - ptcloudsatflag8(1:ncol) = cospOUT%cloudsat_precip_cover(:,9) - ptcloudsatflag9(1:ncol) = cospOUT%cloudsat_precip_cover(:,10) - cloudsatpia(1:ncol) = cospOUT%cloudsat_pia - - ! Output the mixing-ratio for all hydrometeor types in Cloudsat near-surface precipitation diagnostics - ! *NOTE* These fields are simply the native CAM mixing-ratios for each hydrometeor type used in the - ! CAM6 microphysics scheme, interpolated to the same vertical grid used by the Cloudsat - ! simulator. These fields are not part of the radar simulator standard output, as these fields - ! are entirely dependent on the host models microphysics, not the retrieval. - - - endif - - ! CALIPSO - if (llidar_sim) then - cldlow_cal(1:ncol) = cospOUT%calipso_cldlayer(:,1) ! CAM version of cllcalipso (time,profile) - cldmed_cal(1:ncol) = cospOUT%calipso_cldlayer(:,2) ! CAM version of clmcalipso (time,profile) - cldhgh_cal(1:ncol) = cospOUT%calipso_cldlayer(:,3) ! CAM version of clhcalipso (time,profile) - cldtot_cal(1:ncol) = cospOUT%calipso_cldlayer(:,4) ! CAM version of cltcalipso (time,profile) - cldlow_cal_ice(1:ncol) = cospOUT%calipso_cldlayerphase(:,1,1) ! CAM version of cllcalipsoice !+cosp1.4 - cldmed_cal_ice(1:ncol) = cospOUT%calipso_cldlayerphase(:,2,1) ! CAM version of clmcalipsoice - cldhgh_cal_ice(1:ncol) = cospOUT%calipso_cldlayerphase(:,3,1) ! CAM version of clhcalipsoice - cldtot_cal_ice(1:ncol) = cospOUT%calipso_cldlayerphase(:,4,1) ! CAM version of cltcalipsoice - cldlow_cal_liq(1:ncol) = cospOUT%calipso_cldlayerphase(:,1,2) ! CAM version of cllcalipsoliq - cldmed_cal_liq(1:ncol) = cospOUT%calipso_cldlayerphase(:,2,2) ! CAM version of clmcalipsoliq - cldhgh_cal_liq(1:ncol) = cospOUT%calipso_cldlayerphase(:,3,2) ! CAM version of clhcalipsoliq - cldtot_cal_liq(1:ncol) = cospOUT%calipso_cldlayerphase(:,4,2) ! CAM version of cltcalipsoliq - cldlow_cal_un(1:ncol) = cospOUT%calipso_cldlayerphase(:,1,3) ! CAM version of cllcalipsoun - cldmed_cal_un(1:ncol) = cospOUT%calipso_cldlayerphase(:,2,3) ! CAM version of clmcalipsoun - cldhgh_cal_un(1:ncol) = cospOUT%calipso_cldlayerphase(:,3,3) ! CAM version of clhcalipsoun - cldtot_cal_un(1:ncol) = cospOUT%calipso_cldlayerphase(:,4,3) ! CAM version of cltcalipsoun, !+cosp1.4 - cld_cal_ice(1:ncol,1:nht_cosp) = cospOUT%calipso_lidarcldphase(:,:,1) ! CAM version of clcalipsoice !+cosp1.4 - cld_cal_liq(1:ncol,1:nht_cosp) = cospOUT%calipso_lidarcldphase(:,:,2) ! CAM version of clcalipsoliq - cld_cal_un(1:ncol,1:nht_cosp) = cospOUT%calipso_lidarcldphase(:,:,3) ! CAM version of clcalipsoun - cld_cal_tmp(1:ncol,1:nht_cosp) = cospOUT%calipso_lidarcldtmp(:,:,1) ! CAM version of clcalipsotmp - cld_cal_tmpliq(1:ncol,1:nht_cosp) = cospOUT%calipso_lidarcldtmp(:,:,2) ! CAM version of clcalipsotmpice - cld_cal_tmpice(1:ncol,1:nht_cosp) = cospOUT%calipso_lidarcldtmp(:,:,3) ! CAM version of clcalipsotmpliq - cld_cal_tmpun(1:ncol,1:nht_cosp) = cospOUT%calipso_lidarcldtmp(:,:,4) ! CAM version of clcalipsotmpun, !+cosp1.4 - cld_cal(1:ncol,1:nht_cosp) = cospOUT%calipso_lidarcld(:,1:nht_cosp) ! CAM version of clcalipso (time,height,profile) - mol532_cal(1:ncol,1:nhtml_cosp) = cospOUT%calipso_beta_mol ! CAM version of beta_mol532 (time,height_mlev,profile) - atb532(1:ncol,1:nscol_cosp,1:nhtml_cosp) = cospOUT%calipso_beta_tot ! atb532 (time,height_mlev,column,profile) - cfad_lidarsr532(1:ncol,1:nsr_cosp,1:nht_cosp) = cospOUT%calipso_cfad_sr(:,:,:) ! cfad_lidarsr532 (time,height,scat_ratio,profile) - ! PARASOL. In COSP2, the Parasol simulator is independent of the calipso simulator. - refl_parasol(1:ncol,1:nsza_cosp) = cospOUT%parasolGrid_refl ! CAM version of parasolrefl (time,sza,profile) - ! CALIPSO Opaque cloud diagnostics -! cldopaq_cal(1:pcols) = cospOUT%calipso_cldtype(:,1) -! cldthin_cal(1:pcols) = cospOUT%calipso_cldtype(:,2) -! cldopaqz_cal(1:pcols) = cospOUT%calipso_cldtype(:,3) -! cldopaq_cal_temp(1:pcols) = cospOUT%calipso_cldtypetemp(:,1) -! cldthin_cal_temp(1:pcols) = cospOUT%calipso_cldtypetemp(:,2) -! cldzopaq_cal_temp(1:pcols) = cospOUT%calipso_cldtypetemp(:,3) -! cldopaq_cal_z(1:pcols) = cospOUT%calipso_cldtypemeanz(:,1) -! cldthin_cal_z(1:pcols) = cospOUT%calipso_cldtypemeanz(:,2) -! cldthin_cal_emis(1:pcols) = cospOUT%calipso_cldthinemis -! cldopaq_cal_se(1:pcols) = cospOUT%calipso_cldtypemeanzse(:,1) -! cldthin_cal_se(1:pcols) = cospOUT%calipso_cldtypemeanzse(:,2) -! cldzopaq_cal_se(1:pcols) = cospOUT%calipso_cldtypemeanzse(:,3) -! cldopaq_cal_2d(1:pcols,1:nht_cosp) = cospOUT%calipso_lidarcldtype(:,:,1) -! cldthin_cal_2d(1:pcols,1:nht_cosp) = cospOUT%calipso_lidarcldtype(:,:,2) -! cldzopaq_cal_2d(1:pcols,1:nht_cosp) = cospOUT%calipso_lidarcldtype(:,:,3) -! opacity_cal_2d(1:pcols,1:nht_cosp) = cospOUT%calipso_lidarcldtype(:,:,4) - endif - - ! ISCCP - if (lisccp_sim) then - clisccp2(1:ncol,1:ntau_cosp,1:nprs_cosp) = cospOUT%isccp_fq ! CAM version of clisccp2 (time,tau,plev,profile) - tau_isccp(1:ncol,1:nscol_cosp) = cospOUT%isccp_boxtau ! CAM version of boxtauisccp (time,column,profile) - cldptop_isccp(1:ncol,1:nscol_cosp) = cospOUT%isccp_boxptop ! CAM version of boxptopisccp (time,column,profile) - cldtot_isccp(1:ncol) = cospOUT%isccp_totalcldarea ! CAM version of tclisccp (time, profile) - meanptop_isccp(1:ncol) = cospOUT%isccp_meanptop ! CAM version of ctpisccp (time, profile) - meantau_isccp(1:ncol) = cospOUT%isccp_meantaucld ! CAM version of meantbisccp (time, profile) - meancldalb_isccp(1:ncol) = cospOUT%isccp_meanalbedocld ! CAM version of albisccp (time, profile) - meantb_isccp(1:ncol) = cospOUT%isccp_meantb ! CAM version of meantbisccp (time, profile) - meantbclr_isccp(1:ncol) = cospOUT%isccp_meantbclr ! CAM version of meantbclrisccp (time, profile) - endif - - ! MISR - if (lmisr_sim) then - clMISR(1:ncol,1:ntau_cosp,1:nhtmisr_cosp) = cospOUT%misr_fq ! CAM version of clMISR (time,tau,CTH_height_bin,profile) - endif - - ! MODIS - if (lmodis_sim) then - cltmodis(1:ncol) = cospOUT%modis_Cloud_Fraction_Total_Mean - clwmodis(1:ncol) = cospOUT%modis_Cloud_Fraction_Water_Mean - climodis(1:ncol) = cospOUT%modis_Cloud_Fraction_Ice_Mean - clhmodis(1:ncol) = cospOUT%modis_Cloud_Fraction_High_Mean - clmmodis(1:ncol) = cospOUT%modis_Cloud_Fraction_Mid_Mean - cllmodis(1:ncol) = cospOUT%modis_Cloud_Fraction_Low_Mean - tautmodis(1:ncol) = cospOUT%modis_Optical_Thickness_Total_Mean - tauwmodis(1:ncol) = cospOUT%modis_Optical_Thickness_Water_Mean - tauimodis(1:ncol) = cospOUT%modis_Optical_Thickness_Ice_Mean - tautlogmodis(1:ncol) = cospOUT%modis_Optical_Thickness_Total_LogMean - tauwlogmodis(1:ncol) = cospOUT%modis_Optical_Thickness_Water_LogMean - tauilogmodis(1:ncol) = cospOUT%modis_Optical_Thickness_Ice_LogMean - reffclwmodis(1:ncol) = cospOUT%modis_Cloud_Particle_Size_Water_Mean - reffclimodis(1:ncol) = cospOUT%modis_Cloud_Particle_Size_Ice_Mean - pctmodis(1:ncol) = cospOUT%modis_Cloud_Top_Pressure_Total_Mean - lwpmodis(1:ncol) = cospOUT%modis_Liquid_Water_Path_Mean - iwpmodis(1:ncol) = cospOUT%modis_Ice_Water_Path_Mean - clmodis(1:ncol,1:ntau_cosp_modis,1:nprs_cosp) = cospOUT%modis_Optical_Thickness_vs_Cloud_Top_Pressure - clrimodis(1:ncol,1:ntau_cosp_modis,1:numMODISReffIceBins) = cospOUT%modis_Optical_Thickness_vs_ReffICE - clrlmodis(1:ncol,1:ntau_cosp_modis,1:numMODISReffLiqBins) = cospOUT%modis_Optical_Thickness_vs_ReffLIQ - endif - - if (masterproc) then - if (docosp) then - write(iulog,*)'Reached writing RTTOV section in cospsimulator_intr_run' - write(iulog,*)'lrttov_sim: ', lrttov_sim - end if - end if - - ! RTTOV - if (lrttov_sim) then - do i=1,rttov_Ninstruments ! Not sure if this logical stuff is needed or not? - if (rttov_configs(i) % Lrttov_pc) then - if (rttov_configs(i) % Lrttov_bt) then - rttov_outputs_cp(i) % bt_total_pc(1:ncol,1:rttov_outputs_cp(i) % nchan_out) = cospOUT % rttov_outputs(i) % bt_total_pc - end if - if (rttov_configs(i) % Lrttov_rad) then - rttov_outputs_cp(i) % rad_total_pc(1:ncol,1:rttov_outputs_cp(i) % nchan_out) = cospOUT % rttov_outputs(i) % rad_total_pc - end if - else - if (rttov_configs(i) % Lrttov_bt) then - rttov_outputs_cp(i) % bt_total(1:ncol,1:rttov_outputs_cp(i) % nchan_out) = cospOUT % rttov_outputs(i) % bt_total - if ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer)) then - rttov_outputs_cp(i) % bt_clear(1:ncol,1:rttov_outputs_cp(i) % nchan_out) = cospOUT % rttov_outputs(i) % bt_clear - end if - end if - if (rttov_configs(i) % Lrttov_rad) then - rttov_outputs_cp(i) % rad_total(1:ncol,1:rttov_outputs_cp(i) % nchan_out) = cospOUT % rttov_outputs(i) % rad_total - if ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer)) then - rttov_outputs_cp(i) % rad_clear(1:ncol,1:rttov_outputs_cp(i) % nchan_out) = cospOUT % rttov_outputs(i) % rad_clear - rttov_outputs_cp(i) % rad_cloudy(1:ncol,1:rttov_outputs_cp(i) % nchan_out) = cospOUT % rttov_outputs(i) % rad_cloudy - end if - end if - if (rttov_configs(i) % Lrttov_refl) then - rttov_outputs_cp(i) % refl_total(1:ncol,1:rttov_outputs_cp(i) % nchan_out) = cospOUT % rttov_outputs(i) % refl_total - if ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer)) then - rttov_outputs_cp(i) % refl_clear(1:ncol,1:rttov_outputs_cp(i) % nchan_out) = cospOUT % rttov_outputs(i) % refl_clear - end if - end if - end if - end do - endif - - if (masterproc) then - if (docosp) then - write(iulog,*)'Finished writing RTTOV section in cospsimulator_intr_run' - write(iulog,*)'lrttov_sim: ', lrttov_sim - end if - end if - - ! Use high-dimensional output to populate CAM collapsed output variables - ! see above for mixed dimension definitions - ! i am using the convention of starting vertical coordinates at the surface, up to down, COSP convention, not CAM. - do i=1,ncol - if (lradar_sim) then - ! CAM cfad_dbze94 (time,height,dbze,profile) - do ih=1,nht_cosp - do id=1,CLOUDSAT_DBZE_BINS - ihd=(ih-1)*CLOUDSAT_DBZE_BINS+id - cfad_dbze94_cs(i,ihd) = cfad_dbze94(i,id,ih) ! cfad_dbze94_cs(pcols,nht_cosp*CLOUDSAT_DBZE_BINS) - end do - end do - ! CAM dbze94 (time,height_mlev,column,profile) - do ihml=1,nhtml_cosp - do isc=1,nscol_cosp - ihsc=(ihml-1)*nscol_cosp+isc - dbze_cs(i,ihsc) = dbze94(i,isc,ihml) ! dbze_cs(pcols,pver*nscol_cosp) - end do - end do - endif - - if (llidar_sim) then - ! CAM cfad_lidarsr532 (time,height,scat_ratio,profile) - do ih=1,nht_cosp - do is=1,nsr_cosp - ihs=(ih-1)*nsr_cosp+is - cfad_sr532_cal(i,ihs) = cfad_lidarsr532(i,is,ih) ! cfad_sr532_cal(pcols,nht_cosp*nsr_cosp) - end do - end do - ! CAM atb532 (time,height_mlev,column,profile) FIX - do ihml=1,nhtml_cosp - do isc=1,nscol_cosp - ihsc=(ihml-1)*nscol_cosp+isc - atb532_cal(i,ihsc) = atb532(i,isc,ihml) ! atb532_cal(pcols,nht_cosp*nscol_cosp) - end do - end do - endif - - if (lmisr_sim) then - ! CAM clMISR (time,tau,CTH_height_bin,profile) - do ihm=1,nhtmisr_cosp - do it=1,ntau_cosp - ihmt=(ihm-1)*ntau_cosp+it - cld_misr(i,ihmt) = clMISR(i,it,ihm) - end do - end do - endif - - if (lmodis_sim) then - ! CAM clmodis - do ip=1,nprs_cosp - do it=1,ntau_cosp_modis - ipt=(ip-1)*ntau_cosp_modis+it - clmodis_cam(i,ipt) = clmodis(i,it,ip) - end do - end do - ! CAM clrimodis - do ip=1,numMODISReffIceBins - do it=1,ntau_cosp_modis - ipt=(ip-1)*ntau_cosp_modis+it - clrimodis_cam(i,ipt) = clrimodis(i,it,ip) - end do - end do - ! CAM clrlmodis - do ip=1,numMODISReffLiqBins - do it=1,ntau_cosp_modis - ipt=(ip-1)*ntau_cosp_modis+it - clrlmodis_cam(i,ipt) = clrlmodis(i,it,ip) - end do - end do - endif - - ! Subcolums - do ihml=1,nhtml_cosp - do isc=1,nscol_cosp - ihsc=(ihml-1)*nscol_cosp+isc - scops_out(i,ihsc) = frac_out(i,isc,ihml) ! scops_out(pcols,nht_cosp*nscol_cosp) - end do - end do - end do - call t_stopf("output_copying") - - ! ###################################################################################### - ! Clean up - ! ###################################################################################### - -! call t_startf("rttov_cleanup") -! call rttov_cleanup(cospIN) ! Just break things to get diagnostics. Not really code. - JKS -! call t_stopf("rttov_cleanup") - call t_startf("destroy_cospIN") - call destroy_cospIN(cospIN) - call t_stopf("destroy_cospIN") - call t_startf("destroy_cospstateIN") - call destroy_cospstateIN(cospstateIN) - call t_stopf("destroy_cospstateIN") - call t_startf("destroy_cospOUT") - call destroy_cosp_outputs(cospOUT) - call t_stopf("destroy_cospOUT") - - ! ###################################################################################### - ! OUTPUT - ! ###################################################################################### - call t_startf("writing_output") - ! ISCCP OUTPUTS - if (lisccp_sim) then - call outfld('FISCCP1_COSP',clisccp2, pcols,lchnk) - call outfld('CLDTOT_ISCCP',cldtot_isccp, pcols,lchnk) - !! weight meancldalb_isccp by the cloud fraction - !! where there is no isccp cloud fraction, set meancldalb_isccp = R_UNDEF - !! weight meanptop_isccp by the cloud fraction - !! where there is no isccp cloud fraction, set meanptop_isccp = R_UNDEF - !! weight meantau_isccp by the cloud fraction - !! where there is no isccp cloud fraction, set meantau_isccp = R_UNDEF - where (cldtot_isccp(:ncol) .eq. R_UNDEF) - meancldalb_isccp(:ncol) = R_UNDEF - meanptop_isccp(:ncol) = R_UNDEF - meantau_isccp(:ncol) = R_UNDEF - elsewhere - meancldalb_isccp(:ncol) = meancldalb_isccp(:ncol)*cldtot_isccp(:ncol) - meanptop_isccp(:ncol) = meanptop_isccp(:ncol)*cldtot_isccp(:ncol) - meantau_isccp(:ncol) = meantau_isccp(:ncol)*cldtot_isccp(:ncol) - end where - call outfld('MEANCLDALB_ISCCP',meancldalb_isccp,pcols,lchnk) - call outfld('MEANPTOP_ISCCP', meanptop_isccp, pcols,lchnk) - call outfld('MEANTAU_ISCCP', meantau_isccp, pcols,lchnk) - call outfld('MEANTB_ISCCP', meantb_isccp, pcols,lchnk) - call outfld('MEANTBCLR_ISCCP', meantbclr_isccp, pcols,lchnk) - end if - - ! CALIPSO SIMULATOR OUTPUTS - if (llidar_sim) then - call outfld('CLDLOW_CAL', cldlow_cal, pcols,lchnk) - call outfld('CLDMED_CAL', cldmed_cal, pcols,lchnk) - call outfld('CLDHGH_CAL', cldhgh_cal, pcols,lchnk) - call outfld('CLDTOT_CAL', cldtot_cal, pcols,lchnk) - call outfld('CLDTOT_CAL_ICE',cldtot_cal_ice, pcols,lchnk) !+1.4 - call outfld('CLDTOT_CAL_LIQ',cldtot_cal_liq, pcols,lchnk) - call outfld('CLDTOT_CAL_UN', cldtot_cal_un, pcols,lchnk) - call outfld('CLDHGH_CAL_ICE',cldhgh_cal_ice, pcols,lchnk) - call outfld('CLDHGH_CAL_LIQ',cldhgh_cal_liq, pcols,lchnk) - call outfld('CLDHGH_CAL_UN', cldhgh_cal_un, pcols,lchnk) - call outfld('CLDMED_CAL_ICE',cldmed_cal_ice, pcols,lchnk) - call outfld('CLDMED_CAL_LIQ',cldmed_cal_liq, pcols,lchnk) - call outfld('CLDMED_CAL_UN', cldmed_cal_un, pcols,lchnk) - call outfld('CLDLOW_CAL_ICE',cldlow_cal_ice, pcols,lchnk) - call outfld('CLDLOW_CAL_LIQ',cldlow_cal_liq, pcols,lchnk) - call outfld('CLDLOW_CAL_UN', cldlow_cal_un, pcols,lchnk) !+1.4 - where (cld_cal(:ncol,:nht_cosp) .eq. R_UNDEF) - !! setting missing values to 0 (clear air). - !! I'm not sure why COSP produces a mix of R_UNDEF and realvalue in the nht_cosp dimension. - cld_cal(:ncol,:nht_cosp) = 0.0_r8 - end where - call outfld('CLD_CAL', cld_cal, pcols,lchnk) !! fails check_accum if 'A' - call outfld('MOL532_CAL', mol532_cal, pcols,lchnk) - - where (cfad_sr532_cal(:ncol,:nht_cosp*nsr_cosp) .eq. R_UNDEF) - !! fails check_accum if this is set... with ht_cosp set relative to sea level, mix of R_UNDEF and realvalue - !! cfad_sr532_cal(:ncol,:nht_cosp*nsr_cosp) = R_UNDEF - cfad_sr532_cal(:ncol,:nht_cosp*nsr_cosp) = 0.0_r8 - end where - call outfld('CFAD_SR532_CAL',cfad_sr532_cal ,pcols,lchnk) - - where (refl_parasol(:ncol,:nsza_cosp) .eq. R_UNDEF) - !! setting missing values to 0 (clear air). - refl_parasol(:ncol,:nsza_cosp) = 0 - end where - call outfld('RFL_PARASOL',refl_parasol ,pcols,lchnk) !! - - where (cld_cal_liq(:ncol,:nht_cosp) .eq. R_UNDEF) !+cosp1.4 - !! setting missing values to 0 (clear air), likely below sea level - cld_cal_liq(:ncol,:nht_cosp) = 0.0_r8 - end where - call outfld('CLD_CAL_LIQ',cld_cal_liq ,pcols,lchnk) !! - - where (cld_cal_ice(:ncol,:nht_cosp) .eq. R_UNDEF) - !! setting missing values to 0 (clear air), likely below sea level - cld_cal_ice(:ncol,:nht_cosp) = 0.0_r8 - end where - call outfld('CLD_CAL_ICE',cld_cal_ice ,pcols,lchnk) !! - - where (cld_cal_un(:ncol,:nht_cosp) .eq. R_UNDEF) - !! setting missing values to 0 (clear air), likely below sea level - cld_cal_un(:ncol,:nht_cosp) = 0.0_r8 - end where - call outfld('CLD_CAL_UN',cld_cal_un ,pcols,lchnk) !! - - where (cld_cal_tmp(:ncol,:nht_cosp) .eq. R_UNDEF) - !! setting missing values to 0 (clear air), likely below sea level - cld_cal_tmp(:ncol,:nht_cosp) = 0.0_r8 - end where - call outfld('CLD_CAL_TMP',cld_cal_tmp ,pcols,lchnk) !! - - where (cld_cal_tmpliq(:ncol,:nht_cosp) .eq. R_UNDEF) - !! setting missing values to 0 (clear air), likely below sea level - cld_cal_tmpliq(:ncol,:nht_cosp) = 0.0_r8 - end where - call outfld('CLD_CAL_TMPLIQ',cld_cal_tmpliq ,pcols,lchnk) !! - - where (cld_cal_tmpice(:ncol,:nht_cosp) .eq. R_UNDEF) - !! setting missing values to 0 (clear air), likely below sea level - cld_cal_tmpice(:ncol,:nht_cosp) = 0.0_r8 - end where - call outfld('CLD_CAL_TMPICE',cld_cal_tmpice ,pcols,lchnk) !! - - where (cld_cal_tmpun(:ncol,:nht_cosp) .eq. R_UNDEF) - !! setting missing values to 0 (clear air), likely below sea level - cld_cal_tmpun(:ncol,:nht_cosp) = 0.0_r8 - end where - call outfld('CLD_CAL_TMPUN',cld_cal_tmpun ,pcols,lchnk) !! !+cosp1.4 - - ! Opaque cloud diagnostics -! call outfld('CLDOPQ_CAL', cldopaq_cal, pcols, lchnk) -! call outfld('CLDTHN_CAL', cldthin_cal, pcols, lchnk) -! call outfld('CLDZOPQ_CAL', cldopaqz_cal, pcols, lchnk) -! call outfld('CLDOPQ_CAL_TMP', cldopaq_cal_temp, pcols, lchnk) -! call outfld('CLDTHN_CAL_TMP', cldthin_cal_temp, pcols, lchnk) -! call outfld('CLDZOPQ_CAL_TMP', cldzopaq_cal_temp, pcols, lchnk) -! call outfld('CLDOPQ_CAL_Z', cldopaq_cal_z, pcols, lchnk) -! call outfld('CLDTHN_CAL_Z', cldthin_cal_z, pcols, lchnk) -! call outfld('CLDTHN_CAL_EMIS', cldthin_cal_emis, pcols, lchnk) -! call outfld('CLDOPQ_CAL_SE', cldopaq_cal_se, pcols, lchnk) -! call outfld('CLDTHN_CAL_SE', cldthin_cal_se, pcols, lchnk) -! call outfld('CLDZOPQ_CAL_SE', cldzopaq_cal_se, pcols, lchnk) -! ! -! where (cldopaq_cal_2d(:ncol,:nht_cosp) .eq. R_UNDEF) -! cldopaq_cal_2d(:ncol,:nht_cosp) = 0.0_r8 -! end where -! call outfld('CLDOPQ_CAL_2D', cldopaq_cal_2d, pcols, lchnk) -! ! -! where (cldthin_cal_2d(:ncol,:nht_cosp) .eq. R_UNDEF) -! cldthin_cal_2d(:ncol,:nht_cosp) = 0.0_r8 -! end where -! call outfld('CLDTHN_CAL_2D', cldthin_cal_2d, pcols, lchnk) -! ! -! where (cldzopaq_cal_2d(:ncol,:nht_cosp) .eq. R_UNDEF) -! cldzopaq_cal_2d(:ncol,:nht_cosp) = 0.0_r8 -! end where -! call outfld('CLDZOPQ_CAL_2D', cldzopaq_cal_2d, pcols, lchnk) -! ! -! where (opacity_cal_2d(:ncol,:nht_cosp) .eq. R_UNDEF) -! opacity_cal_2d(:ncol,:nht_cosp) = 0.0_r8 -! end where -! call outfld('OPACITY_CAL_2D', opacity_cal_2d, pcols, lchnk) - - end if - - ! RADAR SIMULATOR OUTPUTS - if (lradar_sim) then - where (cfad_dbze94_cs(:ncol,:nht_cosp*CLOUDSAT_DBZE_BINS) .eq. R_UNDEF) - !! fails check_accum if this is set... with ht_cosp set relative to sea level, mix of R_UNDEF and realvalue - ! cfad_dbze94_cs(:ncol,:nht_cosp*CLOUDSAT_DBZE_BINS) = R_UNDEF - cfad_dbze94_cs(:ncol,:nht_cosp*CLOUDSAT_DBZE_BINS) = 0.0_r8 - end where - call outfld('CFAD_DBZE94_CS',cfad_dbze94_cs, pcols, lchnk) - call outfld('CLDTOT_CALCS', cldtot_calcs, pcols, lchnk) - call outfld('CLDTOT_CS', cldtot_cs, pcols, lchnk) - call outfld('CLDTOT_CS2', cldtot_cs2, pcols, lchnk) - call outfld('CLD_CAL_NOTCS', cld_cal_notcs, pcols, lchnk) - call outfld('CS_NOPRECIP', ptcloudsatflag0, pcols, lchnk) - call outfld('CS_RAINPOSS', ptcloudsatflag1, pcols, lchnk) - call outfld('CS_RAINPROB', ptcloudsatflag2, pcols, lchnk) - call outfld('CS_RAINCERT', ptcloudsatflag3, pcols, lchnk) - call outfld('CS_SNOWPOSS', ptcloudsatflag4, pcols, lchnk) - call outfld('CS_SNOWCERT', ptcloudsatflag5, pcols, lchnk) - call outfld('CS_MIXPOSS', ptcloudsatflag6, pcols, lchnk) - call outfld('CS_MIXCERT', ptcloudsatflag7, pcols, lchnk) - call outfld('CS_RAINHARD', ptcloudsatflag8, pcols, lchnk) - call outfld('CS_UN', ptcloudsatflag9, pcols, lchnk) - call outfld('CS_PIA', cloudsatpia, pcols, lchnk) - end if - - ! MISR SIMULATOR OUTPUTS - if (lmisr_sim) then - call outfld('CLD_MISR',cld_misr ,pcols,lchnk) - end if - - ! MODIS SIMULATOR OUTPUTS - if (lmodis_sim) then - call outfld('CLTMODIS',cltmodis ,pcols,lchnk) - call outfld('CLWMODIS',clwmodis ,pcols,lchnk) - call outfld('CLIMODIS',climodis ,pcols,lchnk) - call outfld('CLHMODIS',clhmodis ,pcols,lchnk) - call outfld('CLMMODIS',clmmodis ,pcols,lchnk) - call outfld('CLLMODIS',cllmodis ,pcols,lchnk) - - !! where there is no cloud fraction or no retrieval, set to R_UNDEF, - !! otherwise weight retrieval by cloud fraction - where ((cltmodis(:ncol) .eq. R_UNDEF) .or. (tautmodis(:ncol) .eq. R_UNDEF)) - tautmodis(:ncol) = R_UNDEF - elsewhere - !! weight by the cloud fraction cltmodis - tautmodis(:ncol) = tautmodis(:ncol)*cltmodis(:ncol) - end where - call outfld('TAUTMODIS',tautmodis ,pcols,lchnk) - - where ((tauwmodis(:ncol) .eq. R_UNDEF) .or. (clwmodis(:ncol) .eq. R_UNDEF)) - tauwmodis(:ncol) = R_UNDEF - elsewhere - !! weight by the cloud fraction clwmodis - tauwmodis(:ncol) = tauwmodis(:ncol)*clwmodis(:ncol) - end where - call outfld('TAUWMODIS',tauwmodis ,pcols,lchnk) - - where ((tauimodis(:ncol) .eq. R_UNDEF) .or. (climodis(:ncol) .eq. R_UNDEF)) - tauimodis(:ncol) = R_UNDEF - elsewhere - !! weight by the cloud fraction climodis - tauimodis(:ncol) = tauimodis(:ncol)*climodis(:ncol) - end where - call outfld('TAUIMODIS',tauimodis ,pcols,lchnk) - - where ((tautlogmodis(:ncol) .eq. R_UNDEF) .or. (cltmodis(:ncol) .eq. R_UNDEF)) - tautlogmodis(:ncol) = R_UNDEF - elsewhere - !! weight by the cloud fraction cltmodis - tautlogmodis(:ncol) = tautlogmodis(:ncol)*cltmodis(:ncol) - end where - call outfld('TAUTLOGMODIS',tautlogmodis ,pcols,lchnk) - - where ((tauwlogmodis(:ncol) .eq. R_UNDEF) .or. (clwmodis(:ncol) .eq. R_UNDEF)) - tauwlogmodis(:ncol) = R_UNDEF - elsewhere - !! weight by the cloud fraction clwmodis - tauwlogmodis(:ncol) = tauwlogmodis(:ncol)*clwmodis(:ncol) - end where - call outfld('TAUWLOGMODIS',tauwlogmodis ,pcols,lchnk) - - where ((tauilogmodis(:ncol) .eq. R_UNDEF) .or. (climodis(:ncol) .eq. R_UNDEF)) - tauilogmodis(:ncol) = R_UNDEF - elsewhere - !! weight by the cloud fraction climodis - tauilogmodis(:ncol) = tauilogmodis(:ncol)*climodis(:ncol) - end where - call outfld('TAUILOGMODIS',tauilogmodis ,pcols,lchnk) - - where ((reffclwmodis(:ncol) .eq. R_UNDEF) .or. (clwmodis(:ncol) .eq. R_UNDEF)) - reffclwmodis(:ncol) = R_UNDEF - elsewhere - !! weight by the cloud fraction clwmodis - reffclwmodis(:ncol) = reffclwmodis(:ncol)*clwmodis(:ncol) - end where - call outfld('REFFCLWMODIS',reffclwmodis ,pcols,lchnk) - - where ((reffclimodis(:ncol) .eq. R_UNDEF) .or. (climodis(:ncol) .eq. R_UNDEF)) - reffclimodis(:ncol) = R_UNDEF - elsewhere - !! weight by the cloud fraction climodis - reffclimodis(:ncol) = reffclimodis(:ncol)*climodis(:ncol) - end where - call outfld('REFFCLIMODIS',reffclimodis ,pcols,lchnk) - - where ((pctmodis(:ncol) .eq. R_UNDEF) .or. ( cltmodis(:ncol) .eq. R_UNDEF)) - pctmodis(:ncol) = R_UNDEF - elsewhere - !! weight by the cloud fraction cltmodis - pctmodis(:ncol) = pctmodis(:ncol)*cltmodis(:ncol) - end where - call outfld('PCTMODIS',pctmodis ,pcols,lchnk) - - where ((lwpmodis(:ncol) .eq. R_UNDEF) .or. (clwmodis(:ncol) .eq. R_UNDEF)) - lwpmodis(:ncol) = R_UNDEF - elsewhere - !! weight by the cloud fraction clwmodis - lwpmodis(:ncol) = lwpmodis(:ncol)*clwmodis(:ncol) - end where - call outfld('LWPMODIS',lwpmodis ,pcols,lchnk) - - where ((iwpmodis(:ncol) .eq. R_UNDEF) .or. (climodis(:ncol) .eq. R_UNDEF)) - iwpmodis(:ncol) = R_UNDEF - elsewhere - !! weight by the cloud fraction climodis - iwpmodis(:ncol) = iwpmodis(:ncol)*climodis(:ncol) - end where - call outfld('IWPMODIS',iwpmodis ,pcols,lchnk) - - call outfld('CLMODIS',clmodis_cam ,pcols,lchnk) - call outfld('CLRIMODIS',clrimodis_cam ,pcols,lchnk) - call outfld('CLRLMODIS',clrlmodis_cam ,pcols,lchnk) - end if - - if (masterproc) then - if (docosp) then - write(iulog,*)'Reached outfld RTTOV section in cospsimulator_intr_run' - write(iulog,*)'lrttov_sim: ', lrttov_sim - end if - end if - - ! RTTOV - if (lrttov_sim) then - do i=1,rttov_Ninstruments - write (i_str,fmt) i ! converting integer to string i_str using a 'internal file' - if (rttov_configs(i) % Lrttov_pc) then - if (rttov_configs(i) % Lrttov_bt) then - call outfld("rttov_btpc_clr_inst"//trim(i_str),rttov_outputs_cp(i) % bt_total_pc,pcols,lchnk) - end if - if (rttov_configs(i) % Lrttov_rad) then - call outfld("rttov_radpc_clr_inst"//trim(i_str),rttov_outputs_cp(i) % rad_total_pc,pcols,lchnk) - end if - else - if (rttov_configs(i) % Lrttov_bt) then - call outfld("rttov_bt_total_inst"//trim(i_str),rttov_outputs_cp(i) % bt_total,pcols,lchnk) - if ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer)) then - call outfld("rttov_bt_clear_inst"//trim(i_str),rttov_outputs_cp(i) % bt_clear,pcols,lchnk) - end if - end if - if (rttov_configs(i) % Lrttov_rad) then - call outfld("rttov_rad_total_inst"//trim(i_str),rttov_outputs_cp(i) % rad_total,pcols,lchnk) - if ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer)) then - call outfld("rttov_rad_clear_inst"//trim(i_str),rttov_outputs_cp(i) % rad_clear,pcols,lchnk) - call outfld("rttov_rad_cloudy_inst"//trim(i_str),rttov_outputs_cp(i) % rad_cloudy,pcols,lchnk) - end if - end if - if (rttov_configs(i) % Lrttov_refl) then - call outfld("rttov_refl_total_inst"//trim(i_str),rttov_outputs_cp(i) % refl_total,pcols,lchnk) - if ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer)) then - call outfld("rttov_refl_clear_inst"//trim(i_str),rttov_outputs_cp(i) % refl_clear,pcols,lchnk) - end if - end if - end if - end do - endif - - ! Deallocate the DDT for the RTTOV outputs - do i=1,rttov_Ninstruments - if (allocated(rttov_outputs_cp(i) % bt_total)) deallocate(rttov_outputs_cp(i) % bt_total) - if (allocated(rttov_outputs_cp(i) % bt_clear)) deallocate(rttov_outputs_cp(i) % bt_clear) - if (allocated(rttov_outputs_cp(i) % rad_total)) deallocate(rttov_outputs_cp(i) % rad_total) - if (allocated(rttov_outputs_cp(i) % rad_clear)) deallocate(rttov_outputs_cp(i) % rad_clear) - if (allocated(rttov_outputs_cp(i) % rad_cloudy)) deallocate(rttov_outputs_cp(i) % rad_cloudy) - if (allocated(rttov_outputs_cp(i) % refl_total)) deallocate(rttov_outputs_cp(i) % refl_total) - if (allocated(rttov_outputs_cp(i) % refl_clear)) deallocate(rttov_outputs_cp(i) % refl_clear) - if (allocated(rttov_outputs_cp(i) % bt_total_pc)) deallocate(rttov_outputs_cp(i) % bt_total_pc) - if (allocated(rttov_outputs_cp(i) % rad_total_pc)) deallocate(rttov_outputs_cp(i) % rad_total_pc) - end do - - if (masterproc) then - if (docosp) then - write(iulog,*)'Finished outfld RTTOV section in cospsimulator_intr_run' - write(iulog,*)'lrttov_sim: ', lrttov_sim - end if - end if - - ! SUB-COLUMN OUTPUT - if (lfrac_out) then - call outfld('SCOPS_OUT',scops_out ,pcols,lchnk)!!!-1.00000E+30 !! fails check_accum if 'A' - if (lisccp_sim) then - call outfld('TAU_ISCCP', tau_isccp, pcols,lchnk) !! fails check_accum if 'A' - call outfld('CLDPTOP_ISCCP',cldptop_isccp,pcols,lchnk) !! fails check_accum if 'A' - end if - if (llidar_sim) then - call outfld('ATB532_CAL',atb532_cal,pcols,lchnk) !! fails check_accum if 'A' - end if - if (lradar_sim) then - call outfld('DBZE_CS',dbze_cs,pcols,lchnk) !! fails check_accum if 'A' - end if - end if - call t_stopf("writing_output") -#endif - end subroutine cospsimulator_intr_run - -#ifdef USE_COSP - ! ###################################################################################### - ! SUBROUTINE subsample_and_optics - ! ###################################################################################### - subroutine subsample_and_optics(nPoints, nLevels, nColumns, nHydro,overlap, & - use_precipitation_fluxes, lidar_ice_type, sd, tca, cca,& - fl_lsrainIN, fl_lssnowIN, fl_lsgrplIN, fl_ccrainIN, & - fl_ccsnowIN, mr_lsliq, mr_lsice, mr_ccliq, mr_ccice, & - reffIN, dtau_c, dtau_s, dem_c, dem_s, dtau_s_snow, & - dem_s_snow, sfcP, cospstateIN, cospIN) - ! Dependencies - use cosp_kinds, only: wp - use mod_rng, only: rng_state, init_rng - use mod_cosp_config, only: R_UNDEF - use mod_scops, only: scops - use mod_prec_scops, only: prec_scops - use mod_cosp_utils, only: cosp_precip_mxratio - use mod_quickbeam_optics, only: quickbeam_optics, gases - use cosp_optics, only: cosp_simulator_optics,lidar_optics,modis_optics, & - modis_optics_partition - use mod_cosp_config, only: Nlvgrid, vgrid_zl, vgrid_zu - use mod_cosp_stats, only: cosp_change_vertical_grid - ! Inputs - logical,intent(in) :: & - use_precipitation_fluxes - integer,intent(in) :: & - nPoints, & ! Number of gridpoints - nLevels, & ! Number of vertical levels - nColumns, & ! Number of subcolumns - nHydro, & ! Number pf hydrometeor types - overlap, & ! Overlap assumption (1/2/3) - lidar_ice_type ! Ice type assumption used by lidar optics - real(wp),intent(in),dimension(nPoints,nLevels) :: & - tca, & ! Total cloud amount (0-1) - cca, & ! Convective cloud amount (0-1) - mr_lsliq, & ! Mixing ratio (kg/kg) - mr_lsice, & ! Mixing ratio (kg/kg) - mr_ccliq, & ! Mixing ratio (kg/kg) - mr_ccice, & ! Mixing ratio (kg/kg) - dtau_c, & ! 0.67-micron optical depth (convective) - dtau_s, & ! 0.67-micron optical depth (stratiform) - dem_c, & ! 11-micron emissivity (convective) - dem_s, & ! 11-micron emissivity (stratiform) - fl_lsrainIN, & ! Precipitation flux - fl_lssnowIN, & ! Precipitation flux - fl_lsgrplIN, & ! Precipitation flux - fl_ccrainIN, & ! Precipitation flux - fl_ccsnowIN ! Precipitation flux - real(wp),intent(inout),dimension(nPoints,nLevels) :: & - dtau_s_snow, & ! 0.67-micron optical depth (snow) - dem_s_snow ! 11-micron emissivity (snow) - real(wp),intent(in),dimension(nPoints,nLevels,nHydro) :: & - reffIN ! - real(wp),intent(in),dimension(nPoints) :: & - sfcP ! Surface pressure - type(size_distribution),intent(inout) :: & - sd - - ! Outputs - type(cosp_optical_inputs),intent(inout) :: cospIN - type(cosp_column_inputs),intent(inout) :: cospstateIN - - ! Local variables - integer :: i,j,k - real(wp),dimension(nPoints,nLevels) :: column_frac_out,column_prec_out, & - fl_lsrain,fl_lssnow,fl_lsgrpl,fl_ccrain, & - fl_ccsnow - real(wp),dimension(nPoints,nLevels,nHydro) :: ReffTemp - type(rng_state),allocatable,dimension(:) :: rngs ! Seeds for random number generator - integer,dimension(:),allocatable :: seed - real(wp),dimension(:,:),allocatable :: ls_p_rate,cv_p_rate,frac_ls,frac_cv, & - prec_ls,prec_cv,g_vol - real(wp),dimension(:,:,:), allocatable :: frac_prec,& - MODIS_cloudWater,MODIS_cloudIce, & - MODIS_watersize,MODIS_iceSize, & - MODIS_snowSize,MODIS_cloudSnow, & - MODIS_opticalThicknessLiq, & - MODIS_opticalThicknessSnow, & - MODIS_opticalThicknessIce, & - fracPrecipIce, fracPrecipIce_statGrid - real(wp),dimension(:,:,:,:),allocatable :: mr_hydro,Reff,Np - - call t_startf("scops") - if (Ncolumns .gt. 1) then - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Generate subcolumns for clouds (SCOPS) and precipitation type (PREC_SCOPS) - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! RNG used for subcolumn generation - allocate(rngs(nPoints),seed(nPoints)) - seed = int(sfcP) - if (Npoints .gt. 1) seed=(sfcP-int(sfcP))*1000000 - call init_rng(rngs, seed) - - ! Call scops - call scops(NPoints,Nlevels,Ncolumns,rngs,tca,cca,overlap,cospIN%frac_out,0) - deallocate(seed,rngs) - - ! Sum up precipitation rates. If not using preciitation fluxes, mixing ratios are - ! stored in _rate variables. - allocate(ls_p_rate(nPoints,nLevels),cv_p_rate(nPoints,Nlevels)) - if(use_precipitation_fluxes) then - ls_p_rate(:,1:nLevels) = fl_lsrainIN + fl_lssnowIN + fl_lsgrplIN - cv_p_rate(:,1:nLevels) = fl_ccrainIN + fl_ccsnowIN - else - ls_p_rate(:,1:nLevels) = 0 ! mixing_ratio(rain) + mixing_ratio(snow) + mixing_ratio (groupel) - cv_p_rate(:,1:nLevels) = 0 ! mixing_ratio(rain) + mixing_ratio(snow) - endif - - ! Call PREC_SCOPS - allocate(frac_prec(nPoints,nColumns,nLevels)) - call prec_scops(nPoints,nLevels,nColumns,ls_p_rate,cv_p_rate,cospIN%frac_out,frac_prec) - deallocate(ls_p_rate,cv_p_rate) - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Compute precipitation fraction in each gridbox - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Allocate - allocate(frac_ls(nPoints,nLevels),prec_ls(nPoints,nLevels), & - frac_cv(nPoints,nLevels),prec_cv(nPoints,nLevels)) - - ! Initialize - frac_ls(1:nPoints,1:nLevels) = 0._wp - prec_ls(1:nPoints,1:nLevels) = 0._wp - frac_cv(1:nPoints,1:nLevels) = 0._wp - prec_cv(1:nPoints,1:nLevels) = 0._wp - do j=1,nPoints - do k=1,nLevels - do i=1,nColumns - if (cospIN%frac_out(j,i,k) .eq. 1) frac_ls(j,k) = frac_ls(j,k)+1._wp - if (cospIN%frac_out(j,i,k) .eq. 2) frac_cv(j,k) = frac_cv(j,k)+1._wp - if (frac_prec(j,i,k) .eq. 1) prec_ls(j,k) = prec_ls(j,k)+1._wp - if (frac_prec(j,i,k) .eq. 2) prec_cv(j,k) = prec_cv(j,k)+1._wp - if (frac_prec(j,i,k) .eq. 3) prec_cv(j,k) = prec_cv(j,k)+1._wp - if (frac_prec(j,i,k) .eq. 3) prec_ls(j,k) = prec_ls(j,k)+1._wp - enddo - frac_ls(j,k)=frac_ls(j,k)/nColumns - frac_cv(j,k)=frac_cv(j,k)/nColumns - prec_ls(j,k)=prec_ls(j,k)/nColumns - prec_cv(j,k)=prec_cv(j,k)/nColumns - - ! Adjust grid-box mean snow properties to local properties - ! Convert longwave optical depth to longwave emissivity - if (prec_ls(j,k) .ne. 0._r8 .and. dtau_s_snow(j,k) .gt. 0._r8) then - dtau_s_snow(j,k) = dtau_s_snow(j,k)/prec_ls(j,k) - end if - if (prec_ls(j,k) .ne. 0._r8 .and. dem_s_snow(j,k) .gt. 0._r8) then - dem_s_snow(j,k) = dem_s_snow(j,k)/prec_ls(j,k) - dem_s_snow(j,k) = 1._r8 - exp ( -1._r8*dem_s_snow(j,k)) - end if !!+JEK - enddo - enddo - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Compute mixing ratios, effective radii and precipitation fluxes for clouds - ! and precipitation - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - allocate(mr_hydro(nPoints,nColumns,nLevels,nHydro), & - Reff(nPoints,nColumns,nLevels,nHydro), & - Np(nPoints,nColumns,nLevels,nHydro)) - - ! Initialize - mr_hydro(:,:,:,:) = 0._wp - Reff(:,:,:,:) = 0._wp - Np(:,:,:,:) = 0._wp - - do k=1,nColumns - ! Subcolumn clouds - column_frac_out = cospIN%frac_out(:,k,:) - - ! LS clouds - where (column_frac_out == I_LSC) - mr_hydro(:,k,:,I_LSCLIQ) = mr_lsliq - mr_hydro(:,k,:,I_LSCICE) = mr_lsice - Reff(:,k,:,I_LSCLIQ) = ReffIN(:,:,I_LSCLIQ) - Reff(:,k,:,I_LSCICE) = ReffIN(:,:,I_LSCICE) - ! CONV clouds - elsewhere (column_frac_out == I_CVC) - mr_hydro(:,k,:,I_CVCLIQ) = mr_ccliq - mr_hydro(:,k,:,I_CVCICE) = mr_ccice - Reff(:,k,:,I_CVCLIQ) = ReffIN(:,:,I_CVCLIQ) - Reff(:,k,:,I_CVCICE) = ReffIN(:,:,I_CVCICE) - end where - - ! Subcolumn precipitation - column_prec_out = frac_prec(:,k,:) - - ! LS Precipitation - where ((column_prec_out == 1) .or. (column_prec_out == 3) ) - Reff(:,k,:,I_LSRAIN) = ReffIN(:,:,I_LSRAIN) - Reff(:,k,:,I_LSSNOW) = ReffIN(:,:,I_LSSNOW) - Reff(:,k,:,I_LSGRPL) = ReffIN(:,:,I_LSGRPL) - ! CONV precipitation - elsewhere ((column_prec_out == 2) .or. (column_prec_out == 3)) - Reff(:,k,:,I_CVRAIN) = ReffIN(:,:,I_CVRAIN) - Reff(:,k,:,I_CVSNOW) = ReffIN(:,:,I_CVSNOW) - end where - enddo - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Convert the mixing ratio and precipitation fluxes from gridbox mean to - ! the fraction-based values - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - do k=1,nLevels - do j=1,nPoints - ! Clouds - if (frac_ls(j,k) .ne. 0._r8) then - mr_hydro(j,:,k,I_LSCLIQ) = mr_hydro(j,:,k,I_LSCLIQ)/frac_ls(j,k) - mr_hydro(j,:,k,I_LSCICE) = mr_hydro(j,:,k,I_LSCICE)/frac_ls(j,k) - endif - if (frac_cv(j,k) .ne. 0._r8) then - mr_hydro(j,:,k,I_CVCLIQ) = mr_hydro(j,:,k,I_CVCLIQ)/frac_cv(j,k) - mr_hydro(j,:,k,I_CVCICE) = mr_hydro(j,:,k,I_CVCICE)/frac_cv(j,k) - endif - - ! Precipitation - if (use_precipitation_fluxes) then - if (prec_ls(j,k) .ne. 0._r8) then - fl_lsrain(j,k) = fl_lsrainIN(j,k)/prec_ls(j,k) - fl_lssnow(j,k) = fl_lssnowIN(j,k)/prec_ls(j,k) - fl_lsgrpl(j,k) = fl_lsgrplIN(j,k)/prec_ls(j,k) - endif - if (prec_cv(j,k) .ne. 0._r8) then - fl_ccrain(j,k) = fl_ccrainIN(j,k)/prec_cv(j,k) - fl_ccsnow(j,k) = fl_ccsnowIN(j,k)/prec_cv(j,k) - endif - else - if (prec_ls(j,k) .ne. 0._r8) then - mr_hydro(j,:,k,I_LSRAIN) = mr_hydro(j,:,k,I_LSRAIN)/prec_ls(j,k) - mr_hydro(j,:,k,I_LSSNOW) = mr_hydro(j,:,k,I_LSSNOW)/prec_ls(j,k) - mr_hydro(j,:,k,I_LSGRPL) = mr_hydro(j,:,k,I_LSGRPL)/prec_ls(j,k) - endif - if (prec_cv(j,k) .ne. 0._r8) then - mr_hydro(j,:,k,I_CVRAIN) = mr_hydro(j,:,k,I_CVRAIN)/prec_cv(j,k) - mr_hydro(j,:,k,I_CVSNOW) = mr_hydro(j,:,k,I_CVSNOW)/prec_cv(j,k) - endif - endif - enddo - enddo - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Convert precipitation fluxes to mixing ratios - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - if (use_precipitation_fluxes) then - ! LS rain - call cosp_precip_mxratio(nPoints, nLevels, nColumns, cospstateIN%pfull, & - cospstateIN%at, frac_prec, 1._wp, n_ax(I_LSRAIN), n_bx(I_LSRAIN), & - alpha_x(I_LSRAIN), c_x(I_LSRAIN), d_x(I_LSRAIN), g_x(I_LSRAIN), & - a_x(I_LSRAIN), b_x(I_LSRAIN), gamma_1(I_LSRAIN), gamma_2(I_LSRAIN), & - gamma_3(I_LSRAIN), gamma_4(I_LSRAIN), fl_lsrain, & - mr_hydro(:,:,:,I_LSRAIN), Reff(:,:,:,I_LSRAIN)) - ! LS snow - call cosp_precip_mxratio(nPoints, nLevels, nColumns, cospstateIN%pfull, & - cospstateIN%at, frac_prec, 1._wp, n_ax(I_LSSNOW), n_bx(I_LSSNOW), & - alpha_x(I_LSSNOW), c_x(I_LSSNOW), d_x(I_LSSNOW), g_x(I_LSSNOW), & - a_x(I_LSSNOW), b_x(I_LSSNOW), gamma_1(I_LSSNOW), gamma_2(I_LSSNOW), & - gamma_3(I_LSSNOW), gamma_4(I_LSSNOW), fl_lssnow, & - mr_hydro(:,:,:,I_LSSNOW), Reff(:,:,:,I_LSSNOW)) - ! CV rain - call cosp_precip_mxratio(nPoints, nLevels, nColumns, cospstateIN%pfull, & - cospstateIN%at, frac_prec, 2._wp, n_ax(I_CVRAIN), n_bx(I_CVRAIN), & - alpha_x(I_CVRAIN), c_x(I_CVRAIN), d_x(I_CVRAIN), g_x(I_CVRAIN), & - a_x(I_CVRAIN), b_x(I_CVRAIN), gamma_1(I_CVRAIN), gamma_2(I_CVRAIN), & - gamma_3(I_CVRAIN), gamma_4(I_CVRAIN), fl_ccrain, & - mr_hydro(:,:,:,I_CVRAIN), Reff(:,:,:,I_CVRAIN)) - ! CV snow - call cosp_precip_mxratio(nPoints, nLevels, nColumns, cospstateIN%pfull, & - cospstateIN%at, frac_prec, 2._wp, n_ax(I_CVSNOW), n_bx(I_CVSNOW), & - alpha_x(I_CVSNOW), c_x(I_CVSNOW), d_x(I_CVSNOW), g_x(I_CVSNOW), & - a_x(I_CVSNOW), b_x(I_CVSNOW), gamma_1(I_CVSNOW), gamma_2(I_CVSNOW), & - gamma_3(I_CVSNOW), gamma_4(I_CVSNOW), fl_ccsnow, & - mr_hydro(:,:,:,I_CVSNOW), Reff(:,:,:,I_CVSNOW)) - ! LS groupel. - call cosp_precip_mxratio(nPoints, nLevels, nColumns, cospstateIN%pfull, & - cospstateIN%at, frac_prec, 1._wp, n_ax(I_LSGRPL), n_bx(I_LSGRPL), & - alpha_x(I_LSGRPL), c_x(I_LSGRPL), d_x(I_LSGRPL), g_x(I_LSGRPL), & - a_x(I_LSGRPL), b_x(I_LSGRPL), gamma_1(I_LSGRPL), gamma_2(I_LSGRPL), & - gamma_3(I_LSGRPL), gamma_4(I_LSGRPL), fl_lsgrpl, & - mr_hydro(:,:,:,I_LSGRPL), Reff(:,:,:,I_LSGRPL)) - endif - - else - cospIN%frac_out(:,:,:) = 1 - allocate(mr_hydro(nPoints, 1,nLevels,nHydro),Reff(nPoints,1,nLevels,nHydro), & - Np(nPoints,1,nLevels,nHydro)) - mr_hydro(:,1,:,I_LSCLIQ) = mr_lsliq - mr_hydro(:,1,:,I_LSCICE) = mr_lsice - mr_hydro(:,1,:,I_CVCLIQ) = mr_ccliq - mr_hydro(:,1,:,I_CVCICE) = mr_ccice - Reff(:,1,:,:) = ReffIN - endif - call t_stopf("scops") - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! CLOUDSAT RADAR OPTICS - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - call t_startf("cloudsat_optics") - if (lradar_sim) then - ! Compute gaseous absorption (assume identical for each subcolun) - allocate(g_vol(nPoints,nLevels)) - g_vol(:,:)=0._wp - do i = 1, nPoints - do j = 1, nLevels - if (cospIN%rcfg_cloudsat%use_gas_abs == 1 .or. & - (cospIN%rcfg_cloudsat%use_gas_abs == 2 .and. j == 1)) then - g_vol(i,j) = gases(cospstateIN%pfull(i,j), cospstateIN%at(i,j), & - cospstateIN%qv(i,j), cospIN%rcfg_cloudsat%freq) - endif - cospIN%g_vol_cloudsat(i,:,j) = g_vol(i,j) - end do - end do - - ! Loop over all subcolumns - allocate(fracPrecipIce(nPoints,nColumns,nLevels)) - fracPrecipIce(:,:,:) = 0._wp - do k=1,nColumns - call quickbeam_optics(sd, cospIN%rcfg_cloudsat, nPoints, nLevels, R_UNDEF, & - mr_hydro(:,k,:,1:nHydro)*1000._wp, Reff(:,k,:,1:nHydro)*1.e6_wp, & - Np(:,k,:,1:nHydro), cospstateIN%pfull, cospstateIN%at, & - cospstateIN%qv, cospIN%z_vol_cloudsat(1:nPoints,k,:), & - cospIN%kr_vol_cloudsat(1:nPoints,k,:)) - - ! At each model level, what fraction of the precipitation is frozen? - where(mr_hydro(:,k,:,I_LSRAIN) .gt. 0 .or. mr_hydro(:,k,:,I_LSSNOW) .gt. 0 .or. & - mr_hydro(:,k,:,I_CVRAIN) .gt. 0 .or. mr_hydro(:,k,:,I_CVSNOW) .gt. 0 .or. & - mr_hydro(:,k,:,I_LSGRPL) .gt. 0) - fracPrecipIce(:,k,:) = (mr_hydro(:,k,:,I_LSSNOW) + mr_hydro(:,k,:,I_CVSNOW) + & - mr_hydro(:,k,:,I_LSGRPL)) / & - (mr_hydro(:,k,:,I_LSSNOW) + mr_hydro(:,k,:,I_CVSNOW) + mr_hydro(:,k,:,I_LSGRPL) + & - mr_hydro(:,k,:,I_LSRAIN) + mr_hydro(:,k,:,I_CVRAIN)) - elsewhere - fracPrecipIce(:,k,:) = 0._wp - endwhere - enddo - - ! Regrid frozen fraction to Cloudsat/Calipso statistical grid - allocate(fracPrecipIce_statGrid(nPoints,nColumns,Nlvgrid)) - fracPrecipIce_statGrid(:,:,:) = 0._wp - call cosp_change_vertical_grid(Npoints, Ncolumns, Nlevels, cospstateIN%hgt_matrix(:,Nlevels:1:-1), & - cospstateIN%hgt_matrix_half(:,Nlevels:1:-1), fracPrecipIce(:,:,Nlevels:1:-1), Nlvgrid, & - vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), fracPrecipIce_statGrid(:,:,Nlvgrid:1:-1)) - - ! For near-surface diagnostics, we only need the frozen fraction at one layer. - cospIN%fracPrecipIce(:,:) = fracPrecipIce_statGrid(:,:,cloudsat_preclvl) - - ! Regrid preipitation mixing-ratios to statistical grid. - !allocate(tempStatGrid(nPoints,ncol,Nlvgrid)) - !tempStatGrid(:,:,:,:) = 0._wp - !call cosp_change_vertical_grid(Npoints, ncol, pver, cospstateIN%hgt_matrix(:,pver:1:-1), & - ! cospstateIN%hgt_matrix_half(:,pver:1:-1), mr_hydro(:,:,:,LSGRPL), & - ! Nlvgrid,vgrid_zl(Nlvgrid:1:-1), vgrid_zu(Nlvgrid:1:-1), tempStatGrid) - ! - endif - call t_stopf("cloudsat_optics") - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! CALIPSO Polarized optics - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - call t_startf("calipso_optics") - if (Llidar_sim) then - ReffTemp = ReffIN - call lidar_optics(nPoints,nColumns,nLevels,5,lidar_ice_type, & - mr_hydro(1:nPoints,1:nColumns,1:nLevels,I_LSCLIQ), & - mr_hydro(1:nPoints,1:nColumns,1:nLevels,I_LSCICE), & - mr_hydro(1:nPoints,1:nColumns,1:nLevels,I_CVCLIQ), & - mr_hydro(1:nPoints,1:nColumns,1:nLevels,I_CVCICE), & - mr_hydro(1:nPoints,1:nColumns,1:nLevels,I_LSSNOW), & - ReffTemp(1:nPoints,1:nLevels,I_LSCLIQ), & - ReffTemp(1:nPoints,1:nLevels,I_LSCICE), & - ReffTemp(1:nPoints,1:nLevels,I_CVCLIQ), & - ReffTemp(1:nPoints,1:nLevels,I_CVCICE), & - ReffTemp(1:nPoints,1:nLevels,I_LSSNOW), & - cospstateIN%pfull(1:nPoints,1:nLevels), & - cospstateIN%phalf(1:nPoints,1:nLevels+1), & - cospstateIN%at(1:nPoints,1:nLevels), & - cospIN%beta_mol_calipso(1:nPoints,1:nLevels), & - cospIN%betatot_calipso(1:nPoints,1:nColumns,1:nLevels), & - cospIN%tau_mol_calipso(1:nPoints,1:nLevels), & - cospIN%tautot_calipso(1:nPoints,1:nColumns,1:nLevels), & - cospIN%tautot_S_liq(1:nPoints,1:nColumns), & - cospIN%tautot_S_ice(1:nPoints,1:nColumns), & - cospIN%betatot_ice_calipso(1:nPoints,1:nColumns,1:nLevels), & - cospIN%betatot_liq_calipso(1:nPoints,1:nColumns,1:nLevels), & - cospIN%tautot_ice_calipso(1:nPoints,1:nColumns,1:nLevels), & - cospIN%tautot_liq_calipso(1:nPoints,1:nColumns,1:nLevels)) - endif - call t_stopf("calipso_optics") - - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Compute optical fields for passive simulators (i.e. only sunlit points) - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! 11 micron emissivity (needed by the ISCCP simulator) - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - call t_startf("11micron_emissivity") - if (Lisccp_sim) then - call cosp_simulator_optics(nPoints,nColumns,nLevels,cospIN%frac_out,dem_c,dem_s, & - cospIN%emiss_11) - ! Add in contributions from radiative snow - do j=1,nColumns - where(frac_prec(:,j,:) .eq. 1 .or. frac_prec(:,j,:) .eq. 3) - cospIN%emiss_11(:,j,:) = 1._wp - (1- cospIN%emiss_11(:,j,:))*(1-dem_s_snow) - endwhere - enddo - endif - call t_stopf("11micron_emissivity") - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! 0.67 micron optical depth (needed by ISCCP, MISR and MODIS simulators) - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - call t_startf("067tau") - if (Lisccp_sim .or. Lmisr_sim .or. Lmodis_sim) then - call cosp_simulator_optics(nPoints,nColumns,nLevels,cospIN%frac_out,dtau_c,dtau_s,& - cospIN%tau_067) - - ! Add in contributions from snow - do j=1,nColumns - where((frac_prec(:,j,:) .eq. 1 .or. frac_prec(:,j,:) .eq. 3) .and. & - Reff(:,j,:,I_LSSNOW) .gt. 0._r8 .and. dtau_s_snow .gt. 0._r8) - cospIN%tau_067(:,j,:) = cospIN%tau_067(:,j,:)+dtau_s_snow - endwhere - enddo - endif - call t_stopf("067tau") - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! MODIS optics - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - call t_startf("modis_optics") - if (lmodis_sim) then - allocate(MODIS_cloudWater(nPoints,nColumns,nLevels), & - MODIS_cloudIce(nPoints,nColumns,nLevels), & - MODIS_cloudSnow(nPoints,nColumns,nLevels), & - MODIS_waterSize(nPoints,nColumns,nLevels), & - MODIS_iceSize(nPoints,nColumns,nLevels), & - MODIS_snowSize(nPoints,nColumns,nLevels), & - MODIS_opticalThicknessLiq(nPoints,nColumns,nLevels), & - MODIS_opticalThicknessIce(nPoints,nColumns,nLevels), & - MODIS_opticalThicknessSnow(nPoints,nColumns,nLevels)) - - ! Cloud water - call cosp_simulator_optics(nPoints,nColumns,nLevels,cospIN%frac_out, & - mr_hydro(:,:,:,I_CVCLIQ),mr_hydro(:,:,:,I_LSCLIQ),MODIS_cloudWater) - ! Cloud ice - call cosp_simulator_optics(nPoints,nColumns,nLevels,cospIN%frac_out, & - mr_hydro(:,:,:,I_CVCICE),mr_hydro(:,:,:,I_LSCICE),MODIS_cloudIce) - ! Cloud water droplet size - call cosp_simulator_optics(nPoints,nColumns,nLevels,cospIN%frac_out, & - Reff(:,:,:,I_CVCLIQ),Reff(:,:,:,I_LSCLIQ),MODIS_waterSize) - ! Cloud ice crystal size - call cosp_simulator_optics(nPoints,nColumns,nLevels,cospIN%frac_out, & - Reff(:,:,:,I_CVCICE),Reff(:,:,:,I_LSCICE),MODIS_iceSize) - - ! Cloud snow and size - MODIS_snowSize(:,:,:) = Reff(:,:,:,I_LSSNOW) - do j=1,nColumns - where((frac_prec(:,j,:) .eq. 1 .or. frac_prec(:,j,:) .eq. 3) .and. & - Reff(:,j,:,I_LSSNOW) .gt. 0._r8 .and. dtau_s_snow .gt. 0._r8) - MODIS_cloudSnow(:,j,:) = mr_hydro(:,j,:,I_LSSNOW) - MODIS_snowSize(:,j,:) = Reff(:,j,:,I_LSSNOW) - elsewhere - MODIS_snowSize(:,j,:) = 0._wp - MODIS_cloudSnow(:,j,:) = 0._wp - endwhere - enddo - - ! Partition optical thickness into liquid and ice parts - call modis_optics_partition(nPoints, nLevels, nColumns, MODIS_cloudWater, & - MODIS_cloudIce, MODIS_cloudSnow, MODIS_waterSize, MODIS_iceSize, & - MODIS_snowSize, cospIN%tau_067, MODIS_opticalThicknessLiq, & - MODIS_opticalThicknessIce, MODIS_opticalThicknessSnow) - - ! Compute assymetry parameter and single scattering albedo - call modis_optics(nPoints, nLevels, nColumns, MODIS_opticalThicknessLiq, & - MODIS_waterSize*1.0e6_wp, MODIS_opticalThicknessIce, & - MODIS_iceSize*1.0e6_wp, MODIS_opticalThicknessSnow, & - MODIS_snowSize*1.0e6_wp, cospIN%fracLiq, cospIN%asym, cospIN%ss_alb) - - endif ! MODIS simulator optics - call t_stopf("modis_optics") - - end subroutine subsample_and_optics - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE construct_cospIN - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine construct_cospIN(npoints,ncolumns,nlevels,ninst_rttov,y,emis_grey) - use cosp_kinds, only: wp - - ! Inputs - integer,intent(in) :: & - npoints, & ! Number of horizontal gridpoints - ncolumns, & ! Number of subcolumns - nlevels, & ! Number of vertical levels - ninst_rttov ! Number of RTTOV instruments - ! Outputs - type(cosp_optical_inputs),intent(out) :: y - ! Optional input - real(wp),intent(in),target, optional :: & - emis_grey - - ! Dimensions - y%Npoints = Npoints - y%Ncolumns = Ncolumns - y%Nlevels = Nlevels - y%Ninst_rttov = Ninst_rttov - y%Npart = 4 - y%Nrefl = PARASOL_NREFL - - if (present(emis_grey)) y%emis_grey => emis_grey - - allocate(y%tau_067( npoints, ncolumns, nlevels),& - y%emiss_11( npoints, ncolumns, nlevels),& - y%frac_out( npoints, ncolumns, nlevels),& - y%betatot_calipso( npoints, ncolumns, nlevels),& - y%betatot_ice_calipso(npoints, ncolumns, nlevels),& - y%fracLiq( npoints, ncolumns, nlevels),& - y%betatot_liq_calipso(npoints, ncolumns, nlevels),& - y%tautot_calipso( npoints, ncolumns, nlevels),& - y%tautot_ice_calipso( npoints, ncolumns, nlevels),& - y%tautot_liq_calipso( npoints, ncolumns, nlevels),& - y%z_vol_cloudsat( npoints, ncolumns, nlevels),& - y%kr_vol_cloudsat( npoints, ncolumns, nlevels),& - y%g_vol_cloudsat( npoints, ncolumns, nlevels),& - y%asym( npoints, ncolumns, nlevels),& - y%ss_alb( npoints, ncolumns, nlevels),& - y%beta_mol_calipso( npoints, nlevels),& - y%tau_mol_calipso( npoints, nlevels),& - y%tautot_S_ice( npoints, ncolumns ),& - y%tautot_S_liq( npoints, ncolumns) ,& - y%fracPrecipIce(npoints, ncolumns)) - allocate(y%cfg_rttov(ninst_rttov)) ! JKS do I need an if statement if "ninst_rttov" is zero? - end subroutine construct_cospIN - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE construct_cospstateIN - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine construct_cospstateIN(npoints,nlevels,y) - ! Inputs - integer,intent(in) :: & - npoints, & ! Number of horizontal gridpoints - nlevels ! Number of vertical levels - ! Outputs - type(cosp_column_inputs),intent(out) :: y - - allocate(y%sunlit(npoints),y%skt(npoints),y%land(npoints),y%at(npoints,nlevels), & - y%pfull(npoints,nlevels),y%phalf(npoints,nlevels+1),y%qv(npoints,nlevels), & - y%o3(npoints,nlevels),y%hgt_matrix(npoints,nlevels),y%u_sfc(npoints), & - y%co(npoints,nlevels),y%n2o(npoints,nlevels),y%ch4(npoints,nlevels), & - y%co2(npoints,nlevels), & - y%v_sfc(npoints),y%lat(npoints),y%lon(nPoints),y%rttov_sfcmask(nPoints), & - y%cloudIce(nPoints,nLevels),y%cloudLiq(nPoints,nLevels),y%surfelev(nPoints),& - y%DeffLiq(nPoints,nLevels),y%DeffIce(nPoints,nLevels), & - y%fl_snow(nPoints,nLevels),y%fl_rain(nPoints,nLevels), & - y%tca(nPoints,nLevels),y%hgt_matrix_half(npoints,nlevels), & - y%month(nPoints),y%time_frac(nPoints),y%sza(nPoints)) - - end subroutine construct_cospstateIN - ! ###################################################################################### - ! SUBROUTINE construct_cosp_outputs - ! - ! This subroutine allocates output fields based on input logical flag switches. - ! ###################################################################################### - subroutine construct_cosp_outputs(Npoints,Ncolumns,Nlevels,Nlvgrid,Ninst_rttov,rttov_configs,x) - ! Inputs - integer,intent(in) :: & - Npoints, & ! Number of sampled points - Ncolumns, & ! Number of subgrid columns - Nlevels, & ! Number of model levels - Nlvgrid, & ! Number of levels in L3 stats computation - Ninst_rttov ! Number of RTTOV instruments - - type(rttov_cfg), dimension(Ninst_rttov),intent(in) :: & - rttov_configs - - ! Outputs - type(cosp_outputs),intent(out) :: & - x ! COSP output structure - - integer :: & - i - - ! ISCCP simulator outputs - if (lisccp_sim) then - allocate(x%isccp_boxtau(Npoints,Ncolumns)) - allocate(x%isccp_boxptop(Npoints,Ncolumns)) - allocate(x%isccp_fq(Npoints,numISCCPTauBins,numISCCPPresBins)) - allocate(x%isccp_totalcldarea(Npoints)) - allocate(x%isccp_meanptop(Npoints)) - allocate(x%isccp_meantaucld(Npoints)) - allocate(x%isccp_meantb(Npoints)) - allocate(x%isccp_meantbclr(Npoints)) - allocate(x%isccp_meanalbedocld(Npoints)) - endif - - ! MISR simulator - if (lmisr_sim) then - allocate(x%misr_fq(Npoints,numMISRTauBins,numMISRHgtBins)) - ! *NOTE* These 3 fields are not output, but were part of the v1.4.0 cosp_misr, so - ! they are still computed. Should probably have a logical to control these - ! outputs. - allocate(x%misr_dist_model_layertops(Npoints,numMISRHgtBins)) - allocate(x%misr_meanztop(Npoints)) - allocate(x%misr_cldarea(Npoints)) - endif - - ! MODIS simulator - if (lmodis_sim) then - allocate(x%modis_Cloud_Fraction_Total_Mean(Npoints)) - allocate(x%modis_Cloud_Fraction_Water_Mean(Npoints)) - allocate(x%modis_Cloud_Fraction_Ice_Mean(Npoints)) - allocate(x%modis_Cloud_Fraction_High_Mean(Npoints)) - allocate(x%modis_Cloud_Fraction_Mid_Mean(Npoints)) - allocate(x%modis_Cloud_Fraction_Low_Mean(Npoints)) - allocate(x%modis_Optical_Thickness_Total_Mean(Npoints)) - allocate(x%modis_Optical_Thickness_Water_Mean(Npoints)) - allocate(x%modis_Optical_Thickness_Ice_Mean(Npoints)) - allocate(x%modis_Optical_Thickness_Total_LogMean(Npoints)) - allocate(x%modis_Optical_Thickness_Water_LogMean(Npoints)) - allocate(x%modis_Optical_Thickness_Ice_LogMean(Npoints)) - allocate(x%modis_Cloud_Particle_Size_Water_Mean(Npoints)) - allocate(x%modis_Cloud_Particle_Size_Ice_Mean(Npoints)) - allocate(x%modis_Cloud_Top_Pressure_Total_Mean(Npoints)) - allocate(x%modis_Liquid_Water_Path_Mean(Npoints)) - allocate(x%modis_Ice_Water_Path_Mean(Npoints)) - allocate(x%modis_Optical_Thickness_vs_Cloud_Top_Pressure(nPoints,numModisTauBins,numMODISPresBins)) - allocate(x%modis_Optical_thickness_vs_ReffLIQ(nPoints,numMODISTauBins,numMODISReffLiqBins)) - allocate(x%modis_Optical_Thickness_vs_ReffICE(nPoints,numMODISTauBins,numMODISReffIceBins)) - endif - - ! CALIPSO simulator - if (llidar_sim) then - allocate(x%calipso_beta_mol(Npoints,Nlevels)) - allocate(x%calipso_beta_tot(Npoints,Ncolumns,Nlevels)) - allocate(x%calipso_srbval(SR_BINS+1)) - allocate(x%calipso_cfad_sr(Npoints,SR_BINS,Nlvgrid)) - allocate(x%calipso_betaperp_tot(Npoints,Ncolumns,Nlevels)) - allocate(x%calipso_lidarcld(Npoints,Nlvgrid)) - allocate(x%calipso_cldlayer(Npoints,LIDAR_NCAT)) - allocate(x%calipso_lidarcldphase(Npoints,Nlvgrid,6)) - allocate(x%calipso_lidarcldtmp(Npoints,LIDAR_NTEMP,5)) - allocate(x%calipso_cldlayerphase(Npoints,LIDAR_NCAT,6)) - ! These 2 outputs are part of the calipso output type, but are not controlled by an - ! logical switch in the output namelist, so if all other fields are on, then allocate - allocate(x%calipso_tau_tot(Npoints,Ncolumns,Nlevels)) - allocate(x%calipso_temp_tot(Npoints,Nlevels)) - ! Calipso opaque cloud diagnostics -! allocate(x%calipso_cldtype(Npoints,LIDAR_NTYPE)) -! allocate(x%calipso_cldtypetemp(Npoints,LIDAR_NTYPE)) -! allocate(x%calipso_cldtypemeanz(Npoints,2)) -! allocate(x%calipso_cldtypemeanzse(Npoints,3)) -! allocate(x%calipso_cldthinemis(Npoints)) -! allocate(x%calipso_lidarcldtype(Npoints,Nlvgrid,LIDAR_NTYPE+1)) - endif - - ! PARASOL - if (lparasol_sim) then - allocate(x%parasolPix_refl(Npoints,Ncolumns,PARASOL_NREFL)) - allocate(x%parasolGrid_refl(Npoints,PARASOL_NREFL)) - endif - - ! Cloudsat simulator - if (lradar_sim) then - allocate(x%cloudsat_Ze_tot(Npoints,Ncolumns,Nlevels)) - allocate(x%cloudsat_cfad_ze(Npoints,CLOUDSAT_DBZE_BINS,Nlvgrid)) - allocate(x%lidar_only_freq_cloud(Npoints,Nlvgrid)) - allocate(x%radar_lidar_tcc(Npoints)) - allocate(x%cloudsat_precip_cover(Npoints,nCloudsatPrecipClass)) - allocate(x%cloudsat_pia(Npoints)) - endif - - ! RTTOV - Allocate output for multiple instruments - ! Do I not need to allocate the number of instruments? Because each rttov output DDT will be a pointer? - - if (masterproc) then - if (docosp) then - write(iulog,*)'Reached RTTOV section in construct_cosp_outputs' - write(iulog,*)'lrttov_sim: ', lrttov_sim - end if - end if - - if ((Ninst_rttov .gt. 0) .and. (lrttov_sim)) then - x % Ninst_rttov = Ninst_rttov - allocate(x % rttov_outputs(Ninst_rttov)) ! Need to allocate a pointer? - print*,'Immediately after rttov_outputs allocation.' - print*,'associated(x % rttov_outputs(1) % refl_total): ',associated(x % rttov_outputs(1) % refl_total) - print*,'associated(x % rttov_outputs(1) % refl_clear): ',associated(x % rttov_outputs(1) % refl_clear) - do i=1,Ninst_rttov - print*,'i: ',i - print*,'rttov_configs(i) % nchan_out: ',rttov_configs(i) % nchan_out - print*,'rttov_configs(i) % Lrttov_bt: ',rttov_configs(i) % Lrttov_bt - print*,'rttov_configs(i) % Lrttov_rad: ',rttov_configs(i) % Lrttov_rad - print*,'rttov_configs(i) % Lrttov_refl: ',rttov_configs(i) % Lrttov_refl - print*,'rttov_configs(i) % Lrttov_cld: ',rttov_configs(i) % Lrttov_cld - print*,'rttov_configs(i) % Lrttov_aer: ',rttov_configs(i) % Lrttov_aer - print*,'rttov_configs(i) % Lrttov_pc: ',rttov_configs(i) % Lrttov_pc - - print*,'1.' - x % rttov_outputs(i) % nchan_out = rttov_configs(i) % nchan_out - if (rttov_configs(i) % Lrttov_pc) then ! Treat PC-RTTOV fields as clear-sky only for now - print*,'2a.' - allocate(x % rttov_outputs(i) % channel_indices(rttov_configs(i) % nchan_out)) - if (rttov_configs(i) % Lrttov_bt) then ! Brightness temp - allocate(x % rttov_outputs(i) % bt_total_pc(Npoints,rttov_configs(i) % nchan_out)) - ! if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_bt_clear(Npoints,Nchan)) - end if - if (rttov_configs(i) % Lrttov_rad) then ! Radiance - allocate(x % rttov_outputs(i) % rad_total_pc(Npoints,rttov_configs(i) % nchan_out)) - ! if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_rad_clear(Npoints,Nchan)) - ! if (Lrttov_cld .or. Lrttov_aer) allocate(x%rttov_rad_cloudy(Npoints,Nchan)) - end if - else - print*,'3a.' - allocate(x % rttov_outputs(i) % channel_indices(rttov_configs(i) % nchan_out)) - if (rttov_configs(i) % Lrttov_bt) then ! Brightness temp - allocate(x % rttov_outputs(i) % bt_total(Npoints,rttov_configs(i) % nchan_out)) - if ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer)) then - allocate(x % rttov_outputs(i) % bt_clear(Npoints,rttov_configs(i) % nchan_out)) - end if - end if - if (rttov_configs(i) % Lrttov_rad) then ! Radiance - allocate(x % rttov_outputs(i) % rad_total(Npoints,rttov_configs(i) % nchan_out)) - if ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer)) then - allocate(x % rttov_outputs(i) % rad_clear(Npoints,rttov_configs(i) % nchan_out)) - end if - if ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer)) then - allocate(x % rttov_outputs(i) % rad_cloudy(Npoints,rttov_configs(i) % nchan_out)) - end if - end if - if (rttov_configs(i) % Lrttov_refl) then ! Reflectance - allocate(x % rttov_outputs(i) % refl_total(Npoints,rttov_configs(i) % nchan_out)) - end if - if (rttov_configs(i) % Lrttov_refl .and. ((rttov_configs(i) % Lrttov_cld) .or. (rttov_configs(i) % Lrttov_aer))) then - print*,'in refl_clear if-do.' - print*,'rttov_configs(i) % Lrttov_refl: ',rttov_configs(i) % Lrttov_refl - print*,'rttov_configs(i) % Lrttov_cld: ',rttov_configs(i) % Lrttov_cld - print*,'rttov_configs(i) % Lrttov_aer: ',rttov_configs(i) % Lrttov_aer - allocate(x % rttov_outputs(i) % refl_clear(Npoints,rttov_configs(i) % nchan_out)) - end if !^ Logic should be equivalent?? - end if - end do - else - x % Ninst_rttov = 0 - end if - - print*,'associated(x % rttov_outputs(i) % refl_total): ',associated(x % rttov_outputs(1) % refl_total) - print*,'associated(x % rttov_outputs(i) % refl_clear): ',associated(x % rttov_outputs(1) % refl_clear) - if (masterproc) then - if (docosp) then - write(iulog,*)'Finished RTTOV section in construct_cosp_outputs' - write(iulog,*)'lrttov_sim: ', lrttov_sim - write(iulog,*)'associated(x % rttov_outputs(i) % bt_total): ',associated(x % rttov_outputs(1) % bt_total) - write(iulog,*)'associated(x % rttov_outputs(i) % refl_total): ',associated(x % rttov_outputs(1) % refl_total) - write(iulog,*)'associated(x % rttov_outputs(i) % refl_clear): ',associated(x % rttov_outputs(1) % refl_clear) - end if - end if - - end subroutine construct_cosp_outputs - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE destroy_cospIN - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine destroy_cospIN(y) - type(cosp_optical_inputs),intent(inout) :: y - - if (allocated(y%tau_067)) deallocate(y%tau_067) - if (allocated(y%emiss_11)) deallocate(y%emiss_11) - if (allocated(y%frac_out)) deallocate(y%frac_out) - if (allocated(y%beta_mol_calipso)) deallocate(y%beta_mol_calipso) - if (allocated(y%tau_mol_calipso)) deallocate(y%tau_mol_calipso) - if (allocated(y%betatot_calipso)) deallocate(y%betatot_calipso) - if (allocated(y%betatot_ice_calipso)) deallocate(y%betatot_ice_calipso) - if (allocated(y%betatot_liq_calipso)) deallocate(y%betatot_liq_calipso) - if (allocated(y%tautot_calipso)) deallocate(y%tautot_calipso) - if (allocated(y%tautot_ice_calipso)) deallocate(y%tautot_ice_calipso) - if (allocated(y%tautot_liq_calipso)) deallocate(y%tautot_liq_calipso) - if (allocated(y%tautot_S_liq)) deallocate(y%tautot_S_liq) - if (allocated(y%tautot_S_ice)) deallocate(y%tautot_S_ice) - if (allocated(y%z_vol_cloudsat)) deallocate(y%z_vol_cloudsat) - if (allocated(y%kr_vol_cloudsat)) deallocate(y%kr_vol_cloudsat) - if (allocated(y%g_vol_cloudsat)) deallocate(y%g_vol_cloudsat) - if (allocated(y%asym)) deallocate(y%asym) - if (allocated(y%ss_alb)) deallocate(y%ss_alb) - if (allocated(y%fracLiq)) deallocate(y%fracLiq) - if (allocated(y%fracPrecipIce)) deallocate(y%fracPrecipIce) - end subroutine destroy_cospIN - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE destroy_cospstateIN - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine destroy_cospstateIN(y) - type(cosp_column_inputs),intent(inout) :: y - - if (allocated(y%surfelev)) deallocate(y%surfelev) - if (allocated(y%sunlit)) deallocate(y%sunlit) - if (allocated(y%skt)) deallocate(y%skt) - if (allocated(y%land)) deallocate(y%land) - if (allocated(y%rttov_sfcmask)) deallocate(y%rttov_sfcmask) - if (allocated(y%at)) deallocate(y%at) - if (allocated(y%pfull)) deallocate(y%pfull) - if (allocated(y%phalf)) deallocate(y%phalf) - if (allocated(y%qv)) deallocate(y%qv) - if (allocated(y%month)) deallocate(y%month) ! New RTTOV variables below - if (allocated(y%time_frac)) deallocate(y%time_frac) - if (allocated(y%sza)) deallocate(y%sza) - if (allocated(y%co2)) deallocate(y%co2) - if (allocated(y%ch4)) deallocate(y%ch4) - if (allocated(y%n2o)) deallocate(y%n2o) - if (allocated(y%co)) deallocate(y%co) ! New RTTOV vars^ - if (allocated(y%o3)) deallocate(y%o3) - if (allocated(y%hgt_matrix)) deallocate(y%hgt_matrix) - if (allocated(y%u_sfc)) deallocate(y%u_sfc) - if (allocated(y%v_sfc)) deallocate(y%v_sfc) - if (allocated(y%lat)) deallocate(y%lat) - if (allocated(y%lon)) deallocate(y%lon) - if (allocated(y%emis_in)) deallocate(y%emis_in) - if (allocated(y%refl_in)) deallocate(y%refl_in) - if (allocated(y%cloudIce)) deallocate(y%cloudIce) - if (allocated(y%cloudLiq)) deallocate(y%cloudLiq) - if (allocated(y%DeffLiq)) deallocate(y%DeffLiq) - if (allocated(y%DeffIce)) deallocate(y%DeffIce) - if (allocated(y%fl_rain)) deallocate(y%fl_rain) - if (allocated(y%fl_snow)) deallocate(y%fl_snow) - if (allocated(y%tca)) deallocate(y%tca) - if (allocated(y%hgt_matrix_half)) deallocate(y%hgt_matrix_half) - - end subroutine destroy_cospstateIN - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE destroy_cosp_outputs - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine destroy_cosp_outputs(y) - type(cosp_outputs),intent(inout) :: y - integer :: i ! Local iterator for RTTOV instruments - - ! Deallocate and nullify - if (associated(y%calipso_beta_mol)) then - deallocate(y%calipso_beta_mol) - nullify(y%calipso_beta_mol) - endif - if (associated(y%calipso_temp_tot)) then - deallocate(y%calipso_temp_tot) - nullify(y%calipso_temp_tot) - endif - if (associated(y%calipso_betaperp_tot)) then - deallocate(y%calipso_betaperp_tot) - nullify(y%calipso_betaperp_tot) - endif - if (associated(y%calipso_beta_tot)) then - deallocate(y%calipso_beta_tot) - nullify(y%calipso_beta_tot) - endif - if (associated(y%calipso_tau_tot)) then - deallocate(y%calipso_tau_tot) - nullify(y%calipso_tau_tot) - endif - if (associated(y%calipso_lidarcldphase)) then - deallocate(y%calipso_lidarcldphase) - nullify(y%calipso_lidarcldphase) - endif - if (associated(y%calipso_cldlayerphase)) then - deallocate(y%calipso_cldlayerphase) - nullify(y%calipso_cldlayerphase) - endif - if (associated(y%calipso_lidarcldtmp)) then - deallocate(y%calipso_lidarcldtmp) - nullify(y%calipso_lidarcldtmp) - endif - if (associated(y%calipso_cldlayer)) then - deallocate(y%calipso_cldlayer) - nullify(y%calipso_cldlayer) - endif - if (associated(y%calipso_lidarcld)) then - deallocate(y%calipso_lidarcld) - nullify(y%calipso_lidarcld) - endif - if (associated(y%calipso_srbval)) then - deallocate(y%calipso_srbval) - nullify(y%calipso_srbval) - endif - if (associated(y%calipso_cfad_sr)) then - deallocate(y%calipso_cfad_sr) - nullify(y%calipso_cfad_sr) - endif - if (associated(y%parasolPix_refl)) then - deallocate(y%parasolPix_refl) - nullify(y%parasolPix_refl) - endif - if (associated(y%parasolGrid_refl)) then - deallocate(y%parasolGrid_refl) - nullify(y%parasolGrid_refl) - endif - if (associated(y%cloudsat_Ze_tot)) then - deallocate(y%cloudsat_Ze_tot) - nullify(y%cloudsat_Ze_tot) - endif - if (associated(y%cloudsat_precip_cover)) then - deallocate(y%cloudsat_precip_cover) - nullify(y%cloudsat_precip_cover) - endif - if (associated(y%cloudsat_pia)) then - deallocate(y%cloudsat_pia) - nullify(y%cloudsat_pia) - endif - if (associated(y%cloudsat_cfad_ze)) then - deallocate(y%cloudsat_cfad_ze) - nullify(y%cloudsat_cfad_ze) - endif - if (associated(y%radar_lidar_tcc)) then - deallocate(y%radar_lidar_tcc) - nullify(y%radar_lidar_tcc) - endif - if (associated(y%lidar_only_freq_cloud)) then - deallocate(y%lidar_only_freq_cloud) - nullify(y%lidar_only_freq_cloud) - endif - if (associated(y%isccp_totalcldarea)) then - deallocate(y%isccp_totalcldarea) - nullify(y%isccp_totalcldarea) - endif - if (associated(y%isccp_meantb)) then - deallocate(y%isccp_meantb) - nullify(y%isccp_meantb) - endif - if (associated(y%isccp_meantbclr)) then - deallocate(y%isccp_meantbclr) - nullify(y%isccp_meantbclr) - endif - if (associated(y%isccp_meanptop)) then - deallocate(y%isccp_meanptop) - nullify(y%isccp_meanptop) - endif - if (associated(y%isccp_meantaucld)) then - deallocate(y%isccp_meantaucld) - nullify(y%isccp_meantaucld) - endif - if (associated(y%isccp_meanalbedocld)) then - deallocate(y%isccp_meanalbedocld) - nullify(y%isccp_meanalbedocld) - endif - if (associated(y%isccp_boxtau)) then - deallocate(y%isccp_boxtau) - nullify(y%isccp_boxtau) - endif - if (associated(y%isccp_boxptop)) then - deallocate(y%isccp_boxptop) - nullify(y%isccp_boxptop) - endif - if (associated(y%isccp_fq)) then - deallocate(y%isccp_fq) - nullify(y%isccp_fq) - endif - if (associated(y%misr_fq)) then - deallocate(y%misr_fq) - nullify(y%misr_fq) - endif - if (associated(y%misr_dist_model_layertops)) then - deallocate(y%misr_dist_model_layertops) - nullify(y%misr_dist_model_layertops) - endif - if (associated(y%misr_meanztop)) then - deallocate(y%misr_meanztop) - nullify(y%misr_meanztop) - endif - if (associated(y%misr_cldarea)) then - deallocate(y%misr_cldarea) - nullify(y%misr_cldarea) - endif - if (associated(y%modis_Cloud_Fraction_Total_Mean)) then - deallocate(y%modis_Cloud_Fraction_Total_Mean) - nullify(y%modis_Cloud_Fraction_Total_Mean) - endif - if (associated(y%modis_Cloud_Fraction_Ice_Mean)) then - deallocate(y%modis_Cloud_Fraction_Ice_Mean) - nullify(y%modis_Cloud_Fraction_Ice_Mean) - endif - if (associated(y%modis_Cloud_Fraction_Water_Mean)) then - deallocate(y%modis_Cloud_Fraction_Water_Mean) - nullify(y%modis_Cloud_Fraction_Water_Mean) - endif - if (associated(y%modis_Cloud_Fraction_High_Mean)) then - deallocate(y%modis_Cloud_Fraction_High_Mean) - nullify(y%modis_Cloud_Fraction_High_Mean) - endif - if (associated(y%modis_Cloud_Fraction_Mid_Mean)) then - deallocate(y%modis_Cloud_Fraction_Mid_Mean) - nullify(y%modis_Cloud_Fraction_Mid_Mean) - endif - if (associated(y%modis_Cloud_Fraction_Low_Mean)) then - deallocate(y%modis_Cloud_Fraction_Low_Mean) - nullify(y%modis_Cloud_Fraction_Low_Mean) - endif - if (associated(y%modis_Optical_Thickness_Total_Mean)) then - deallocate(y%modis_Optical_Thickness_Total_Mean) - nullify(y%modis_Optical_Thickness_Total_Mean) - endif - if (associated(y%modis_Optical_Thickness_Water_Mean)) then - deallocate(y%modis_Optical_Thickness_Water_Mean) - nullify(y%modis_Optical_Thickness_Water_Mean) - endif - if (associated(y%modis_Optical_Thickness_Ice_Mean)) then - deallocate(y%modis_Optical_Thickness_Ice_Mean) - nullify(y%modis_Optical_Thickness_Ice_Mean) - endif - if (associated(y%modis_Optical_Thickness_Total_LogMean)) then - deallocate(y%modis_Optical_Thickness_Total_LogMean) - nullify(y%modis_Optical_Thickness_Total_LogMean) - endif - if (associated(y%modis_Optical_Thickness_Water_LogMean)) then - deallocate(y%modis_Optical_Thickness_Water_LogMean) - nullify(y%modis_Optical_Thickness_Water_LogMean) - endif - if (associated(y%modis_Optical_Thickness_Ice_LogMean)) then - deallocate(y%modis_Optical_Thickness_Ice_LogMean) - nullify(y%modis_Optical_Thickness_Ice_LogMean) - endif - if (associated(y%modis_Cloud_Particle_Size_Water_Mean)) then - deallocate(y%modis_Cloud_Particle_Size_Water_Mean) - nullify(y%modis_Cloud_Particle_Size_Water_Mean) - endif - if (associated(y%modis_Cloud_Particle_Size_Ice_Mean)) then - deallocate(y%modis_Cloud_Particle_Size_Ice_Mean) - nullify(y%modis_Cloud_Particle_Size_Ice_Mean) - endif - if (associated(y%modis_Cloud_Top_Pressure_Total_Mean)) then - deallocate(y%modis_Cloud_Top_Pressure_Total_Mean) - nullify(y%modis_Cloud_Top_Pressure_Total_Mean) - endif - if (associated(y%modis_Liquid_Water_Path_Mean)) then - deallocate(y%modis_Liquid_Water_Path_Mean) - nullify(y%modis_Liquid_Water_Path_Mean) - endif - if (associated(y%modis_Ice_Water_Path_Mean)) then - deallocate(y%modis_Ice_Water_Path_Mean) - nullify(y%modis_Ice_Water_Path_Mean) - endif - if (associated(y%modis_Optical_Thickness_vs_Cloud_Top_Pressure)) then - deallocate(y%modis_Optical_Thickness_vs_Cloud_Top_Pressure) - nullify(y%modis_Optical_Thickness_vs_Cloud_Top_Pressure) - endif - if (associated(y%modis_Optical_thickness_vs_ReffLIQ)) then - deallocate(y%modis_Optical_thickness_vs_ReffLIQ) - nullify(y%modis_Optical_thickness_vs_ReffLIQ) - endif - if (associated(y%modis_Optical_thickness_vs_ReffICE)) then - deallocate(y%modis_Optical_thickness_vs_ReffICE) - nullify(y%modis_Optical_thickness_vs_ReffICE) - endif - if (associated(y%calipso_cldtype)) then - deallocate(y%calipso_cldtype) - nullify(y%calipso_cldtype) - endif - if (associated(y%calipso_cldtypetemp)) then - deallocate(y%calipso_cldtypetemp) - nullify(y%calipso_cldtypetemp) - endif - if (associated(y%calipso_cldtypemeanz)) then - deallocate(y%calipso_cldtypemeanz) - nullify(y%calipso_cldtypemeanz) - endif - if (associated(y%calipso_cldtypemeanzse)) then - deallocate(y%calipso_cldtypemeanzse) - nullify(y%calipso_cldtypemeanzse) - endif - if (associated(y%calipso_cldthinemis)) then - deallocate(y%calipso_cldthinemis) - nullify(y%calipso_cldthinemis) - endif - if (associated(y%calipso_lidarcldtype)) then - deallocate(y%calipso_lidarcldtype) - nullify(y%calipso_lidarcldtype) - endif - - ! RTTOV multi-instrument - JKS -! if (associated(y%rttov_outputs)) then - if (allocated(y%rttov_outputs)) then - do i=1,y % Ninst_rttov ! Iterate over each instrument - if (associated(y%rttov_outputs(i)%channel_indices)) then - deallocate(y%rttov_outputs(i)%channel_indices) - nullify(y%rttov_outputs(i)%channel_indices) - endif - if (associated(y%rttov_outputs(i)%bt_total)) then - deallocate(y%rttov_outputs(i)%bt_total) - nullify(y%rttov_outputs(i)%bt_total) - endif - if (associated(y%rttov_outputs(i)%bt_clear)) then - deallocate(y%rttov_outputs(i)%bt_clear) - nullify(y%rttov_outputs(i)%bt_clear) - endif - if (associated(y%rttov_outputs(i)%rad_total)) then - deallocate(y%rttov_outputs(i)%rad_total) - nullify(y%rttov_outputs(i)%rad_total) - endif - if (associated(y%rttov_outputs(i)%rad_clear)) then - deallocate(y%rttov_outputs(i)%rad_clear) - nullify(y%rttov_outputs(i)%rad_clear) - endif - if (associated(y%rttov_outputs(i)%rad_cloudy)) then - deallocate(y%rttov_outputs(i)%rad_cloudy) - nullify(y%rttov_outputs(i)%rad_cloudy) - endif - if (associated(y%rttov_outputs(i)%refl_total)) then - deallocate(y%rttov_outputs(i)%refl_total) - nullify(y%rttov_outputs(i)%refl_total) - endif - if (associated(y%rttov_outputs(i)%refl_clear)) then - deallocate(y%rttov_outputs(i)%refl_clear) - nullify(y%rttov_outputs(i)%refl_clear) - endif - if (associated(y%rttov_outputs(i)%bt_total_pc)) then - deallocate(y%rttov_outputs(i)%bt_total_pc) - nullify(y%rttov_outputs(i)%bt_total_pc) - endif - if (associated(y%rttov_outputs(i)%rad_total_pc)) then - deallocate(y%rttov_outputs(i)%rad_total_pc) - nullify(y%rttov_outputs(i)%rad_total_pc) - endif - end do - deallocate(y%rttov_outputs) -! nullify(y%rttov_outputs) - end if - - end subroutine destroy_cosp_outputs - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE rttov_cleanup - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine rttov_cleanup(y) - use MOD_COSP_RTTOV_INTERFACE, only: DESTROY_RTTOV_CONFIG - - type(cosp_optical_inputs),intent(inout) :: y - integer :: i - - if (size(y%cfg_rttov) .gt. 0) then - do i=1,y%Ninst_rttov - call destroy_rttov_config(y%cfg_rttov(i)) - end do - end if - nullify(y%cfg_rttov) - - end subroutine rttov_cleanup - -#endif - -!####################################################################### -end module cospsimulator_intr diff --git a/driver/run/cosp2_input_AIRS_L1C_validation_nl.txt b/driver/run/cosp2_input_AIRS_L1C_validation_nl.txt deleted file mode 100644 index 356f17e48a..0000000000 --- a/driver/run/cosp2_input_AIRS_L1C_validation_nl.txt +++ /dev/null @@ -1,110 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&COSP_INPUT - NPOINTS=1,! Number of gridpoints 153,27840,7081,6912 - NPOINTS_IT=10,! 50,5000, Max number of gridpoints to be processed in one iteration - NCOLUMNS=20, ! Number of subcolumns - NLEVELS=38, ! Number of model levels - USE_VGRID=.true., ! Use fixed vertical grid for outputs? (if .true. then you need to define number of levels with Nlr) - NLVGRID=40, ! Number of levels in statistical outputs (only used if USE_VGRID=.true.) - CSAT_VGRID=.true., ! CloudSat vertical grid? (if .true. then the CloudSat standard grid is used for the outputs. - ! USE_VGRID needs also be .true.) - DINPUT='./', ! Directory where the input files are located. Useful when processing multiple files. - ! Leave blank ('') if you are using the full path in FINPUT. - FINPUT='../data/inputs/UKMO/cosp_input_um_realisticO3.nc', ! List input NetCDF files - FOUTPUT='../data/outputs/UKMO/cosp2_output_um_AIRS_L1C_O3profile_emis1.nc', - !---------------------------------------------------------------------------------- - !--------------- Inputs related to radar simulations - !---------------------------------------------------------------------------------- - cloudsat_RADAR_FREQ=94.0, ! CloudSat radar frequency (GHz) - SURFACE_RADAR=0, ! surface=1, spaceborne=0 - cloudsat_use_gas_abs=1, ! include gaseous absorption? yes=1,no=0 - cloudsat_do_ray=0, ! calculate/output Rayleigh refl=1, not=0 - cloudsat_k2=-1, ! |K|^2, -1=use frequency dependent default - use_precipitation_fluxes=.true., ! True if precipitation fluxes are input to the algorithm - cloudsat_micro_scheme='MMF_v3_single_moment', !'MMF_v3.5_two_moment' - !---------------------------------------------------------------------------------- - !---------------- Inputs related to lidar simulations - !---------------------------------------------------------------------------------- - lidar_ice_type=0, ! Ice particle shape in lidar calculations (0=ice-spheres ; 1=ice-non-spherical) - OVERLAP=3, ! overlap assumption used by scops: 1=max, 2=rand, 3=max/rand - !---------------------------------------------------------------------------------- - !---------------- Inputs related to ISCCP simulator - !---------------------------------------------------------------------------------- - ISCCP_TOPHEIGHT=1, ! 1 = adjust top height using both a computed - ! infrared brightness temperature and the visible - ! optical depth to adjust cloud top pressure. Note - ! that this calculation is most appropriate to compare - ! to ISCCP data during sunlit hours. - ! 2 = do not adjust top height, that is cloud top - ! pressure is the actual cloud top pressure - ! in the model - ! 3 = adjust top height using only the computed - ! infrared brightness temperature. Note that this - ! calculation is most appropriate to compare to ISCCP - ! IR only algortihm (i.e. you can compare to nighttime - ! ISCCP data with this option) - ISCCP_TOPHEIGHT_DIRECTION=2, ! direction for finding atmosphere pressure level - ! with interpolated temperature equal to the radiance - ! determined cloud-top temperature - ! 1 = find the *lowest* altitude (highest pressure) level - ! with interpolated temperature equal to the radiance - ! determined cloud-top temperature - ! 2 = find the *highest* altitude (lowest pressure) level - ! with interpolated temperature equal to the radiance - ! determined cloud-top temperature. This is the - ! default value since V4.0 of the ISCCP simulator. - ! ONLY APPLICABLE IF top_height EQUALS 1 or 3 - !---------------------------------------------------------------------------------- - !-------------- RTTOV inputs - !---------------------------------------------------------------------------------- - ! Simulating three AIRS L1C instruments - rttov_Ninstruments=3, - rttov_instrument_namelists='instrument_nls/cosp2_rttov_AIRS_L1C_val1.txt','instrument_nls/cosp2_rttov_AIRS_L1C_val2.txt','instrument_nls/cosp2_rttov_AIRS_L1C_val3.txt','instrument_nls/cosp2_rttov_AIRS_L1C_CESM2.txt', - rttov_verbose=.true. - !---------------------------------------------------------------------------------- - !-------------- Swathing inputs - !---------------------------------------------------------------------------------- - N_SWATHS_ISCCP=0, - SWATH_LOCALTIMES_ISCCP=0,0, - SWATH_WIDTHS_ISCCP=0,0, - N_SWATHS_MISR=0, - SWATH_LOCALTIMES_MISR=0,0, - SWATH_WIDTHS_MISR=0,0, - N_SWATHS_MODIS=0, - SWATH_LOCALTIMES_MODIS=0,0, - SWATH_WIDTHS_MODIS=0,0, - N_SWATHS_CSCAL=0, - SWATH_LOCALTIMES_CSCAL=0,0, - SWATH_WIDTHS_CSCAL=0,0, - N_SWATHS_PARASOL=0, - SWATH_LOCALTIMES_PARASOL=0,0, - SWATH_WIDTHS_PARASOL=0,0, - N_SWATHS_ATLID=0, - SWATH_LOCALTIMES_ATLID=0,0, - SWATH_WIDTHS_ATLID=0,0, -/ diff --git a/driver/run/cosp2_input_iasi_nl.txt b/driver/run/cosp2_input_iasi_nl.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/driver/run/cosp2_input_rrtmg_validation_nl.txt b/driver/run/cosp2_input_rrtmg_validation_nl.txt deleted file mode 100644 index 0998ef33fc..0000000000 --- a/driver/run/cosp2_input_rrtmg_validation_nl.txt +++ /dev/null @@ -1,113 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&COSP_INPUT - NPOINTS=153,! Number of gridpoints 153,27840,7081,6912 - NPOINTS_IT=2,! 50,5000, Max number of gridpoints to be processed in one iteration - NCOLUMNS=20, ! Number of subcolumns - NLEVELS=38, ! Number of model levels - USE_VGRID=.true., ! Use fixed vertical grid for outputs? (if .true. then you need to define number of levels with Nlr) - NLVGRID=40, ! Number of levels in statistical outputs (only used if USE_VGRID=.true.) - CSAT_VGRID=.true., ! CloudSat vertical grid? (if .true. then the CloudSat standard grid is used for the outputs. - ! USE_VGRID needs also be .true.) - DINPUT='./', ! Directory where the input files are located. Useful when processing multiple files. - ! Leave blank ('') if you are using the full path in FINPUT. - FINPUT='../data/inputs/UKMO/cosp_input_um.nc', ! List input NetCDF files - FOUTPUT='../data/outputs/UKMO/cosp2_output_um_iasi.nc', - !---------------------------------------------------------------------------------- - !--------------- Inputs related to radar simulations - !---------------------------------------------------------------------------------- - cloudsat_RADAR_FREQ=94.0, ! CloudSat radar frequency (GHz) - SURFACE_RADAR=0, ! surface=1, spaceborne=0 - cloudsat_use_gas_abs=1, ! include gaseous absorption? yes=1,no=0 - cloudsat_do_ray=0, ! calculate/output Rayleigh refl=1, not=0 - cloudsat_k2=-1, ! |K|^2, -1=use frequency dependent default - use_precipitation_fluxes=.true., ! True if precipitation fluxes are input to the algorithm - cloudsat_micro_scheme='MMF_v3_single_moment', !'MMF_v3.5_two_moment' - !---------------------------------------------------------------------------------- - !---------------- Inputs related to lidar simulations - !---------------------------------------------------------------------------------- - lidar_ice_type=0, ! Ice particle shape in lidar calculations (0=ice-spheres ; 1=ice-non-spherical) - OVERLAP=3, ! overlap assumption used by scops: 1=max, 2=rand, 3=max/rand - !---------------------------------------------------------------------------------- - !---------------- Inputs related to ISCCP simulator - !---------------------------------------------------------------------------------- - ISCCP_TOPHEIGHT=1, ! 1 = adjust top height using both a computed - ! infrared brightness temperature and the visible - ! optical depth to adjust cloud top pressure. Note - ! that this calculation is most appropriate to compare - ! to ISCCP data during sunlit hours. - ! 2 = do not adjust top height, that is cloud top - ! pressure is the actual cloud top pressure - ! in the model - ! 3 = adjust top height using only the computed - ! infrared brightness temperature. Note that this - ! calculation is most appropriate to compare to ISCCP - ! IR only algortihm (i.e. you can compare to nighttime - ! ISCCP data with this option) - ISCCP_TOPHEIGHT_DIRECTION=2, ! direction for finding atmosphere pressure level - ! with interpolated temperature equal to the radiance - ! determined cloud-top temperature - ! 1 = find the *lowest* altitude (highest pressure) level - ! with interpolated temperature equal to the radiance - ! determined cloud-top temperature - ! 2 = find the *highest* altitude (lowest pressure) level - ! with interpolated temperature equal to the radiance - ! determined cloud-top temperature. This is the - ! default value since V4.0 of the ISCCP simulator. - ! ONLY APPLICABLE IF top_height EQUALS 1 or 3 - !---------------------------------------------------------------------------------- - !-------------- RTTOV inputs - !---------------------------------------------------------------------------------- - ! Simulating a single Nadir-viewing IASI instrument. - !rttov_Ninstruments=1, - !rttov_instrument_namelists='instrument_nls/cosp2_rttov_IASI_CESM2_val.txt', - ! Simulating three IASI instruments and three FORUM instruments - rttov_Ninstruments=6, - rttov_instrument_namelists='instrument_nls/cosp2_rttov_IASI_CESM2_val1.txt','instrument_nls/cosp2_rttov_IASI_CESM2_val2.txt','instrument_nls/cosp2_rttov_IASI_CESM2_val3.txt','instrument_nls/cosp2_rttov_FORUM_CESM2_val1.txt','instrument_nls/cosp2_rttov_FORUM_CESM2_val2.txt','instrument_nls/cosp2_rttov_FORUM_CESM2_val3.txt', - rttov_verbose=.true. - !---------------------------------------------------------------------------------- - !-------------- Swathing inputs - !---------------------------------------------------------------------------------- - N_SWATHS_ISCCP=0, - SWATH_LOCALTIMES_ISCCP=0,0, - SWATH_WIDTHS_ISCCP=0,0, - N_SWATHS_MISR=0, - SWATH_LOCALTIMES_MISR=0,0, - SWATH_WIDTHS_MISR=0,0, - N_SWATHS_MODIS=0, - SWATH_LOCALTIMES_MODIS=0,0, - SWATH_WIDTHS_MODIS=0,0, - N_SWATHS_CSCAL=0, - SWATH_LOCALTIMES_CSCAL=0,0, - SWATH_WIDTHS_CSCAL=0,0, - N_SWATHS_PARASOL=0, - SWATH_LOCALTIMES_PARASOL=0,0, - SWATH_WIDTHS_PARASOL=0,0, - N_SWATHS_ATLID=0, - SWATH_LOCALTIMES_ATLID=0,0, - SWATH_WIDTHS_ATLID=0,0, -/ diff --git a/driver/run/cosp2_input_rttov_nl.txt b/driver/run/cosp2_input_rttov_nl.txt deleted file mode 100644 index 78aff4e808..0000000000 --- a/driver/run/cosp2_input_rttov_nl.txt +++ /dev/null @@ -1,117 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&COSP_INPUT - NPOINTS=153,! Number of gridpoints 153,27840,7081,6912 - NPOINTS_IT=5000,! 50,5000, Max number of gridpoints to be processed in one iteration - NCOLUMNS=20, ! Number of subcolumns - NLEVELS=38, ! Number of model levels - USE_VGRID=.true., ! Use fixed vertical grid for outputs? (if .true. then you need to define number of levels with Nlr) - NLVGRID=40, ! Number of levels in statistical outputs (only used if USE_VGRID=.true.) - CSAT_VGRID=.true., ! CloudSat vertical grid? (if .true. then the CloudSat standard grid is used for the outputs. - ! USE_VGRID needs also be .true.) - DINPUT='./', ! Directory where the input files are located. Useful when processing multiple files. - ! Leave blank ('') if you are using the full path in FINPUT. - FINPUT='../data/inputs/UKMO/cosp_input_um.nc', ! List input NetCDF files - FOUTPUT='../data/outputs/UKMO/cosp2_output_rttov_um_bin.nc', - !---------------------------------------------------------------------------------- - !--------------- Inputs related to radar simulations - !---------------------------------------------------------------------------------- - cloudsat_RADAR_FREQ=94.0, ! CloudSat radar frequency (GHz) - SURFACE_RADAR=0, ! surface=1, spaceborne=0 - cloudsat_use_gas_abs=1, ! include gaseous absorption? yes=1,no=0 - cloudsat_do_ray=0, ! calculate/output Rayleigh refl=1, not=0 - cloudsat_k2=-1, ! |K|^2, -1=use frequency dependent default - use_precipitation_fluxes=.true., ! True if precipitation fluxes are input to the algorithm - cloudsat_micro_scheme='MMF_v3_single_moment', !'MMF_v3.5_two_moment' - !---------------------------------------------------------------------------------- - !---------------- Inputs related to lidar simulations - !---------------------------------------------------------------------------------- - lidar_ice_type=0, ! Ice particle shape in lidar calculations (0=ice-spheres ; 1=ice-non-spherical) - OVERLAP=3, ! overlap assumption used by scops: 1=max, 2=rand, 3=max/rand - !---------------------------------------------------------------------------------- - !---------------- Inputs related to ISCCP simulator - !---------------------------------------------------------------------------------- - ISCCP_TOPHEIGHT=1, ! 1 = adjust top height using both a computed - ! infrared brightness temperature and the visible - ! optical depth to adjust cloud top pressure. Note - ! that this calculation is most appropriate to compare - ! to ISCCP data during sunlit hours. - ! 2 = do not adjust top height, that is cloud top - ! pressure is the actual cloud top pressure - ! in the model - ! 3 = adjust top height using only the computed - ! infrared brightness temperature. Note that this - ! calculation is most appropriate to compare to ISCCP - ! IR only algortihm (i.e. you can compare to nighttime - ! ISCCP data with this option) - ISCCP_TOPHEIGHT_DIRECTION=2, ! direction for finding atmosphere pressure level - ! with interpolated temperature equal to the radiance - ! determined cloud-top temperature - ! 1 = find the *lowest* altitude (highest pressure) level - ! with interpolated temperature equal to the radiance - ! determined cloud-top temperature - ! 2 = find the *highest* altitude (lowest pressure) level - ! with interpolated temperature equal to the radiance - ! determined cloud-top temperature. This is the - ! default value since V4.0 of the ISCCP simulator. - ! ONLY APPLICABLE IF top_height EQUALS 1 or 3 - !---------------------------------------------------------------------------------- - !-------------- RTTOV inputs - !---------------------------------------------------------------------------------- -! rttov_Ninstruments=3, -! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt','instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt','instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt', - rttov_Ninstruments=7, - rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt','instrument_nls/cosp2_rttov_inst4.txt','instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt','instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt','instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt', -! rttov_Ninstruments=4, -! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt','instrument_nls/cosp2_rttov_inst4.txt', -! rttov_Ninstruments=3, -! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt', -! rttov_Ninstruments=1, -! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt', - rttov_verbose=.true. - !---------------------------------------------------------------------------------- - !-------------- Swathing inputs - !---------------------------------------------------------------------------------- - N_SWATHS_ISCCP=2, - SWATH_LOCALTIMES_ISCCP=5.25,18.0, - SWATH_WIDTHS_ISCCP=2000,2000, - N_SWATHS_MISR=2, - SWATH_LOCALTIMES_MISR=6.5,18.25, - SWATH_WIDTHS_MISR=2000,2000, - N_SWATHS_MODIS=2, - SWATH_LOCALTIMES_MODIS=5.75,13.5, - SWATH_WIDTHS_MODIS=2000,2000, - N_SWATHS_CSCAL=2, - SWATH_LOCALTIMES_CSCAL=6.75,19.25, - SWATH_WIDTHS_CSCAL=2000,2000, - N_SWATHS_PARASOL=2, - SWATH_LOCALTIMES_PARASOL=6.75,19, - SWATH_WIDTHS_PARASOL=2000,2000, - N_SWATHS_ATLID=2, - SWATH_LOCALTIMES_ATLID=7.25,19.5, - SWATH_WIDTHS_ATLID=2000,2000, -/ diff --git a/driver/run/cosp2_input_rttov_nl.um_global.txt b/driver/run/cosp2_input_rttov_nl.um_global.txt deleted file mode 100644 index 3c1916b49a..0000000000 --- a/driver/run/cosp2_input_rttov_nl.um_global.txt +++ /dev/null @@ -1,90 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&COSP_INPUT - NPOINTS=1728, ! 1728,6912 - NPOINTS_IT=250,! 250,1000 Max number of gridpoints to be processed in one iteration - NCOLUMNS=20, ! Number of subcolumns - NLEVELS=54, ! Number of model levels - USE_VGRID=.true., ! Use fixed vertical grid for outputs? (if .true. then you need to define number of levels with Nlr) - NLVGRID=40, ! Number of levels in statistical outputs (only used if USE_VGRID=.true.) - CSAT_VGRID=.true., ! CloudSat vertical grid? (if .true. then the CloudSat standard grid is used for the outputs. - ! USE_VGRID needs also be .true.) - DINPUT='./', ! Directory where the input files are located. Useful when processing multiple files. - ! Leave blank ('') if you are using the full path in FINPUT. - FINPUT='../data/inputs/UKMO/cosp_input.um_global.nc', ! List input NetCDF files - FOUTPUT='../data/outputs/UKMO/cosp2_output.um_global.nc', - !---------------------------------------------------------------------------------- - !--------------- Inputs related to radar simulations - !---------------------------------------------------------------------------------- - cloudsat_RADAR_FREQ=94.0, ! CloudSat radar frequency (GHz) - SURFACE_RADAR=0, ! surface=1, spaceborne=0 - cloudsat_use_gas_abs=1, ! include gaseous absorption? yes=1,no=0 - cloudsat_do_ray=0, ! calculate/output Rayleigh refl=1, not=0 - cloudsat_k2=-1, ! |K|^2, -1=use frequency dependent default - use_precipitation_fluxes=.true., ! True if precipitation fluxes are input to the algorithm - cloudsat_micro_scheme='MMF_v3_single_moment', !'MMF_v3.5_two_moment' - !---------------------------------------------------------------------------------- - !---------------- Inputs related to lidar simulations - !---------------------------------------------------------------------------------- - lidar_ice_type=0, ! Ice particle shape in lidar calculations (0=ice-spheres ; 1=ice-non-spherical) - OVERLAP=3, ! overlap assumption used by scops: 1=max, 2=rand, 3=max/rand - !---------------------------------------------------------------------------------- - !---------------- Inputs related to ISCCP simulator - !---------------------------------------------------------------------------------- - ISCCP_TOPHEIGHT=1, ! 1 = adjust top height using both a computed - ! infrared brightness temperature and the visible - ! optical depth to adjust cloud top pressure. Note - ! that this calculation is most appropriate to compare - ! to ISCCP data during sunlit hours. - ! 2 = do not adjust top height, that is cloud top - ! pressure is the actual cloud top pressure - ! in the model - ! 3 = adjust top height using only the computed - ! infrared brightness temperature. Note that this - ! calculation is most appropriate to compare to ISCCP - ! IR only algortihm (i.e. you can compare to nighttime - ! ISCCP data with this option) - ISCCP_TOPHEIGHT_DIRECTION=2, ! direction for finding atmosphere pressure level - ! with interpolated temperature equal to the radiance - ! determined cloud-top temperature - ! 1 = find the *lowest* altitude (highest pressure) level - ! with interpolated temperature equal to the radiance - ! determined cloud-top temperature - ! 2 = find the *highest* altitude (lowest pressure) level - ! with interpolated temperature equal to the radiance - ! determined cloud-top temperature. This is the - ! default value since V4.0 of the ISCCP simulator. - ! ONLY APPLICABLE IF top_height EQUALS 1 or 3 - !---------------------------------------------------------------------------------- - !-------------- RTTOV inputs - !---------------------------------------------------------------------------------- - rttov_Ninstruments=4, - rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt','instrument_nls/cosp2_rttov_inst2.txt','instrument_nls/cosp2_rttov_inst3.txt','instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt', -! rttov_Ninstruments=1, -! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt', - rttov_verbose=.true. -/ diff --git a/driver/run/cosp2_input_rttov_swathleak_nl.txt b/driver/run/cosp2_input_rttov_swathleak_nl.txt deleted file mode 100644 index 654898f015..0000000000 --- a/driver/run/cosp2_input_rttov_swathleak_nl.txt +++ /dev/null @@ -1,109 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&COSP_INPUT - NPOINTS=153,! Number of gridpoints 153,27840,7081,6912 - NPOINTS_IT=5000,! 50,5000, Max number of gridpoints to be processed in one iteration - NCOLUMNS=20, ! Number of subcolumns - NLEVELS=38, ! Number of model levels - USE_VGRID=.true., ! Use fixed vertical grid for outputs? (if .true. then you need to define number of levels with Nlr) - NLVGRID=40, ! Number of levels in statistical outputs (only used if USE_VGRID=.true.) - CSAT_VGRID=.true., ! CloudSat vertical grid? (if .true. then the CloudSat standard grid is used for the outputs. - ! USE_VGRID needs also be .true.) - DINPUT='./', ! Directory where the input files are located. Useful when processing multiple files. - ! Leave blank ('') if you are using the full path in FINPUT. - FINPUT='../data/inputs/UKMO/cosp_input_um.nc', ! List input NetCDF files - FOUTPUT='../data/outputs/UKMO/cosp2_output_rttov_um_bin.nc', - !---------------------------------------------------------------------------------- - !--------------- Inputs related to radar simulations - !---------------------------------------------------------------------------------- - cloudsat_RADAR_FREQ=94.0, ! CloudSat radar frequency (GHz) - SURFACE_RADAR=0, ! surface=1, spaceborne=0 - cloudsat_use_gas_abs=1, ! include gaseous absorption? yes=1,no=0 - cloudsat_do_ray=0, ! calculate/output Rayleigh refl=1, not=0 - cloudsat_k2=-1, ! |K|^2, -1=use frequency dependent default - use_precipitation_fluxes=.true., ! True if precipitation fluxes are input to the algorithm - cloudsat_micro_scheme='MMF_v3_single_moment', !'MMF_v3.5_two_moment' - !---------------------------------------------------------------------------------- - !---------------- Inputs related to lidar simulations - !---------------------------------------------------------------------------------- - lidar_ice_type=0, ! Ice particle shape in lidar calculations (0=ice-spheres ; 1=ice-non-spherical) - OVERLAP=3, ! overlap assumption used by scops: 1=max, 2=rand, 3=max/rand - !---------------------------------------------------------------------------------- - !---------------- Inputs related to ISCCP simulator - !---------------------------------------------------------------------------------- - ISCCP_TOPHEIGHT=1, ! 1 = adjust top height using both a computed - ! infrared brightness temperature and the visible - ! optical depth to adjust cloud top pressure. Note - ! that this calculation is most appropriate to compare - ! to ISCCP data during sunlit hours. - ! 2 = do not adjust top height, that is cloud top - ! pressure is the actual cloud top pressure - ! in the model - ! 3 = adjust top height using only the computed - ! infrared brightness temperature. Note that this - ! calculation is most appropriate to compare to ISCCP - ! IR only algortihm (i.e. you can compare to nighttime - ! ISCCP data with this option) - ISCCP_TOPHEIGHT_DIRECTION=2, ! direction for finding atmosphere pressure level - ! with interpolated temperature equal to the radiance - ! determined cloud-top temperature - ! 1 = find the *lowest* altitude (highest pressure) level - ! with interpolated temperature equal to the radiance - ! determined cloud-top temperature - ! 2 = find the *highest* altitude (lowest pressure) level - ! with interpolated temperature equal to the radiance - ! determined cloud-top temperature. This is the - ! default value since V4.0 of the ISCCP simulator. - ! ONLY APPLICABLE IF top_height EQUALS 1 or 3 - !---------------------------------------------------------------------------------- - !-------------- RTTOV inputs - !---------------------------------------------------------------------------------- - rttov_Ninstruments = 3, - rttov_instrument_namelists = 'instrument_nls/cosp2_rttov_AIRS_L1C_CESM2_des.txt','instrument_nls/cosp2_rttov_AIRS_L1C_CESM2_asc.txt','instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt', - rttov_verbose=.true. - !---------------------------------------------------------------------------------- - !-------------- Swathing inputs - !---------------------------------------------------------------------------------- - N_SWATHS_ISCCP=2, - SWATH_LOCALTIMES_ISCCP=5.25,18.0, - SWATH_WIDTHS_ISCCP=2000,2000, - N_SWATHS_MISR=2, - SWATH_LOCALTIMES_MISR=6.5,18.25, - SWATH_WIDTHS_MISR=2000,2000, - N_SWATHS_MODIS=2, - SWATH_LOCALTIMES_MODIS=5.75,13.5, - SWATH_WIDTHS_MODIS=2000,2000, - N_SWATHS_CSCAL=2, - SWATH_LOCALTIMES_CSCAL=6.75,19.25, - SWATH_WIDTHS_CSCAL=2000,2000, - N_SWATHS_PARASOL=2, - SWATH_LOCALTIMES_PARASOL=6.75,19, - SWATH_WIDTHS_PARASOL=2000,2000, - N_SWATHS_ATLID=2, - SWATH_LOCALTIMES_ATLID=7.25,19.5, - SWATH_WIDTHS_ATLID=2000,2000, -/ diff --git a/driver/run/cosp2_output_AIRS_L1C_nl.txt b/driver/run/cosp2_output_AIRS_L1C_nl.txt deleted file mode 100644 index 9726a5c6a7..0000000000 --- a/driver/run/cosp2_output_AIRS_L1C_nl.txt +++ /dev/null @@ -1,152 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -! Namelist that sets up output-related variables. It controls -! the instrument simulators to run and the list of variables -! to be written to file -&COSP_OUTPUT - !- CloudSat - Lcfaddbze94=.false., - Ldbze94=.false., - !- CALIPSO - Latb532=.false., - LcfadLidarsr532=.false., - Lclcalipso=.false., - Lclhcalipso=.false., - Lcllcalipso=.false., - Lclmcalipso=.false., - Lcltcalipso=.false., - LparasolRefl=.false., - ! CALIPSO phase diagnostics - Lclcalipsoliq=.false., - Lclcalipsoice=.false., - Lclcalipsoun=.false., - Lclcalipsotmp=.false., - Lclcalipsotmpliq=.false., - Lclcalipsotmpice=.false., - Lclcalipsotmpun=.false., - Lclhcalipsoliq=.false., - Lcllcalipsoliq=.false., - Lclmcalipsoliq=.false., - Lcltcalipsoliq=.false., - Lclhcalipsoice=.false., - Lcllcalipsoice=.false., - Lclmcalipsoice=.false., - Lcltcalipsoice=.false., - Lclhcalipsoun=.false., - Lcllcalipsoun=.false., - Lclmcalipsoun=.false., - Lcltcalipsoun=.false., - ! CALIPSO OPAQ diagnostics - Lclopaquecalipso=.false., - Lclthincalipso=.false., - Lclzopaquecalipso=.false., - Lclcalipsoopaque=.false., - Lclcalipsothin=.false., - Lclcalipsozopaque=.false., - Lclcalipsoopacity=.false., - Lclopaquetemp=.false., - Lclthintemp=.false., - Lclzopaquetemp=.false., - Lclopaquemeanz=.false., - Lclthinmeanz=.false., - Lclthinemis=.false., - Lclopaquemeanzse=.false., - Lclthinmeanzse=.false., - Lclzopaquecalipsose=.false., - ! GROUND LIDAR diagnostics - LlidarBetaMol532gr=.false., - LcfadLidarsr532gr=.false., - Latb532gr=.false., - LclgrLidar532=.false., - LclhgrLidar532=.false., - LcllgrLidar532=.false., - LclmgrLidar532=.false., - LcltgrLidar532=.false., - ! ATLID diagnostics - LlidarBetaMol355=.false., - LcfadLidarsr355=.false., - Latb355=.false., - Lclatlid=.false., - Lclhatlid=.false., - Lcllatlid=.false., - Lclmatlid=.false., - Lcltatlid=.false., - !- ISCCP - Lalbisccp=.false., - Lboxptopisccp=.false., - Lboxtauisccp=.false., - Lpctisccp=.false., - Lclisccp=.false., - Ltauisccp=.false., - Lcltisccp=.false., - Lmeantbisccp=.false., - Lmeantbclrisccp=.false., - !- MISR - LclMISR=.false., - !- Use lidar and radar - Lclcalipso2=.false., - Lcltlidarradar=.false., - Lcloudsat_tcc=.false., - Lcloudsat_tcc2=.false., - !- These are provided for debugging or special purposes - Lfracout=.false., - LlidarBetaMol532=.false., - !- MODIS - Lcltmodis=.false., - Lclwmodis=.false., - Lclimodis=.false., - Lclhmodis=.false., - Lclmmodis=.false., - Lcllmodis=.false., - Ltautmodis=.false., - Ltauwmodis=.false., - Ltauimodis=.false., - Ltautlogmodis=.false., - Ltauwlogmodis=.false., - Ltauilogmodis=.false., - Lreffclwmodis=.false., - Lreffclimodis=.false., - Lpctmodis=.false., - Llwpmodis=.false., - Liwpmodis=.false., - Lclmodis=.false., - !- RTTOV - Lrttov_run=.true., ! Run RTTOV? - ! -CLOUDSAT precipitation frequency/occurence diagnostics - Lptradarflag0=.false., - Lptradarflag1=.false., - Lptradarflag2=.false., - Lptradarflag3=.false., - Lptradarflag4=.false., - Lptradarflag5=.false., - Lptradarflag6=.false., - Lptradarflag7=.false., - Lptradarflag8=.false., - Lptradarflag9=.false., - Lradarpia=.false., - !- CloudSat+MODIS joint diagnostics - Lwr_occfreq=.false., - Lcfodd=.false. -/ diff --git a/driver/run/cosp2_output_iasi_nl.txt b/driver/run/cosp2_output_iasi_nl.txt deleted file mode 100644 index 9726a5c6a7..0000000000 --- a/driver/run/cosp2_output_iasi_nl.txt +++ /dev/null @@ -1,152 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -! Namelist that sets up output-related variables. It controls -! the instrument simulators to run and the list of variables -! to be written to file -&COSP_OUTPUT - !- CloudSat - Lcfaddbze94=.false., - Ldbze94=.false., - !- CALIPSO - Latb532=.false., - LcfadLidarsr532=.false., - Lclcalipso=.false., - Lclhcalipso=.false., - Lcllcalipso=.false., - Lclmcalipso=.false., - Lcltcalipso=.false., - LparasolRefl=.false., - ! CALIPSO phase diagnostics - Lclcalipsoliq=.false., - Lclcalipsoice=.false., - Lclcalipsoun=.false., - Lclcalipsotmp=.false., - Lclcalipsotmpliq=.false., - Lclcalipsotmpice=.false., - Lclcalipsotmpun=.false., - Lclhcalipsoliq=.false., - Lcllcalipsoliq=.false., - Lclmcalipsoliq=.false., - Lcltcalipsoliq=.false., - Lclhcalipsoice=.false., - Lcllcalipsoice=.false., - Lclmcalipsoice=.false., - Lcltcalipsoice=.false., - Lclhcalipsoun=.false., - Lcllcalipsoun=.false., - Lclmcalipsoun=.false., - Lcltcalipsoun=.false., - ! CALIPSO OPAQ diagnostics - Lclopaquecalipso=.false., - Lclthincalipso=.false., - Lclzopaquecalipso=.false., - Lclcalipsoopaque=.false., - Lclcalipsothin=.false., - Lclcalipsozopaque=.false., - Lclcalipsoopacity=.false., - Lclopaquetemp=.false., - Lclthintemp=.false., - Lclzopaquetemp=.false., - Lclopaquemeanz=.false., - Lclthinmeanz=.false., - Lclthinemis=.false., - Lclopaquemeanzse=.false., - Lclthinmeanzse=.false., - Lclzopaquecalipsose=.false., - ! GROUND LIDAR diagnostics - LlidarBetaMol532gr=.false., - LcfadLidarsr532gr=.false., - Latb532gr=.false., - LclgrLidar532=.false., - LclhgrLidar532=.false., - LcllgrLidar532=.false., - LclmgrLidar532=.false., - LcltgrLidar532=.false., - ! ATLID diagnostics - LlidarBetaMol355=.false., - LcfadLidarsr355=.false., - Latb355=.false., - Lclatlid=.false., - Lclhatlid=.false., - Lcllatlid=.false., - Lclmatlid=.false., - Lcltatlid=.false., - !- ISCCP - Lalbisccp=.false., - Lboxptopisccp=.false., - Lboxtauisccp=.false., - Lpctisccp=.false., - Lclisccp=.false., - Ltauisccp=.false., - Lcltisccp=.false., - Lmeantbisccp=.false., - Lmeantbclrisccp=.false., - !- MISR - LclMISR=.false., - !- Use lidar and radar - Lclcalipso2=.false., - Lcltlidarradar=.false., - Lcloudsat_tcc=.false., - Lcloudsat_tcc2=.false., - !- These are provided for debugging or special purposes - Lfracout=.false., - LlidarBetaMol532=.false., - !- MODIS - Lcltmodis=.false., - Lclwmodis=.false., - Lclimodis=.false., - Lclhmodis=.false., - Lclmmodis=.false., - Lcllmodis=.false., - Ltautmodis=.false., - Ltauwmodis=.false., - Ltauimodis=.false., - Ltautlogmodis=.false., - Ltauwlogmodis=.false., - Ltauilogmodis=.false., - Lreffclwmodis=.false., - Lreffclimodis=.false., - Lpctmodis=.false., - Llwpmodis=.false., - Liwpmodis=.false., - Lclmodis=.false., - !- RTTOV - Lrttov_run=.true., ! Run RTTOV? - ! -CLOUDSAT precipitation frequency/occurence diagnostics - Lptradarflag0=.false., - Lptradarflag1=.false., - Lptradarflag2=.false., - Lptradarflag3=.false., - Lptradarflag4=.false., - Lptradarflag5=.false., - Lptradarflag6=.false., - Lptradarflag7=.false., - Lptradarflag8=.false., - Lptradarflag9=.false., - Lradarpia=.false., - !- CloudSat+MODIS joint diagnostics - Lwr_occfreq=.false., - Lcfodd=.false. -/ diff --git a/driver/run/cosp2_output_pcrttov_nl.txt b/driver/run/cosp2_output_pcrttov_nl.txt deleted file mode 100644 index 9c8a349949..0000000000 --- a/driver/run/cosp2_output_pcrttov_nl.txt +++ /dev/null @@ -1,152 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -! Namelist that sets up output-related variables. It controls -! the instrument simulators to run and the list of variables -! to be written to file -&COSP_OUTPUT - !- CloudSat - Lcfaddbze94=.true., - Ldbze94=.true., - !- CALIPSO - Latb532=.true., - LcfadLidarsr532=.true., - Lclcalipso=.true., - Lclhcalipso=.true., - Lcllcalipso=.true., - Lclmcalipso=.true., - Lcltcalipso=.true., - LparasolRefl=.true., - ! CALIPSO phase diagnostics - Lclcalipsoliq=.true., - Lclcalipsoice=.true., - Lclcalipsoun=.true., - Lclcalipsotmp=.true., - Lclcalipsotmpliq=.true., - Lclcalipsotmpice=.true., - Lclcalipsotmpun=.true., - Lclhcalipsoliq=.true., - Lcllcalipsoliq=.true., - Lclmcalipsoliq=.true., - Lcltcalipsoliq=.true., - Lclhcalipsoice=.true., - Lcllcalipsoice=.true., - Lclmcalipsoice=.true., - Lcltcalipsoice=.true., - Lclhcalipsoun=.true., - Lcllcalipsoun=.true., - Lclmcalipsoun=.true., - Lcltcalipsoun=.true., - ! CALIPSO OPAQ diagnostics - Lclopaquecalipso=.true., - Lclthincalipso=.true., - Lclzopaquecalipso=.true., - Lclcalipsoopaque=.true., - Lclcalipsothin=.true., - Lclcalipsozopaque=.true., - Lclcalipsoopacity=.true., - Lclopaquetemp=.true., - Lclthintemp=.true., - Lclzopaquetemp=.true., - Lclopaquemeanz=.true., - Lclthinmeanz=.true., - Lclthinemis=.true., - Lclopaquemeanzse=.true., - Lclthinmeanzse=.true., - Lclzopaquecalipsose=.true., - ! GROUND LIDAR diagnostics - LlidarBetaMol532gr=.true., - LcfadLidarsr532gr=.true., - Latb532gr=.true., - LclgrLidar532=.true., - LclhgrLidar532=.true., - LcllgrLidar532=.true., - LclmgrLidar532=.true., - LcltgrLidar532=.true., - ! ATLID diagnostics - LlidarBetaMol355=.true., - LcfadLidarsr355=.true., - Latb355=.true., - Lclatlid=.true., - Lclhatlid=.true., - Lcllatlid=.true., - Lclmatlid=.true., - Lcltatlid=.true., - !- ISCCP - Lalbisccp=.true., - Lboxptopisccp=.true., - Lboxtauisccp=.true., - Lpctisccp=.true., - Lclisccp=.true., - Ltauisccp=.true., - Lcltisccp=.true., - Lmeantbisccp=.true., - Lmeantbclrisccp=.true., - !- MISR - LclMISR=.true., - !- Use lidar and radar - Lclcalipso2=.true., - Lcltlidarradar=.true., - Lcloudsat_tcc=.true., - Lcloudsat_tcc2=.true., - !- These are provided for debugging or special purposes - Lfracout=.true., - LlidarBetaMol532=.true., - !- MODIS - Lcltmodis=.true., - Lclwmodis=.true., - Lclimodis=.true., - Lclhmodis=.true., - Lclmmodis=.true., - Lcllmodis=.true., - Ltautmodis=.true., - Ltauwmodis=.true., - Ltauimodis=.true., - Ltautlogmodis=.true., - Ltauwlogmodis=.true., - Ltauilogmodis=.true., - Lreffclwmodis=.true., - Lreffclimodis=.true., - Lpctmodis=.true., - Llwpmodis=.true., - Liwpmodis=.true., - Lclmodis=.true., - !- RTTOV - Lrttov_run=.true., ! Run RTTOV? - ! -CLOUDSAT precipitation frequency/occurence diagnostics - Lptradarflag0=.true., - Lptradarflag1=.true., - Lptradarflag2=.true., - Lptradarflag3=.true., - Lptradarflag4=.true., - Lptradarflag5=.true., - Lptradarflag6=.true., - Lptradarflag7=.true., - Lptradarflag8=.true., - Lptradarflag9=.true., - Lradarpia=.true., - !- CloudSat+MODIS joint diagnostics - Lwr_occfreq=.true., - Lcfodd=.true. -/ diff --git a/driver/run/cosp2_output_rttov_nl.txt b/driver/run/cosp2_output_rttov_nl.txt deleted file mode 100755 index 9c8a349949..0000000000 --- a/driver/run/cosp2_output_rttov_nl.txt +++ /dev/null @@ -1,152 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -! Namelist that sets up output-related variables. It controls -! the instrument simulators to run and the list of variables -! to be written to file -&COSP_OUTPUT - !- CloudSat - Lcfaddbze94=.true., - Ldbze94=.true., - !- CALIPSO - Latb532=.true., - LcfadLidarsr532=.true., - Lclcalipso=.true., - Lclhcalipso=.true., - Lcllcalipso=.true., - Lclmcalipso=.true., - Lcltcalipso=.true., - LparasolRefl=.true., - ! CALIPSO phase diagnostics - Lclcalipsoliq=.true., - Lclcalipsoice=.true., - Lclcalipsoun=.true., - Lclcalipsotmp=.true., - Lclcalipsotmpliq=.true., - Lclcalipsotmpice=.true., - Lclcalipsotmpun=.true., - Lclhcalipsoliq=.true., - Lcllcalipsoliq=.true., - Lclmcalipsoliq=.true., - Lcltcalipsoliq=.true., - Lclhcalipsoice=.true., - Lcllcalipsoice=.true., - Lclmcalipsoice=.true., - Lcltcalipsoice=.true., - Lclhcalipsoun=.true., - Lcllcalipsoun=.true., - Lclmcalipsoun=.true., - Lcltcalipsoun=.true., - ! CALIPSO OPAQ diagnostics - Lclopaquecalipso=.true., - Lclthincalipso=.true., - Lclzopaquecalipso=.true., - Lclcalipsoopaque=.true., - Lclcalipsothin=.true., - Lclcalipsozopaque=.true., - Lclcalipsoopacity=.true., - Lclopaquetemp=.true., - Lclthintemp=.true., - Lclzopaquetemp=.true., - Lclopaquemeanz=.true., - Lclthinmeanz=.true., - Lclthinemis=.true., - Lclopaquemeanzse=.true., - Lclthinmeanzse=.true., - Lclzopaquecalipsose=.true., - ! GROUND LIDAR diagnostics - LlidarBetaMol532gr=.true., - LcfadLidarsr532gr=.true., - Latb532gr=.true., - LclgrLidar532=.true., - LclhgrLidar532=.true., - LcllgrLidar532=.true., - LclmgrLidar532=.true., - LcltgrLidar532=.true., - ! ATLID diagnostics - LlidarBetaMol355=.true., - LcfadLidarsr355=.true., - Latb355=.true., - Lclatlid=.true., - Lclhatlid=.true., - Lcllatlid=.true., - Lclmatlid=.true., - Lcltatlid=.true., - !- ISCCP - Lalbisccp=.true., - Lboxptopisccp=.true., - Lboxtauisccp=.true., - Lpctisccp=.true., - Lclisccp=.true., - Ltauisccp=.true., - Lcltisccp=.true., - Lmeantbisccp=.true., - Lmeantbclrisccp=.true., - !- MISR - LclMISR=.true., - !- Use lidar and radar - Lclcalipso2=.true., - Lcltlidarradar=.true., - Lcloudsat_tcc=.true., - Lcloudsat_tcc2=.true., - !- These are provided for debugging or special purposes - Lfracout=.true., - LlidarBetaMol532=.true., - !- MODIS - Lcltmodis=.true., - Lclwmodis=.true., - Lclimodis=.true., - Lclhmodis=.true., - Lclmmodis=.true., - Lcllmodis=.true., - Ltautmodis=.true., - Ltauwmodis=.true., - Ltauimodis=.true., - Ltautlogmodis=.true., - Ltauwlogmodis=.true., - Ltauilogmodis=.true., - Lreffclwmodis=.true., - Lreffclimodis=.true., - Lpctmodis=.true., - Llwpmodis=.true., - Liwpmodis=.true., - Lclmodis=.true., - !- RTTOV - Lrttov_run=.true., ! Run RTTOV? - ! -CLOUDSAT precipitation frequency/occurence diagnostics - Lptradarflag0=.true., - Lptradarflag1=.true., - Lptradarflag2=.true., - Lptradarflag3=.true., - Lptradarflag4=.true., - Lptradarflag5=.true., - Lptradarflag6=.true., - Lptradarflag7=.true., - Lptradarflag8=.true., - Lptradarflag9=.true., - Lradarpia=.true., - !- CloudSat+MODIS joint diagnostics - Lwr_occfreq=.true., - Lcfodd=.true. -/ diff --git a/driver/run/cosp2_output_rttov_swathleak_nl.txt b/driver/run/cosp2_output_rttov_swathleak_nl.txt deleted file mode 100644 index 9c8a349949..0000000000 --- a/driver/run/cosp2_output_rttov_swathleak_nl.txt +++ /dev/null @@ -1,152 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -! Namelist that sets up output-related variables. It controls -! the instrument simulators to run and the list of variables -! to be written to file -&COSP_OUTPUT - !- CloudSat - Lcfaddbze94=.true., - Ldbze94=.true., - !- CALIPSO - Latb532=.true., - LcfadLidarsr532=.true., - Lclcalipso=.true., - Lclhcalipso=.true., - Lcllcalipso=.true., - Lclmcalipso=.true., - Lcltcalipso=.true., - LparasolRefl=.true., - ! CALIPSO phase diagnostics - Lclcalipsoliq=.true., - Lclcalipsoice=.true., - Lclcalipsoun=.true., - Lclcalipsotmp=.true., - Lclcalipsotmpliq=.true., - Lclcalipsotmpice=.true., - Lclcalipsotmpun=.true., - Lclhcalipsoliq=.true., - Lcllcalipsoliq=.true., - Lclmcalipsoliq=.true., - Lcltcalipsoliq=.true., - Lclhcalipsoice=.true., - Lcllcalipsoice=.true., - Lclmcalipsoice=.true., - Lcltcalipsoice=.true., - Lclhcalipsoun=.true., - Lcllcalipsoun=.true., - Lclmcalipsoun=.true., - Lcltcalipsoun=.true., - ! CALIPSO OPAQ diagnostics - Lclopaquecalipso=.true., - Lclthincalipso=.true., - Lclzopaquecalipso=.true., - Lclcalipsoopaque=.true., - Lclcalipsothin=.true., - Lclcalipsozopaque=.true., - Lclcalipsoopacity=.true., - Lclopaquetemp=.true., - Lclthintemp=.true., - Lclzopaquetemp=.true., - Lclopaquemeanz=.true., - Lclthinmeanz=.true., - Lclthinemis=.true., - Lclopaquemeanzse=.true., - Lclthinmeanzse=.true., - Lclzopaquecalipsose=.true., - ! GROUND LIDAR diagnostics - LlidarBetaMol532gr=.true., - LcfadLidarsr532gr=.true., - Latb532gr=.true., - LclgrLidar532=.true., - LclhgrLidar532=.true., - LcllgrLidar532=.true., - LclmgrLidar532=.true., - LcltgrLidar532=.true., - ! ATLID diagnostics - LlidarBetaMol355=.true., - LcfadLidarsr355=.true., - Latb355=.true., - Lclatlid=.true., - Lclhatlid=.true., - Lcllatlid=.true., - Lclmatlid=.true., - Lcltatlid=.true., - !- ISCCP - Lalbisccp=.true., - Lboxptopisccp=.true., - Lboxtauisccp=.true., - Lpctisccp=.true., - Lclisccp=.true., - Ltauisccp=.true., - Lcltisccp=.true., - Lmeantbisccp=.true., - Lmeantbclrisccp=.true., - !- MISR - LclMISR=.true., - !- Use lidar and radar - Lclcalipso2=.true., - Lcltlidarradar=.true., - Lcloudsat_tcc=.true., - Lcloudsat_tcc2=.true., - !- These are provided for debugging or special purposes - Lfracout=.true., - LlidarBetaMol532=.true., - !- MODIS - Lcltmodis=.true., - Lclwmodis=.true., - Lclimodis=.true., - Lclhmodis=.true., - Lclmmodis=.true., - Lcllmodis=.true., - Ltautmodis=.true., - Ltauwmodis=.true., - Ltauimodis=.true., - Ltautlogmodis=.true., - Ltauwlogmodis=.true., - Ltauilogmodis=.true., - Lreffclwmodis=.true., - Lreffclimodis=.true., - Lpctmodis=.true., - Llwpmodis=.true., - Liwpmodis=.true., - Lclmodis=.true., - !- RTTOV - Lrttov_run=.true., ! Run RTTOV? - ! -CLOUDSAT precipitation frequency/occurence diagnostics - Lptradarflag0=.true., - Lptradarflag1=.true., - Lptradarflag2=.true., - Lptradarflag3=.true., - Lptradarflag4=.true., - Lptradarflag5=.true., - Lptradarflag6=.true., - Lptradarflag7=.true., - Lptradarflag8=.true., - Lptradarflag9=.true., - Lradarpia=.true., - !- CloudSat+MODIS joint diagnostics - Lwr_occfreq=.true., - Lcfodd=.true. -/ diff --git a/driver/run/cosp2_pcrttov_nl.txt b/driver/run/cosp2_pcrttov_nl.txt deleted file mode 100644 index 87f5d940d7..0000000000 --- a/driver/run/cosp2_pcrttov_nl.txt +++ /dev/null @@ -1,62 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=1000, ! 2300 - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_AIRS.csv', - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov9pred101L/rtcoef_eos_2_airs_pcrttov_compat.H5', - aer_coef_filepath='cldaer_visir/scaercoef_eos_2_airs_cams.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_airs.H5', - PC_coef_filepath='pc/pccoef_eos_2_airs_landsea.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.false., - CO_data=.false., - CO2_data=.true., - CH4_data=.false., - ozone_data=.true., - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - N2O_mr=4.665e-07, - CO_mr=2.098e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=16, - rttov_ZenAng=0.0, ! Satellite Zenith Angle -/ diff --git a/driver/run/cosp2_rttov_nl.txt b/driver/run/cosp2_rttov_nl.txt deleted file mode 100644 index 8d2e9a4dc9..0000000000 --- a/driver/run/cosp2_rttov_nl.txt +++ /dev/null @@ -1,59 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=-1, - !-------------- RTTOV Filepaths - channel_filepath='rttov_channel_input_AIRS.csv' - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/' - OD_coef_filepath='rttov13pred101L/rtcoef_eos_2_airs_7gas.H5', - aer_coef_filepath='cldaer_visir/scaercoef_eos_2_airs_cams.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_airs.H5', -! OD_coef_filepath='rttov13pred54L/rtcoef_ticfire_1_mbfiri_o3co2.dat', -! aer_coef_filepath='cldaer_visir/scaercoef_ticfire_1_mbfiri_cams.dat', -! cld_coef_filepath='cldaer_visir/sccldcoef_ticfire_1_mbfiri.dat', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.false., - CO_data=.false., - CO2_data=.true., - CH4_data=.false., - ozone_data=.true., - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - N2O_mr=4.665e-07, - CO_mr=2.098e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=16, - rttov_ZenAng=0.0, ! Satellite Zenith Angle -/ diff --git a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2.txt deleted file mode 100644 index 31546c17f7..0000000000 --- a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2.txt +++ /dev/null @@ -1,85 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.true., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=45, ! 2645 for all AIRS L1C channels, 45 channel subset mostly from Sergio - !-------------- RTTOV Filepaths - Lchannel_filepath=.true., - channel_filepath='rttov_channel_input_AIRSL1C_subset.csv' - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - ! OD_coef_filepath='AIRS_L1C/rtcoef_eos_2_airs_l1c_o3co2.H5', - OD_coef_filepath='AIRS_L1C/rtcoef_eos_2_airs_l1c_7gas.H5', ! Full version with N20 and CH4 - cld_coef_filepath='AIRS_L1C/sccldcoef_eos_2_airs_l1c.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., ! .true. for 7gas - CO_data=.false., - CO2_data=.true., - CH4_data=.true., ! .true. for 7gas - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=6.09e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_ZenAng=0.0, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) - ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) - rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. - rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. - rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. - ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. -/ diff --git a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2_asc.txt b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2_asc.txt deleted file mode 100644 index 862ba412a8..0000000000 --- a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2_asc.txt +++ /dev/null @@ -1,85 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.true., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=45, ! 2645 for all AIRS L1C channels, 45 channel subset mostly from Sergio - !-------------- RTTOV Filepaths - Lchannel_filepath=.true., - channel_filepath='rttov_channel_input_AIRSL1C_subset.csv' - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - ! OD_coef_filepath='AIRS_L1C/rtcoef_eos_2_airs_l1c_o3co2.H5', - OD_coef_filepath='AIRS_L1C/rtcoef_eos_2_airs_l1c_7gas.H5', ! Full version with N20 and CH4 - cld_coef_filepath='AIRS_L1C/sccldcoef_eos_2_airs_l1c.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., ! .true. for 7gas - CO_data=.false., - CO2_data=.true., - CH4_data=.true., ! .true. for 7gas - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=6.09e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air - rttov_ZenAng=0.0, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=1, ! Number of local times to sample at - rttov_localtime=13.5, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1800, ! Swath width (km) - ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) - rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. - rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. - rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. - ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. -/ diff --git a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2_des.txt b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2_des.txt deleted file mode 100644 index 14e1c158b8..0000000000 --- a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_CESM2_des.txt +++ /dev/null @@ -1,85 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.true., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=45, ! 2645 for all AIRS L1C channels, 45 channel subset mostly from Sergio - !-------------- RTTOV Filepaths - Lchannel_filepath=.true., - channel_filepath='rttov_channel_input_AIRSL1C_subset.csv' - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - ! OD_coef_filepath='AIRS_L1C/rtcoef_eos_2_airs_l1c_o3co2.H5', - OD_coef_filepath='AIRS_L1C/rtcoef_eos_2_airs_l1c_7gas.H5', ! Full version with N20 and CH4 - cld_coef_filepath='AIRS_L1C/sccldcoef_eos_2_airs_l1c.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., ! .true. for 7gas - CO_data=.false., - CO2_data=.true., - CH4_data=.true., ! .true. for 7gas - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=6.09e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air - rttov_ZenAng=0.0, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=1, ! Number of local times to sample at - rttov_localtime=1.5, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1800, ! Swath width (km) - ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) - rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. - rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. - rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. - ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. -/ diff --git a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_SCAMval.txt b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_SCAMval.txt deleted file mode 100644 index c677abd5a6..0000000000 --- a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_SCAMval.txt +++ /dev/null @@ -1,84 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.true., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=2645, ! 2645 for all AIRS L1C channels, could limit just to those that overlap RRTMG channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_AIRS.csv' - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='AIRS_L1C/rtcoef_eos_2_airs_l1c_7gas.H5', ! Full version with N20 and CH4 - cld_coef_filepath='AIRS_L1C/sccldcoef_eos_2_airs_l1c.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., - CO_data=.false., - CO2_data=.true., - CH4_data=.true., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=6.09e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_ZenAng=0.0, ! Satellite Zenith Angle, was 76.2 - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) - ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) - rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. - rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. - rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. - ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. -/ diff --git a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val1.txt b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val1.txt deleted file mode 100644 index 8c3500f101..0000000000 --- a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val1.txt +++ /dev/null @@ -1,75 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.true., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=2645, ! 2645 for all AIRS L1C channels, could limit just to those that overlap RRTMG channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_AIRS.csv' - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='AIRS_L1C/rtcoef_eos_2_airs_l1c_o3co2.H5', - cld_coef_filepath='AIRS_L1C/sccldcoef_eos_2_airs_l1c.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.false., - CO_data=.false., - CO2_data=.true., - CH4_data=.false., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.true., ! Have RTTOV use the trace gas concentrations below - CO2_mr=6.09e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_ZenAng=0.0, ! Satellite Zenith Angle, was 76.2 - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) -/ diff --git a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val2.txt b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val2.txt deleted file mode 100644 index 05c090cc5b..0000000000 --- a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val2.txt +++ /dev/null @@ -1,75 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.true., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=2645, ! 2645 for all AIRS L1C channels, could limit just to those that overlap RRTMG channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_AIRS.csv' - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='AIRS_L1C/rtcoef_eos_2_airs_l1c_o3co2.H5', - cld_coef_filepath='AIRS_L1C/sccldcoef_eos_2_airs_l1c.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.false., - CO_data=.false., - CO2_data=.true., - CH4_data=.false., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.true., ! Have RTTOV use the trace gas concentrations below - CO2_mr=6.09e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_ZenAng=20.0, ! Satellite Zenith Angle, was 76.2 - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) -/ diff --git a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val3.txt b/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val3.txt deleted file mode 100644 index 1d167989f5..0000000000 --- a/driver/run/instrument_nls/cosp2_rttov_AIRS_L1C_val3.txt +++ /dev/null @@ -1,79 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.true., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=2645, ! 2645 for all AIRS L1C channels, could limit just to those that overlap RRTMG channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_AIRS.csv' - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='AIRS_L1C/rtcoef_eos_2_airs_l1c_o3co2.H5', - cld_coef_filepath='AIRS_L1C/sccldcoef_eos_2_airs_l1c.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.false., - CO_data=.false., - CO2_data=.true., - CH4_data=.false., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.true., ! Have RTTOV use the trace gas concentrations below - CO2_mr=6.09e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_ZenAng=45.0, ! Satellite Zenith Angle, was 76.2 - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) - ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. -/ diff --git a/driver/run/instrument_nls/cosp2_rttov_FORUM_CESM2_val1.txt b/driver/run/instrument_nls/cosp2_rttov_FORUM_CESM2_val1.txt deleted file mode 100644 index 5a065ec072..0000000000 --- a/driver/run/instrument_nls/cosp2_rttov_FORUM_CESM2_val1.txt +++ /dev/null @@ -1,75 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.false., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=5001, ! 5001 for all FORUM channels, could limit just to those that overlap RRTMG channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_IASI_subset.csv', ! Doesn't matter if producing all channels - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov13pred101L/rtcoef_forum_1_forum_7gas.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_forum_1_forum.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., - CO_data=.false., - CO2_data=.true., - CH4_data=.true., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_ZenAng=13.81, ! Satellite Zenith Angle, was 76.2 - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) -/ diff --git a/driver/run/instrument_nls/cosp2_rttov_FORUM_CESM2_val2.txt b/driver/run/instrument_nls/cosp2_rttov_FORUM_CESM2_val2.txt deleted file mode 100644 index d2a11069a0..0000000000 --- a/driver/run/instrument_nls/cosp2_rttov_FORUM_CESM2_val2.txt +++ /dev/null @@ -1,75 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.false., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=5001, ! 5001 for all FORUM channels, could limit just to those that overlap RRTMG channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_IASI_subset.csv', ! Doesn't matter if producing all channels - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov13pred101L/rtcoef_forum_1_forum_7gas.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_forum_1_forum.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., - CO_data=.false., - CO2_data=.true., - CH4_data=.true., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_ZenAng=41.39, !48.6, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) -/ diff --git a/driver/run/instrument_nls/cosp2_rttov_FORUM_CESM2_val3.txt b/driver/run/instrument_nls/cosp2_rttov_FORUM_CESM2_val3.txt deleted file mode 100644 index a429ae8c6c..0000000000 --- a/driver/run/instrument_nls/cosp2_rttov_FORUM_CESM2_val3.txt +++ /dev/null @@ -1,75 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.false., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=5001, ! 5001 for all FORUM channels, could limit just to those that overlap RRTMG channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_IASI_subset.csv', ! Doesn't matter if producing all channels - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov13pred101L/rtcoef_forum_1_forum_7gas.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_forum_1_forum.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., - CO_data=.false., - CO2_data=.true., - CH4_data=.true., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_ZenAng=68.82, !64.98, !21.2, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) -/ diff --git a/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val.txt b/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val.txt deleted file mode 100644 index 0f1fb10b87..0000000000 --- a/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val.txt +++ /dev/null @@ -1,78 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.false., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.true., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_AIRS.csv' -! channel_filepath='rttov_channel_input_IASI_subset.csv', - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov13pred101L/rtcoef_metop_2_iasi_7gas.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., - CO_data=.false., - CO2_data=.true., - CH4_data=.true., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_ZenAng=0.0, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) -/ diff --git a/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val1.txt b/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val1.txt deleted file mode 100644 index 26c944d10c..0000000000 --- a/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val1.txt +++ /dev/null @@ -1,78 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.false., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.true., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_AIRS.csv' -! channel_filepath='rttov_channel_input_IASI_subset.csv', - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov13pred101L/rtcoef_metop_2_iasi_7gas.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., - CO_data=.false., - CO2_data=.true., - CH4_data=.true., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.true., ! have rttov use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_ZenAng=13.81, ! Satellite Zenith Angle, was 76.2 - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) -/ diff --git a/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val2.txt b/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val2.txt deleted file mode 100644 index 70fef75aa3..0000000000 --- a/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val2.txt +++ /dev/null @@ -1,78 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.false., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.true., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_AIRS.csv' -! channel_filepath='rttov_channel_input_IASI_subset.csv', - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov13pred101L/rtcoef_metop_2_iasi_7gas.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., - CO_data=.false., - CO2_data=.true., - CH4_data=.true., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_ZenAng=41.39, !48.6, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) -/ diff --git a/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val3.txt b/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val3.txt deleted file mode 100644 index 9bc8481252..0000000000 --- a/driver/run/instrument_nls/cosp2_rttov_IASI_CESM2_val3.txt +++ /dev/null @@ -1,78 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.false., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.true., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_AIRS.csv' -! channel_filepath='rttov_channel_input_IASI_subset.csv', - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov13pred101L/rtcoef_metop_2_iasi_7gas.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., - CO_data=.false., - CO2_data=.true., - CH4_data=.true., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_ZenAng=68.82, !64.98, !21.2, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) -/ diff --git a/driver/run/instrument_nls/cosp2_rttov_inst1.txt b/driver/run/instrument_nls/cosp2_rttov_inst1.txt deleted file mode 100644 index 2b8dd9afe9..0000000000 --- a/driver/run/instrument_nls/cosp2_rttov_inst1.txt +++ /dev/null @@ -1,85 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.true., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.true., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_pc=.false., ! Run with PC-RTTOV - Lrttov_solar=.true., ! Do solar calculations - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=0, ! 2300 - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_AIRS.csv', - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov13pred54L/rtcoef_eos_2_modis-shifted_7gas.dat', - aer_coef_filepath='cldaer_visir/scaercoef_eos_2_modis-shifted_cams.dat', - cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_modis-shifted.dat', -! OD_coef_filepath='rttov9pred101L/rtcoef_eos_2_airs_pcrttov_compat.H5', -! aer_coef_filepath='cldaer_visir/scaercoef_eos_2_airs_cams.H5', -! cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_airs.H5', - PC_coef_filepath='pc/pccoef_eos_2_airs_landsea.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.false., - CO_data=.false., - CO2_data=.true., - CH4_data=.false., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_ZenAng=0.0, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) - rttov_clw_scheme=2, - rttov_ice_scheme=2, - rttov_icede_param=2, - ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. -/ diff --git a/driver/run/instrument_nls/cosp2_rttov_inst2.txt b/driver/run/instrument_nls/cosp2_rttov_inst2.txt deleted file mode 100644 index e97960a366..0000000000 --- a/driver/run/instrument_nls/cosp2_rttov_inst2.txt +++ /dev/null @@ -1,80 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.true., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=0, ! do all - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_AIRS.csv', - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov9pred101L/rtcoef_eos_2_airs_pcrttov_compat.H5', - aer_coef_filepath='cldaer_visir/scaercoef_eos_2_airs_cams.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_airs.H5', -! OD_coef_filepath='rttov13pred54L/rtcoef_ticfire_1_mbfiri_o3co2.dat', -! aer_coef_filepath='cldaer_visir/scaercoef_ticfire_1_mbfiri_cams.dat', -! cld_coef_filepath='cldaer_visir/sccldcoef_ticfire_1_mbfiri.dat', - PC_coef_filepath='pc/pccoef_eos_2_airs_landsea.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.false., - CO_data=.false., - CO2_data=.true., - CH4_data=.false., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=16, - rttov_ZenAng=0.0, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=2, ! Number of local times to sample at - rttov_localtime=0.75,13.5, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=2.e3,5.6e3, ! Swath width (km) -/ diff --git a/driver/run/instrument_nls/cosp2_rttov_inst3.txt b/driver/run/instrument_nls/cosp2_rttov_inst3.txt deleted file mode 100644 index 9fab30f0c8..0000000000 --- a/driver/run/instrument_nls/cosp2_rttov_inst3.txt +++ /dev/null @@ -1,77 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.true., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_pc=.true., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=0, ! 2300 - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_AIRS.csv', - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov9pred101L/rtcoef_eos_2_airs_pcrttov_compat.H5', - aer_coef_filepath='cldaer_visir/scaercoef_eos_2_airs_cams.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_airs.H5', - PC_coef_filepath='pc/pccoef_eos_2_airs_landsea.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.false., - CO_data=.false., - CO2_data=.true., - CH4_data=.false., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=16, - rttov_ZenAng=0.0, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=2, ! Number of local times to sample at - rttov_localtime=0.75,13.5, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=2.e3,5.6e3, ! Swath width (km) -/ diff --git a/driver/run/instrument_nls/cosp2_rttov_inst4.txt b/driver/run/instrument_nls/cosp2_rttov_inst4.txt deleted file mode 100644 index 80316408bb..0000000000 --- a/driver/run/instrument_nls/cosp2_rttov_inst4.txt +++ /dev/null @@ -1,79 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -! Simulate MODIS, but just channels 20-36, removing 26 - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.true., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=16, ! 2300 - !-------------- RTTOV Filepaths - Lchannel_filepath=.true., - channel_filepath='rttov_channel_input_MODIS16.csv', - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov13pred54L/rtcoef_eos_2_modis-shifted_7gas.dat', - aer_coef_filepath='cldaer_visir/scaercoef_eos_2_modis-shifted_cams.dat', - cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_modis-shifted.dat', -! OD_coef_filepath='rttov9pred101L/rtcoef_eos_2_airs_pcrttov_compat.H5', -! aer_coef_filepath='cldaer_visir/scaercoef_eos_2_airs_cams.H5', -! cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_airs.H5', - PC_coef_filepath='pc/pccoef_eos_2_airs_landsea.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.false., - CO_data=.false., - CO2_data=.true., - CH4_data=.false., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=16, - rttov_ZenAng=0.0, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at -/ diff --git a/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt deleted file mode 100644 index 0826cfaae8..0000000000 --- a/driver/run/instrument_nls/cosp2_rttov_inst5_PREFIRE_CESM2.txt +++ /dev/null @@ -1,89 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.false., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_pc=.false., ! Run with PC-RTTOV - Lrttov_solar=.false., ! Do solar calculations - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=55, ! - !-------------- RTTOV Filepaths - Lchannel_filepath=.true., - channel_filepath='rttov_channel_input_PREFIRE_subset.csv', - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='PREFIRE/rtcoef_prefire_1_tirs_o3co2.dat', - cld_coef_filepath='PREFIRE/sccldcoef_prefire_1_tirs.dat', -! aer_coef_filepath='cldaer_visir/scaercoef_eos_2_modis-shifted_cams.dat', -! cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_modis-shifted.dat', -! OD_coef_filepath='rttov9pred101L/rtcoef_eos_2_airs_pcrttov_compat.H5', -! aer_coef_filepath='cldaer_visir/scaercoef_eos_2_airs_cams.H5', -! cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_airs.H5', - PC_coef_filepath='pc/pccoef_eos_2_airs_landsea.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.false., - CO_data=.false., - CO2_data=.true., - CH4_data=.false., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air - rttov_ZenAng=0.0, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=6.75,19.25, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=15000,2000, ! Swath width (km) - ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) - rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. - rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. - rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. - ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. -/ diff --git a/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2.txt deleted file mode 100644 index cd247daf05..0000000000 --- a/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2.txt +++ /dev/null @@ -1,86 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.true., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=26, ! do a selection of AIRS channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.true., - channel_filepath='rttov_channel_input_AIRS_subset.csv', - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov13pred101L/rtcoef_eos_2_airs_7gas.H5', - aer_coef_filepath='cldaer_visir/scaercoef_eos_2_airs_cams.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_eos_2_airs.H5', -! OD_coef_filepath='rttov13pred54L/rtcoef_ticfire_1_mbfiri_o3co2.dat', -! aer_coef_filepath='cldaer_visir/scaercoef_ticfire_1_mbfiri_cams.dat', -! cld_coef_filepath='cldaer_visir/sccldcoef_ticfire_1_mbfiri.dat', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., - CO_data=.false., - CO2_data=.true., - CH4_data=.true., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air - rttov_ZenAng=0.0, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at -! rttov_localtime=0.75,13.5, ! Local times to sample at in hrs [0,24] -! rttov_localtime_width=2.e3,5.6e3, ! Swath width (km) - ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) - rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. - rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. - rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. - ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. -/ diff --git a/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt b/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt deleted file mode 100644 index 1e3970eba9..0000000000 --- a/driver/run/instrument_nls/cosp2_rttov_inst6_AIRS_CESM2_bin.txt +++ /dev/null @@ -1,84 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.true., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=26, ! do a selection of AIRS channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.true., - channel_filepath='rttov_channel_input_AIRS_subset.csv', - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='AIRS_alt/rtcoef_eos_2_airs_7gas.bin', - cld_coef_filepath='AIRS_alt/sccldcoef_eos_2_airs.bin', -! OD_coef_filepath='AIRS_alt/rtcoef_eos_2_airs_7gas.dat', -! cld_coef_filepath='AIRS_alt/sccldcoef_eos_2_airs.dat', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., - CO_data=.false., - CO2_data=.true., - CH4_data=.true., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air - rttov_ZenAng=0.0, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=2, ! Number of local times to sample at - rttov_localtime=5.75,13.5, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=2000,2000, ! Swath width (km) - ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) - rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. - rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. - rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. - ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. -/ diff --git a/driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt b/driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt deleted file mode 100644 index 0ee8381032..0000000000 --- a/driver/run/instrument_nls/cosp2_rttov_inst7_VIIRS_CESM2.txt +++ /dev/null @@ -1,87 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.true., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.true., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_pc=.false., ! Run with PC-RTTOV - Lrttov_solar=.true., ! Do solar calculations - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=2, ! do a selection of VIIRS channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.true., - channel_filepath='rttov_channel_input_VIIRS_subset.csv', - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='/rttov13pred54L/rtcoef_noaa_21_viirs_7gas.dat', - aer_coef_filepath='/cldaer_visir/scaercoef_noaa_21_viirs_cams.dat', - cld_coef_filepath='cldaer_visir/sccldcoef_noaa_21_viirs.dat', -! OD_coef_filepath='rttov13pred54L/rtcoef_ticfire_1_mbfiri_o3co2.dat', -! aer_coef_filepath='cldaer_visir/scaercoef_ticfire_1_mbfiri_cams.dat', -! cld_coef_filepath='cldaer_visir/sccldcoef_ticfire_1_mbfiri.dat', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., - CO_data=.false., - CO2_data=.true., - CH4_data=.true., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air - rttov_ZenAng=0.0, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=5.75,13.5, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=2000,2000, ! Swath width (km) - ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) - rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. - rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. - rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. - ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. -/ diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_input_rrtmg_6stream_validation_nl.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_input_rrtmg_6stream_validation_nl.txt deleted file mode 100644 index b58f668e59..0000000000 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_input_rrtmg_6stream_validation_nl.txt +++ /dev/null @@ -1,110 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&COSP_INPUT - NPOINTS=153,! Number of gridpoints 153,27840,7081,6912 - NPOINTS_IT=2,! 50,5000, Max number of gridpoints to be processed in one iteration - NCOLUMNS=20, ! Number of subcolumns - NLEVELS=38, ! Number of model levels - USE_VGRID=.true., ! Use fixed vertical grid for outputs? (if .true. then you need to define number of levels with Nlr) - NLVGRID=40, ! Number of levels in statistical outputs (only used if USE_VGRID=.true.) - CSAT_VGRID=.true., ! CloudSat vertical grid? (if .true. then the CloudSat standard grid is used for the outputs. - ! USE_VGRID needs also be .true.) - DINPUT='./', ! Directory where the input files are located. Useful when processing multiple files. - ! Leave blank ('') if you are using the full path in FINPUT. - FINPUT='../data/inputs/UKMO/cosp_input_um.nc', ! List input NetCDF files - FOUTPUT='../data/outputs/UKMO/cosp2_output_um_iasi.nc', - !---------------------------------------------------------------------------------- - !--------------- Inputs related to radar simulations - !---------------------------------------------------------------------------------- - cloudsat_RADAR_FREQ=94.0, ! CloudSat radar frequency (GHz) - SURFACE_RADAR=0, ! surface=1, spaceborne=0 - cloudsat_use_gas_abs=1, ! include gaseous absorption? yes=1,no=0 - cloudsat_do_ray=0, ! calculate/output Rayleigh refl=1, not=0 - cloudsat_k2=-1, ! |K|^2, -1=use frequency dependent default - use_precipitation_fluxes=.true., ! True if precipitation fluxes are input to the algorithm - cloudsat_micro_scheme='MMF_v3_single_moment', !'MMF_v3.5_two_moment' - !---------------------------------------------------------------------------------- - !---------------- Inputs related to lidar simulations - !---------------------------------------------------------------------------------- - lidar_ice_type=0, ! Ice particle shape in lidar calculations (0=ice-spheres ; 1=ice-non-spherical) - OVERLAP=3, ! overlap assumption used by scops: 1=max, 2=rand, 3=max/rand - !---------------------------------------------------------------------------------- - !---------------- Inputs related to ISCCP simulator - !---------------------------------------------------------------------------------- - ISCCP_TOPHEIGHT=1, ! 1 = adjust top height using both a computed - ! infrared brightness temperature and the visible - ! optical depth to adjust cloud top pressure. Note - ! that this calculation is most appropriate to compare - ! to ISCCP data during sunlit hours. - ! 2 = do not adjust top height, that is cloud top - ! pressure is the actual cloud top pressure - ! in the model - ! 3 = adjust top height using only the computed - ! infrared brightness temperature. Note that this - ! calculation is most appropriate to compare to ISCCP - ! IR only algortihm (i.e. you can compare to nighttime - ! ISCCP data with this option) - ISCCP_TOPHEIGHT_DIRECTION=2, ! direction for finding atmosphere pressure level - ! with interpolated temperature equal to the radiance - ! determined cloud-top temperature - ! 1 = find the *lowest* altitude (highest pressure) level - ! with interpolated temperature equal to the radiance - ! determined cloud-top temperature - ! 2 = find the *highest* altitude (lowest pressure) level - ! with interpolated temperature equal to the radiance - ! determined cloud-top temperature. This is the - ! default value since V4.0 of the ISCCP simulator. - ! ONLY APPLICABLE IF top_height EQUALS 1 or 3 - !---------------------------------------------------------------------------------- - !-------------- RTTOV inputs - !---------------------------------------------------------------------------------- - ! Simulating six IASI instruments and six FORUM instruments - rttov_Ninstruments=12, - rttov_instrument_namelists='instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt','instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt','instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt','instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt','instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt','instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt','instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt','instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt','instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt','instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt','instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt','instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt', - rttov_verbose=.true. - !---------------------------------------------------------------------------------- - !-------------- Swathing inputs - !---------------------------------------------------------------------------------- - N_SWATHS_ISCCP=0, - SWATH_LOCALTIMES_ISCCP=0,0, - SWATH_WIDTHS_ISCCP=0,0, - N_SWATHS_MISR=0, - SWATH_LOCALTIMES_MISR=0,0, - SWATH_WIDTHS_MISR=0,0, - N_SWATHS_MODIS=0, - SWATH_LOCALTIMES_MODIS=0,0, - SWATH_WIDTHS_MODIS=0,0, - N_SWATHS_CSCAL=0, - SWATH_LOCALTIMES_CSCAL=0,0, - SWATH_WIDTHS_CSCAL=0,0, - N_SWATHS_PARASOL=0, - SWATH_LOCALTIMES_PARASOL=0,0, - SWATH_WIDTHS_PARASOL=0,0, - N_SWATHS_ATLID=0, - SWATH_LOCALTIMES_ATLID=0,0, - SWATH_WIDTHS_ATLID=0,0, -/ diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt deleted file mode 100644 index 59ac2ba8bb..0000000000 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza1.txt +++ /dev/null @@ -1,84 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.false., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=5001, ! 5001 for all FORUM channels, could limit just to those that overlap RRTMG channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_IASI_subset.csv', ! Doesn't matter if producing all channels - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov13pred101L/rtcoef_forum_1_forum_7gas.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_forum_1_forum.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., - CO_data=.false., - CO2_data=.true., - CH4_data=.true., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air - rttov_ZenAng=7.19, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) - ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) - rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. - rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. - rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. - ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. -/ diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt deleted file mode 100644 index f9ce5e772b..0000000000 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza2.txt +++ /dev/null @@ -1,84 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.false., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=5001, ! 5001 for all FORUM channels, could limit just to those that overlap RRTMG channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_IASI_subset.csv', ! Doesn't matter if producing all channels - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov13pred101L/rtcoef_forum_1_forum_7gas.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_forum_1_forum.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., - CO_data=.false., - CO2_data=.true., - CH4_data=.true., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air - rttov_ZenAng=21.58, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) - ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) - rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. - rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. - rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. - ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. -/ diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt deleted file mode 100644 index 9dcbe9f23f..0000000000 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza3.txt +++ /dev/null @@ -1,84 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.false., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=5001, ! 5001 for all FORUM channels, could limit just to those that overlap RRTMG channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_IASI_subset.csv', ! Doesn't matter if producing all channels - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov13pred101L/rtcoef_forum_1_forum_7gas.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_forum_1_forum.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., - CO_data=.false., - CO2_data=.true., - CH4_data=.true., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air - rttov_ZenAng=35.97, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) - ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) - rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. - rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. - rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. - ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. -/ diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt deleted file mode 100644 index bd8953f7bc..0000000000 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza4.txt +++ /dev/null @@ -1,84 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.false., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=5001, ! 5001 for all FORUM channels, could limit just to those that overlap RRTMG channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_IASI_subset.csv', ! Doesn't matter if producing all channels - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov13pred101L/rtcoef_forum_1_forum_7gas.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_forum_1_forum.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., - CO_data=.false., - CO2_data=.true., - CH4_data=.true., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air - rttov_ZenAng=50.34, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) - ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) - rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. - rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. - rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. - ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. -/ diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt deleted file mode 100644 index 63a30d0ca2..0000000000 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza5.txt +++ /dev/null @@ -1,84 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.false., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=5001, ! 5001 for all FORUM channels, could limit just to those that overlap RRTMG channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_IASI_subset.csv', ! Doesn't matter if producing all channels - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov13pred101L/rtcoef_forum_1_forum_7gas.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_forum_1_forum.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., - CO_data=.false., - CO2_data=.true., - CH4_data=.true., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air - rttov_ZenAng=64.71, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) - ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) - rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. - rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. - rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. - ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. -/ diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt deleted file mode 100644 index 6f6ea7ed43..0000000000 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_FORUM_CESM2_vza6.txt +++ /dev/null @@ -1,84 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.false., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=5001, ! 5001 for all FORUM channels, could limit just to those that overlap RRTMG channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_IASI_subset.csv', ! Doesn't matter if producing all channels - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov13pred101L/rtcoef_forum_1_forum_7gas.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_forum_1_forum.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., - CO_data=.false., - CO2_data=.true., - CH4_data=.true., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air - rttov_ZenAng=78.98, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) - ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) - rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. - rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. - rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. - ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. -/ diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt deleted file mode 100644 index ef0acdaac2..0000000000 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza1.txt +++ /dev/null @@ -1,85 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.false., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_AIRS.csv' -! channel_filepath='rttov_channel_input_IASI_subset.csv', - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov13pred101L/rtcoef_metop_2_iasi_7gas.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., - CO_data=.false., - CO2_data=.true., - CH4_data=.true., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air - rttov_ZenAng=7.19, ! Satellite Zenith Angle, was 76.2 - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) - ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) - rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. - rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. - rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. - ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. -/ diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt deleted file mode 100644 index fdda705a9c..0000000000 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza2.txt +++ /dev/null @@ -1,85 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.false., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_AIRS.csv' -! channel_filepath='rttov_channel_input_IASI_subset.csv', - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov13pred101L/rtcoef_metop_2_iasi_7gas.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., - CO_data=.false., - CO2_data=.true., - CH4_data=.true., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air - rttov_ZenAng=21.58, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) - ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) - rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. - rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. - rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. - ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. -/ diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt deleted file mode 100644 index 913b14b2f3..0000000000 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza3.txt +++ /dev/null @@ -1,85 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.false., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_AIRS.csv' -! channel_filepath='rttov_channel_input_IASI_subset.csv', - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov13pred101L/rtcoef_metop_2_iasi_7gas.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., - CO_data=.false., - CO2_data=.true., - CH4_data=.true., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air - rttov_ZenAng=35.97, ! Satellite Zenith Angle, was 76.2 - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) - ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) - rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. - rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. - rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. - ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. -/ diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt deleted file mode 100644 index 3e03847cd5..0000000000 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza4.txt +++ /dev/null @@ -1,85 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.false., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_AIRS.csv' -! channel_filepath='rttov_channel_input_IASI_subset.csv', - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov13pred101L/rtcoef_metop_2_iasi_7gas.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., - CO_data=.false., - CO2_data=.true., - CH4_data=.true., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air - rttov_ZenAng=50.34, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) - ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) - rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. - rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. - rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. - ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. -/ diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt deleted file mode 100644 index c2ff405125..0000000000 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza5.txt +++ /dev/null @@ -1,85 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.false., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_AIRS.csv' -! channel_filepath='rttov_channel_input_IASI_subset.csv', - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov13pred101L/rtcoef_metop_2_iasi_7gas.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., - CO_data=.false., - CO2_data=.true., - CH4_data=.true., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air - rttov_ZenAng=64.71, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) - ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) - rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. - rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. - rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. - ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. -/ diff --git a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt b/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt deleted file mode 100644 index 48f02f3e30..0000000000 --- a/driver/run/instrument_nls/point6_quadrature/cosp2_rttov_IASI_CESM2_vza6.txt +++ /dev/null @@ -1,85 +0,0 @@ -! (c) British Crown Copyright 2008, the Met Office. -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are permitted -! provided that the following conditions are met: -! -! * Redistributions of source code must retain the above copyright notice, this list -! of conditions and the following disclaimer. -! * Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other materials -! provided with the distribution. -! * Neither the name of the Met Office nor the names of its contributors may be used -! to endorse or promote products derived from this software without specific prior written -! permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -! Namelist that sets up the main COSP options -&RTTOV_INPUT - !-------------- Logical for constructing outputs and determining settings - Lrttov_bt=.false., ! Calculate RTTOV brightness temps - Lrttov_rad=.true., ! Calculate RTTOV radiances - Lrttov_refl=.false., ! Calculate RTTOV reflectivities - Lrttov_cld=.true., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_aer=.false., ! Calculate RTTOV all-sky + cloudy-sky values - Lrttov_cldparam=.false., ! Use user input cloud optical parameters - Lrttov_aerparam=.false., ! Use user input aerosol optical parameters - Lrttov_gridbox_cldmmr=.true., ! Do cloud mixing ratios represent gridcell means? - Ldo_nlte_correction=.false., ! Correct for non-local thermal equilibrium effects? Requires appropriate coefficients. - Lrttov_pc=.false., ! Run with PC-RTTOV - !-------------- Number of channels to reconstruct. Should match the length of entries in "channel_filepath" - nchannels_rec=8461, ! 8461 for all IASI channels, could limit just to those that overlap RRTMG channels - !-------------- RTTOV Filepaths - Lchannel_filepath=.false., - channel_filepath='rttov_channel_input_AIRS.csv' -! channel_filepath='rttov_channel_input_IASI_subset.csv', - rttov_srcDir='/glade/u/home/jonahshaw/w/RTTOV/', - rttov_coefDir='rtcoef_rttov13/', - OD_coef_filepath='rttov13pred101L/rtcoef_metop_2_iasi_7gas.H5', - cld_coef_filepath='cldaer_visir/sccldcoef_metop_2_iasi.H5', - !-------------- RTTOV Trace Gas Logicals (must match coefficient files) - SO2_data=.false., - N2O_data=.true., - CO_data=.false., - CO2_data=.true., - CH4_data=.true., - ozone_data=.true., - clw_data=.false., ! Only used for MW calculations - ! -------------- RTTOV Trace Gas Concentrations - ! -------------- Specify units in RTTOV options set-up - ! ---------------Standard units are kg/kg over moist air - user_tracegas_input=.false., ! Have RTTOV use the trace gas concentrations below - CO2_mr=5.241e-04, - CH4_mr=9.139e-07, - CO_mr=2.098e-07, - N2O_mr=4.665e-07, - SO2_mr=2.0e-11, ! RTTOV hard lower limit is 1.0e-11 ppmv - !-------------- PC-RTTOV ------------------ - ipcbnd=1, ! Always 1 for RTTOV v13 - ipcreg=2, ! Set the number of predictors (channel outputs) - npcscores=100, ! Determine how many principal components are used (greater accuracy, greater cost) - !-------------- RTTOV Other --------------- - ! Control degree of parallelization in RTTOV 1=no parallel, >1 more parallel - rttov_nthreads=1, - rttov_gas_units=3, ! 0: ppmv over dry air, 1: kg/kg over moist air, 2: ppmv over moist air, 3: kg/kg over dry air - rttov_ZenAng=78.98, ! Satellite Zenith Angle - ! Set local time sampling with swath widths - rttov_Nlocaltime=0, ! Number of local times to sample at - rttov_localtime=1,0, ! Local times to sample at in hrs [0,24] - rttov_localtime_width=1550,0, ! Swath width (km) - ! ---------------------- How to parameterize the optical properties of cloud ice and cloud liquid (see RTTOV user manual pg 75) - rttov_clw_scheme=2, ! Should be 2 if model supplies effective radius and not cloud type. - rttov_ice_scheme=1, ! 1 uses effective radii values if rttov_icede_param=0, 2 and 3 ignore icede entirely. - rttov_icede_param=4, ! 0 if icede should be used from model, if ice_scheme = 1 then 1-4 are different options for computing icede separately. - ! ---------------------- How to handle atmosphere between the top of supplied values and the RTTOV instrument. - rttov_extendatmos=1, ! 0: Atmosphere ends at the top of supplied values. 1: CAM-like additional interfaces at 1e-4 Pa and 2.25 Pa. -/ diff --git a/driver/run/rttov_channel_input2.csv b/driver/run/rttov_channel_input2.csv deleted file mode 100644 index 01d2f42dc2..0000000000 --- a/driver/run/rttov_channel_input2.csv +++ /dev/null @@ -1,100 +0,0 @@ -1,1,0 -2,1,0 -3,1,0 -4,1,0 -5,1,0 -6,1,0 -7,1,0 -8,1,0 -9,1,0 -10,1,0 -11,1,0 -12,1,0 -13,1,0 -14,1,0 -15,1,0 -16,1,0 -17,1,0 -18,1,0 -19,1,0 -20,1,0 -21,1,0 -22,1,0 -23,1,0 -24,1,0 -25,1,0 -26,1,0 -27,1,0 -28,1,0 -29,1,0 -30,1,0 -31,1,0 -32,1,0 -33,1,0 -34,1,0 -35,1,0 -36,1,0 -37,1,0 -38,1,0 -39,1,0 -40,1,0 -41,1,0 -42,1,0 -43,1,0 -44,1,0 -45,1,0 -46,1,0 -47,1,0 -48,1,0 -49,1,0 -50,1,0 -51,1,0 -52,1,0 -53,1,0 -54,1,0 -55,1,0 -56,1,0 -57,1,0 -58,1,0 -59,1,0 -60,1,0 -61,1,0 -62,1,0 -63,1,0 -64,1,0 -65,1,0 -66,1,0 -67,1,0 -68,1,0 -69,1,0 -70,1,0 -71,1,0 -72,1,0 -73,1,0 -74,1,0 -75,1,0 -76,1,0 -77,1,0 -78,1,0 -79,1,0 -80,1,0 -81,1,0 -82,1,0 -83,1,0 -84,1,0 -85,1,0 -86,1,0 -87,1,0 -88,1,0 -89,1,0 -90,1,0 -91,1,0 -92,1,0 -93,1,0 -94,1,0 -95,1,0 -96,1,0 -97,1,0 -98,1,0 -99,1,0 -100,1,0 \ No newline at end of file diff --git a/driver/run/rttov_channel_input_AIRS.csv b/driver/run/rttov_channel_input_AIRS.csv deleted file mode 100644 index 4d71f96f24..0000000000 --- a/driver/run/rttov_channel_input_AIRS.csv +++ /dev/null @@ -1,2500 +0,0 @@ -1,1,0 -2,1,0 -3,1,0 -4,1,0 -5,1,0 -6,1,0 -7,1,0 -8,1,0 -9,1,0 -10,1,0 -11,1,0 -12,1,0 -13,1,0 -14,1,0 -15,1,0 -16,1,0 -17,1,0 -18,1,0 -19,1,0 -20,1,0 -21,1,0 -22,1,0 -23,1,0 -24,1,0 -25,1,0 -26,1,0 -27,1,0 -28,1,0 -29,1,0 -30,1,0 -31,1,0 -32,1,0 -33,1,0 -34,1,0 -35,1,0 -36,1,0 -37,1,0 -38,1,0 -39,1,0 -40,1,0 -41,1,0 -42,1,0 -43,1,0 -44,1,0 -45,1,0 -46,1,0 -47,1,0 -48,1,0 -49,1,0 -50,1,0 -51,1,0 -52,1,0 -53,1,0 -54,1,0 -55,1,0 -56,1,0 -57,1,0 -58,1,0 -59,1,0 -60,1,0 -61,1,0 -62,1,0 -63,1,0 -64,1,0 -65,1,0 -66,1,0 -67,1,0 -68,1,0 -69,1,0 -70,1,0 -71,1,0 -72,1,0 -73,1,0 -74,1,0 -75,1,0 -76,1,0 -77,1,0 -78,1,0 -79,1,0 -80,1,0 -81,1,0 -82,1,0 -83,1,0 -84,1,0 -85,1,0 -86,1,0 -87,1,0 -88,1,0 -89,1,0 -90,1,0 -91,1,0 -92,1,0 -93,1,0 -94,1,0 -95,1,0 -96,1,0 -97,1,0 -98,1,0 -99,1,0 -100,1,0 -101,1,0 -102,1,0 -103,1,0 -104,1,0 -105,1,0 -106,1,0 -107,1,0 -108,1,0 -109,1,0 -110,1,0 -111,1,0 -112,1,0 -113,1,0 -114,1,0 -115,1,0 -116,1,0 -117,1,0 -118,1,0 -119,1,0 -120,1,0 -121,1,0 -122,1,0 -123,1,0 -124,1,0 -125,1,0 -126,1,0 -127,1,0 -128,1,0 -129,1,0 -130,1,0 -131,1,0 -132,1,0 -133,1,0 -134,1,0 -135,1,0 -136,1,0 -137,1,0 -138,1,0 -139,1,0 -140,1,0 -141,1,0 -142,1,0 -143,1,0 -144,1,0 -145,1,0 -146,1,0 -147,1,0 -148,1,0 -149,1,0 -150,1,0 -151,1,0 -152,1,0 -153,1,0 -154,1,0 -155,1,0 -156,1,0 -157,1,0 -158,1,0 -159,1,0 -160,1,0 -161,1,0 -162,1,0 -163,1,0 -164,1,0 -165,1,0 -166,1,0 -167,1,0 -168,1,0 -169,1,0 -170,1,0 -171,1,0 -172,1,0 -173,1,0 -174,1,0 -175,1,0 -176,1,0 -177,1,0 -178,1,0 -179,1,0 -180,1,0 -181,1,0 -182,1,0 -183,1,0 -184,1,0 -185,1,0 -186,1,0 -187,1,0 -188,1,0 -189,1,0 -190,1,0 -191,1,0 -192,1,0 -193,1,0 -194,1,0 -195,1,0 -196,1,0 -197,1,0 -198,1,0 -199,1,0 -200,1,0 -201,1,0 -202,1,0 -203,1,0 -204,1,0 -205,1,0 -206,1,0 -207,1,0 -208,1,0 -209,1,0 -210,1,0 -211,1,0 -212,1,0 -213,1,0 -214,1,0 -215,1,0 -216,1,0 -217,1,0 -218,1,0 -219,1,0 -220,1,0 -221,1,0 -222,1,0 -223,1,0 -224,1,0 -225,1,0 -226,1,0 -227,1,0 -228,1,0 -229,1,0 -230,1,0 -231,1,0 -232,1,0 -233,1,0 -234,1,0 -235,1,0 -236,1,0 -237,1,0 -238,1,0 -239,1,0 -240,1,0 -241,1,0 -242,1,0 -243,1,0 -244,1,0 -245,1,0 -246,1,0 -247,1,0 -248,1,0 -249,1,0 -250,1,0 -251,1,0 -252,1,0 -253,1,0 -254,1,0 -255,1,0 -256,1,0 -257,1,0 -258,1,0 -259,1,0 -260,1,0 -261,1,0 -262,1,0 -263,1,0 -264,1,0 -265,1,0 -266,1,0 -267,1,0 -268,1,0 -269,1,0 -270,1,0 -271,1,0 -272,1,0 -273,1,0 -274,1,0 -275,1,0 -276,1,0 -277,1,0 -278,1,0 -279,1,0 -280,1,0 -281,1,0 -282,1,0 -283,1,0 -284,1,0 -285,1,0 -286,1,0 -287,1,0 -288,1,0 -289,1,0 -290,1,0 -291,1,0 -292,1,0 -293,1,0 -294,1,0 -295,1,0 -296,1,0 -297,1,0 -298,1,0 -299,1,0 -300,1,0 -301,1,0 -302,1,0 -303,1,0 -304,1,0 -305,1,0 -306,1,0 -307,1,0 -308,1,0 -309,1,0 -310,1,0 -311,1,0 -312,1,0 -313,1,0 -314,1,0 -315,1,0 -316,1,0 -317,1,0 -318,1,0 -319,1,0 -320,1,0 -321,1,0 -322,1,0 -323,1,0 -324,1,0 -325,1,0 -326,1,0 -327,1,0 -328,1,0 -329,1,0 -330,1,0 -331,1,0 -332,1,0 -333,1,0 -334,1,0 -335,1,0 -336,1,0 -337,1,0 -338,1,0 -339,1,0 -340,1,0 -341,1,0 -342,1,0 -343,1,0 -344,1,0 -345,1,0 -346,1,0 -347,1,0 -348,1,0 -349,1,0 -350,1,0 -351,1,0 -352,1,0 -353,1,0 -354,1,0 -355,1,0 -356,1,0 -357,1,0 -358,1,0 -359,1,0 -360,1,0 -361,1,0 -362,1,0 -363,1,0 -364,1,0 -365,1,0 -366,1,0 -367,1,0 -368,1,0 -369,1,0 -370,1,0 -371,1,0 -372,1,0 -373,1,0 -374,1,0 -375,1,0 -376,1,0 -377,1,0 -378,1,0 -379,1,0 -380,1,0 -381,1,0 -382,1,0 -383,1,0 -384,1,0 -385,1,0 -386,1,0 -387,1,0 -388,1,0 -389,1,0 -390,1,0 -391,1,0 -392,1,0 -393,1,0 -394,1,0 -395,1,0 -396,1,0 -397,1,0 -398,1,0 -399,1,0 -400,1,0 -401,1,0 -402,1,0 -403,1,0 -404,1,0 -405,1,0 -406,1,0 -407,1,0 -408,1,0 -409,1,0 -410,1,0 -411,1,0 -412,1,0 -413,1,0 -414,1,0 -415,1,0 -416,1,0 -417,1,0 -418,1,0 -419,1,0 -420,1,0 -421,1,0 -422,1,0 -423,1,0 -424,1,0 -425,1,0 -426,1,0 -427,1,0 -428,1,0 -429,1,0 -430,1,0 -431,1,0 -432,1,0 -433,1,0 -434,1,0 -435,1,0 -436,1,0 -437,1,0 -438,1,0 -439,1,0 -440,1,0 -441,1,0 -442,1,0 -443,1,0 -444,1,0 -445,1,0 -446,1,0 -447,1,0 -448,1,0 -449,1,0 -450,1,0 -451,1,0 -452,1,0 -453,1,0 -454,1,0 -455,1,0 -456,1,0 -457,1,0 -458,1,0 -459,1,0 -460,1,0 -461,1,0 -462,1,0 -463,1,0 -464,1,0 -465,1,0 -466,1,0 -467,1,0 -468,1,0 -469,1,0 -470,1,0 -471,1,0 -472,1,0 -473,1,0 -474,1,0 -475,1,0 -476,1,0 -477,1,0 -478,1,0 -479,1,0 -480,1,0 -481,1,0 -482,1,0 -483,1,0 -484,1,0 -485,1,0 -486,1,0 -487,1,0 -488,1,0 -489,1,0 -490,1,0 -491,1,0 -492,1,0 -493,1,0 -494,1,0 -495,1,0 -496,1,0 -497,1,0 -498,1,0 -499,1,0 -500,1,0 -501,1,0 -502,1,0 -503,1,0 -504,1,0 -505,1,0 -506,1,0 -507,1,0 -508,1,0 -509,1,0 -510,1,0 -511,1,0 -512,1,0 -513,1,0 -514,1,0 -515,1,0 -516,1,0 -517,1,0 -518,1,0 -519,1,0 -520,1,0 -521,1,0 -522,1,0 -523,1,0 -524,1,0 -525,1,0 -526,1,0 -527,1,0 -528,1,0 -529,1,0 -530,1,0 -531,1,0 -532,1,0 -533,1,0 -534,1,0 -535,1,0 -536,1,0 -537,1,0 -538,1,0 -539,1,0 -540,1,0 -541,1,0 -542,1,0 -543,1,0 -544,1,0 -545,1,0 -546,1,0 -547,1,0 -548,1,0 -549,1,0 -550,1,0 -551,1,0 -552,1,0 -553,1,0 -554,1,0 -555,1,0 -556,1,0 -557,1,0 -558,1,0 -559,1,0 -560,1,0 -561,1,0 -562,1,0 -563,1,0 -564,1,0 -565,1,0 -566,1,0 -567,1,0 -568,1,0 -569,1,0 -570,1,0 -571,1,0 -572,1,0 -573,1,0 -574,1,0 -575,1,0 -576,1,0 -577,1,0 -578,1,0 -579,1,0 -580,1,0 -581,1,0 -582,1,0 -583,1,0 -584,1,0 -585,1,0 -586,1,0 -587,1,0 -588,1,0 -589,1,0 -590,1,0 -591,1,0 -592,1,0 -593,1,0 -594,1,0 -595,1,0 -596,1,0 -597,1,0 -598,1,0 -599,1,0 -600,1,0 -601,1,0 -602,1,0 -603,1,0 -604,1,0 -605,1,0 -606,1,0 -607,1,0 -608,1,0 -609,1,0 -610,1,0 -611,1,0 -612,1,0 -613,1,0 -614,1,0 -615,1,0 -616,1,0 -617,1,0 -618,1,0 -619,1,0 -620,1,0 -621,1,0 -622,1,0 -623,1,0 -624,1,0 -625,1,0 -626,1,0 -627,1,0 -628,1,0 -629,1,0 -630,1,0 -631,1,0 -632,1,0 -633,1,0 -634,1,0 -635,1,0 -636,1,0 -637,1,0 -638,1,0 -639,1,0 -640,1,0 -641,1,0 -642,1,0 -643,1,0 -644,1,0 -645,1,0 -646,1,0 -647,1,0 -648,1,0 -649,1,0 -650,1,0 -651,1,0 -652,1,0 -653,1,0 -654,1,0 -655,1,0 -656,1,0 -657,1,0 -658,1,0 -659,1,0 -660,1,0 -661,1,0 -662,1,0 -663,1,0 -664,1,0 -665,1,0 -666,1,0 -667,1,0 -668,1,0 -669,1,0 -670,1,0 -671,1,0 -672,1,0 -673,1,0 -674,1,0 -675,1,0 -676,1,0 -677,1,0 -678,1,0 -679,1,0 -680,1,0 -681,1,0 -682,1,0 -683,1,0 -684,1,0 -685,1,0 -686,1,0 -687,1,0 -688,1,0 -689,1,0 -690,1,0 -691,1,0 -692,1,0 -693,1,0 -694,1,0 -695,1,0 -696,1,0 -697,1,0 -698,1,0 -699,1,0 -700,1,0 -701,1,0 -702,1,0 -703,1,0 -704,1,0 -705,1,0 -706,1,0 -707,1,0 -708,1,0 -709,1,0 -710,1,0 -711,1,0 -712,1,0 -713,1,0 -714,1,0 -715,1,0 -716,1,0 -717,1,0 -718,1,0 -719,1,0 -720,1,0 -721,1,0 -722,1,0 -723,1,0 -724,1,0 -725,1,0 -726,1,0 -727,1,0 -728,1,0 -729,1,0 -730,1,0 -731,1,0 -732,1,0 -733,1,0 -734,1,0 -735,1,0 -736,1,0 -737,1,0 -738,1,0 -739,1,0 -740,1,0 -741,1,0 -742,1,0 -743,1,0 -744,1,0 -745,1,0 -746,1,0 -747,1,0 -748,1,0 -749,1,0 -750,1,0 -751,1,0 -752,1,0 -753,1,0 -754,1,0 -755,1,0 -756,1,0 -757,1,0 -758,1,0 -759,1,0 -760,1,0 -761,1,0 -762,1,0 -763,1,0 -764,1,0 -765,1,0 -766,1,0 -767,1,0 -768,1,0 -769,1,0 -770,1,0 -771,1,0 -772,1,0 -773,1,0 -774,1,0 -775,1,0 -776,1,0 -777,1,0 -778,1,0 -779,1,0 -780,1,0 -781,1,0 -782,1,0 -783,1,0 -784,1,0 -785,1,0 -786,1,0 -787,1,0 -788,1,0 -789,1,0 -790,1,0 -791,1,0 -792,1,0 -793,1,0 -794,1,0 -795,1,0 -796,1,0 -797,1,0 -798,1,0 -799,1,0 -800,1,0 -801,1,0 -802,1,0 -803,1,0 -804,1,0 -805,1,0 -806,1,0 -807,1,0 -808,1,0 -809,1,0 -810,1,0 -811,1,0 -812,1,0 -813,1,0 -814,1,0 -815,1,0 -816,1,0 -817,1,0 -818,1,0 -819,1,0 -820,1,0 -821,1,0 -822,1,0 -823,1,0 -824,1,0 -825,1,0 -826,1,0 -827,1,0 -828,1,0 -829,1,0 -830,1,0 -831,1,0 -832,1,0 -833,1,0 -834,1,0 -835,1,0 -836,1,0 -837,1,0 -838,1,0 -839,1,0 -840,1,0 -841,1,0 -842,1,0 -843,1,0 -844,1,0 -845,1,0 -846,1,0 -847,1,0 -848,1,0 -849,1,0 -850,1,0 -851,1,0 -852,1,0 -853,1,0 -854,1,0 -855,1,0 -856,1,0 -857,1,0 -858,1,0 -859,1,0 -860,1,0 -861,1,0 -862,1,0 -863,1,0 -864,1,0 -865,1,0 -866,1,0 -867,1,0 -868,1,0 -869,1,0 -870,1,0 -871,1,0 -872,1,0 -873,1,0 -874,1,0 -875,1,0 -876,1,0 -877,1,0 -878,1,0 -879,1,0 -880,1,0 -881,1,0 -882,1,0 -883,1,0 -884,1,0 -885,1,0 -886,1,0 -887,1,0 -888,1,0 -889,1,0 -890,1,0 -891,1,0 -892,1,0 -893,1,0 -894,1,0 -895,1,0 -896,1,0 -897,1,0 -898,1,0 -899,1,0 -900,1,0 -901,1,0 -902,1,0 -903,1,0 -904,1,0 -905,1,0 -906,1,0 -907,1,0 -908,1,0 -909,1,0 -910,1,0 -911,1,0 -912,1,0 -913,1,0 -914,1,0 -915,1,0 -916,1,0 -917,1,0 -918,1,0 -919,1,0 -920,1,0 -921,1,0 -922,1,0 -923,1,0 -924,1,0 -925,1,0 -926,1,0 -927,1,0 -928,1,0 -929,1,0 -930,1,0 -931,1,0 -932,1,0 -933,1,0 -934,1,0 -935,1,0 -936,1,0 -937,1,0 -938,1,0 -939,1,0 -940,1,0 -941,1,0 -942,1,0 -943,1,0 -944,1,0 -945,1,0 -946,1,0 -947,1,0 -948,1,0 -949,1,0 -950,1,0 -951,1,0 -952,1,0 -953,1,0 -954,1,0 -955,1,0 -956,1,0 -957,1,0 -958,1,0 -959,1,0 -960,1,0 -961,1,0 -962,1,0 -963,1,0 -964,1,0 -965,1,0 -966,1,0 -967,1,0 -968,1,0 -969,1,0 -970,1,0 -971,1,0 -972,1,0 -973,1,0 -974,1,0 -975,1,0 -976,1,0 -977,1,0 -978,1,0 -979,1,0 -980,1,0 -981,1,0 -982,1,0 -983,1,0 -984,1,0 -985,1,0 -986,1,0 -987,1,0 -988,1,0 -989,1,0 -990,1,0 -991,1,0 -992,1,0 -993,1,0 -994,1,0 -995,1,0 -996,1,0 -997,1,0 -998,1,0 -999,1,0 -1000,1,0 -1001,1,0 -1002,1,0 -1003,1,0 -1004,1,0 -1005,1,0 -1006,1,0 -1007,1,0 -1008,1,0 -1009,1,0 -1010,1,0 -1011,1,0 -1012,1,0 -1013,1,0 -1014,1,0 -1015,1,0 -1016,1,0 -1017,1,0 -1018,1,0 -1019,1,0 -1020,1,0 -1021,1,0 -1022,1,0 -1023,1,0 -1024,1,0 -1025,1,0 -1026,1,0 -1027,1,0 -1028,1,0 -1029,1,0 -1030,1,0 -1031,1,0 -1032,1,0 -1033,1,0 -1034,1,0 -1035,1,0 -1036,1,0 -1037,1,0 -1038,1,0 -1039,1,0 -1040,1,0 -1041,1,0 -1042,1,0 -1043,1,0 -1044,1,0 -1045,1,0 -1046,1,0 -1047,1,0 -1048,1,0 -1049,1,0 -1050,1,0 -1051,1,0 -1052,1,0 -1053,1,0 -1054,1,0 -1055,1,0 -1056,1,0 -1057,1,0 -1058,1,0 -1059,1,0 -1060,1,0 -1061,1,0 -1062,1,0 -1063,1,0 -1064,1,0 -1065,1,0 -1066,1,0 -1067,1,0 -1068,1,0 -1069,1,0 -1070,1,0 -1071,1,0 -1072,1,0 -1073,1,0 -1074,1,0 -1075,1,0 -1076,1,0 -1077,1,0 -1078,1,0 -1079,1,0 -1080,1,0 -1081,1,0 -1082,1,0 -1083,1,0 -1084,1,0 -1085,1,0 -1086,1,0 -1087,1,0 -1088,1,0 -1089,1,0 -1090,1,0 -1091,1,0 -1092,1,0 -1093,1,0 -1094,1,0 -1095,1,0 -1096,1,0 -1097,1,0 -1098,1,0 -1099,1,0 -1100,1,0 -1101,1,0 -1102,1,0 -1103,1,0 -1104,1,0 -1105,1,0 -1106,1,0 -1107,1,0 -1108,1,0 -1109,1,0 -1110,1,0 -1111,1,0 -1112,1,0 -1113,1,0 -1114,1,0 -1115,1,0 -1116,1,0 -1117,1,0 -1118,1,0 -1119,1,0 -1120,1,0 -1121,1,0 -1122,1,0 -1123,1,0 -1124,1,0 -1125,1,0 -1126,1,0 -1127,1,0 -1128,1,0 -1129,1,0 -1130,1,0 -1131,1,0 -1132,1,0 -1133,1,0 -1134,1,0 -1135,1,0 -1136,1,0 -1137,1,0 -1138,1,0 -1139,1,0 -1140,1,0 -1141,1,0 -1142,1,0 -1143,1,0 -1144,1,0 -1145,1,0 -1146,1,0 -1147,1,0 -1148,1,0 -1149,1,0 -1150,1,0 -1151,1,0 -1152,1,0 -1153,1,0 -1154,1,0 -1155,1,0 -1156,1,0 -1157,1,0 -1158,1,0 -1159,1,0 -1160,1,0 -1161,1,0 -1162,1,0 -1163,1,0 -1164,1,0 -1165,1,0 -1166,1,0 -1167,1,0 -1168,1,0 -1169,1,0 -1170,1,0 -1171,1,0 -1172,1,0 -1173,1,0 -1174,1,0 -1175,1,0 -1176,1,0 -1177,1,0 -1178,1,0 -1179,1,0 -1180,1,0 -1181,1,0 -1182,1,0 -1183,1,0 -1184,1,0 -1185,1,0 -1186,1,0 -1187,1,0 -1188,1,0 -1189,1,0 -1190,1,0 -1191,1,0 -1192,1,0 -1193,1,0 -1194,1,0 -1195,1,0 -1196,1,0 -1197,1,0 -1198,1,0 -1199,1,0 -1200,1,0 -1201,1,0 -1202,1,0 -1203,1,0 -1204,1,0 -1205,1,0 -1206,1,0 -1207,1,0 -1208,1,0 -1209,1,0 -1210,1,0 -1211,1,0 -1212,1,0 -1213,1,0 -1214,1,0 -1215,1,0 -1216,1,0 -1217,1,0 -1218,1,0 -1219,1,0 -1220,1,0 -1221,1,0 -1222,1,0 -1223,1,0 -1224,1,0 -1225,1,0 -1226,1,0 -1227,1,0 -1228,1,0 -1229,1,0 -1230,1,0 -1231,1,0 -1232,1,0 -1233,1,0 -1234,1,0 -1235,1,0 -1236,1,0 -1237,1,0 -1238,1,0 -1239,1,0 -1240,1,0 -1241,1,0 -1242,1,0 -1243,1,0 -1244,1,0 -1245,1,0 -1246,1,0 -1247,1,0 -1248,1,0 -1249,1,0 -1250,1,0 -1251,1,0 -1252,1,0 -1253,1,0 -1254,1,0 -1255,1,0 -1256,1,0 -1257,1,0 -1258,1,0 -1259,1,0 -1260,1,0 -1261,1,0 -1262,1,0 -1263,1,0 -1264,1,0 -1265,1,0 -1266,1,0 -1267,1,0 -1268,1,0 -1269,1,0 -1270,1,0 -1271,1,0 -1272,1,0 -1273,1,0 -1274,1,0 -1275,1,0 -1276,1,0 -1277,1,0 -1278,1,0 -1279,1,0 -1280,1,0 -1281,1,0 -1282,1,0 -1283,1,0 -1284,1,0 -1285,1,0 -1286,1,0 -1287,1,0 -1288,1,0 -1289,1,0 -1290,1,0 -1291,1,0 -1292,1,0 -1293,1,0 -1294,1,0 -1295,1,0 -1296,1,0 -1297,1,0 -1298,1,0 -1299,1,0 -1300,1,0 -1301,1,0 -1302,1,0 -1303,1,0 -1304,1,0 -1305,1,0 -1306,1,0 -1307,1,0 -1308,1,0 -1309,1,0 -1310,1,0 -1311,1,0 -1312,1,0 -1313,1,0 -1314,1,0 -1315,1,0 -1316,1,0 -1317,1,0 -1318,1,0 -1319,1,0 -1320,1,0 -1321,1,0 -1322,1,0 -1323,1,0 -1324,1,0 -1325,1,0 -1326,1,0 -1327,1,0 -1328,1,0 -1329,1,0 -1330,1,0 -1331,1,0 -1332,1,0 -1333,1,0 -1334,1,0 -1335,1,0 -1336,1,0 -1337,1,0 -1338,1,0 -1339,1,0 -1340,1,0 -1341,1,0 -1342,1,0 -1343,1,0 -1344,1,0 -1345,1,0 -1346,1,0 -1347,1,0 -1348,1,0 -1349,1,0 -1350,1,0 -1351,1,0 -1352,1,0 -1353,1,0 -1354,1,0 -1355,1,0 -1356,1,0 -1357,1,0 -1358,1,0 -1359,1,0 -1360,1,0 -1361,1,0 -1362,1,0 -1363,1,0 -1364,1,0 -1365,1,0 -1366,1,0 -1367,1,0 -1368,1,0 -1369,1,0 -1370,1,0 -1371,1,0 -1372,1,0 -1373,1,0 -1374,1,0 -1375,1,0 -1376,1,0 -1377,1,0 -1378,1,0 -1379,1,0 -1380,1,0 -1381,1,0 -1382,1,0 -1383,1,0 -1384,1,0 -1385,1,0 -1386,1,0 -1387,1,0 -1388,1,0 -1389,1,0 -1390,1,0 -1391,1,0 -1392,1,0 -1393,1,0 -1394,1,0 -1395,1,0 -1396,1,0 -1397,1,0 -1398,1,0 -1399,1,0 -1400,1,0 -1401,1,0 -1402,1,0 -1403,1,0 -1404,1,0 -1405,1,0 -1406,1,0 -1407,1,0 -1408,1,0 -1409,1,0 -1410,1,0 -1411,1,0 -1412,1,0 -1413,1,0 -1414,1,0 -1415,1,0 -1416,1,0 -1417,1,0 -1418,1,0 -1419,1,0 -1420,1,0 -1421,1,0 -1422,1,0 -1423,1,0 -1424,1,0 -1425,1,0 -1426,1,0 -1427,1,0 -1428,1,0 -1429,1,0 -1430,1,0 -1431,1,0 -1432,1,0 -1433,1,0 -1434,1,0 -1435,1,0 -1436,1,0 -1437,1,0 -1438,1,0 -1439,1,0 -1440,1,0 -1441,1,0 -1442,1,0 -1443,1,0 -1444,1,0 -1445,1,0 -1446,1,0 -1447,1,0 -1448,1,0 -1449,1,0 -1450,1,0 -1451,1,0 -1452,1,0 -1453,1,0 -1454,1,0 -1455,1,0 -1456,1,0 -1457,1,0 -1458,1,0 -1459,1,0 -1460,1,0 -1461,1,0 -1462,1,0 -1463,1,0 -1464,1,0 -1465,1,0 -1466,1,0 -1467,1,0 -1468,1,0 -1469,1,0 -1470,1,0 -1471,1,0 -1472,1,0 -1473,1,0 -1474,1,0 -1475,1,0 -1476,1,0 -1477,1,0 -1478,1,0 -1479,1,0 -1480,1,0 -1481,1,0 -1482,1,0 -1483,1,0 -1484,1,0 -1485,1,0 -1486,1,0 -1487,1,0 -1488,1,0 -1489,1,0 -1490,1,0 -1491,1,0 -1492,1,0 -1493,1,0 -1494,1,0 -1495,1,0 -1496,1,0 -1497,1,0 -1498,1,0 -1499,1,0 -1500,1,0 -1501,1,0 -1502,1,0 -1503,1,0 -1504,1,0 -1505,1,0 -1506,1,0 -1507,1,0 -1508,1,0 -1509,1,0 -1510,1,0 -1511,1,0 -1512,1,0 -1513,1,0 -1514,1,0 -1515,1,0 -1516,1,0 -1517,1,0 -1518,1,0 -1519,1,0 -1520,1,0 -1521,1,0 -1522,1,0 -1523,1,0 -1524,1,0 -1525,1,0 -1526,1,0 -1527,1,0 -1528,1,0 -1529,1,0 -1530,1,0 -1531,1,0 -1532,1,0 -1533,1,0 -1534,1,0 -1535,1,0 -1536,1,0 -1537,1,0 -1538,1,0 -1539,1,0 -1540,1,0 -1541,1,0 -1542,1,0 -1543,1,0 -1544,1,0 -1545,1,0 -1546,1,0 -1547,1,0 -1548,1,0 -1549,1,0 -1550,1,0 -1551,1,0 -1552,1,0 -1553,1,0 -1554,1,0 -1555,1,0 -1556,1,0 -1557,1,0 -1558,1,0 -1559,1,0 -1560,1,0 -1561,1,0 -1562,1,0 -1563,1,0 -1564,1,0 -1565,1,0 -1566,1,0 -1567,1,0 -1568,1,0 -1569,1,0 -1570,1,0 -1571,1,0 -1572,1,0 -1573,1,0 -1574,1,0 -1575,1,0 -1576,1,0 -1577,1,0 -1578,1,0 -1579,1,0 -1580,1,0 -1581,1,0 -1582,1,0 -1583,1,0 -1584,1,0 -1585,1,0 -1586,1,0 -1587,1,0 -1588,1,0 -1589,1,0 -1590,1,0 -1591,1,0 -1592,1,0 -1593,1,0 -1594,1,0 -1595,1,0 -1596,1,0 -1597,1,0 -1598,1,0 -1599,1,0 -1600,1,0 -1601,1,0 -1602,1,0 -1603,1,0 -1604,1,0 -1605,1,0 -1606,1,0 -1607,1,0 -1608,1,0 -1609,1,0 -1610,1,0 -1611,1,0 -1612,1,0 -1613,1,0 -1614,1,0 -1615,1,0 -1616,1,0 -1617,1,0 -1618,1,0 -1619,1,0 -1620,1,0 -1621,1,0 -1622,1,0 -1623,1,0 -1624,1,0 -1625,1,0 -1626,1,0 -1627,1,0 -1628,1,0 -1629,1,0 -1630,1,0 -1631,1,0 -1632,1,0 -1633,1,0 -1634,1,0 -1635,1,0 -1636,1,0 -1637,1,0 -1638,1,0 -1639,1,0 -1640,1,0 -1641,1,0 -1642,1,0 -1643,1,0 -1644,1,0 -1645,1,0 -1646,1,0 -1647,1,0 -1648,1,0 -1649,1,0 -1650,1,0 -1651,1,0 -1652,1,0 -1653,1,0 -1654,1,0 -1655,1,0 -1656,1,0 -1657,1,0 -1658,1,0 -1659,1,0 -1660,1,0 -1661,1,0 -1662,1,0 -1663,1,0 -1664,1,0 -1665,1,0 -1666,1,0 -1667,1,0 -1668,1,0 -1669,1,0 -1670,1,0 -1671,1,0 -1672,1,0 -1673,1,0 -1674,1,0 -1675,1,0 -1676,1,0 -1677,1,0 -1678,1,0 -1679,1,0 -1680,1,0 -1681,1,0 -1682,1,0 -1683,1,0 -1684,1,0 -1685,1,0 -1686,1,0 -1687,1,0 -1688,1,0 -1689,1,0 -1690,1,0 -1691,1,0 -1692,1,0 -1693,1,0 -1694,1,0 -1695,1,0 -1696,1,0 -1697,1,0 -1698,1,0 -1699,1,0 -1700,1,0 -1701,1,0 -1702,1,0 -1703,1,0 -1704,1,0 -1705,1,0 -1706,1,0 -1707,1,0 -1708,1,0 -1709,1,0 -1710,1,0 -1711,1,0 -1712,1,0 -1713,1,0 -1714,1,0 -1715,1,0 -1716,1,0 -1717,1,0 -1718,1,0 -1719,1,0 -1720,1,0 -1721,1,0 -1722,1,0 -1723,1,0 -1724,1,0 -1725,1,0 -1726,1,0 -1727,1,0 -1728,1,0 -1729,1,0 -1730,1,0 -1731,1,0 -1732,1,0 -1733,1,0 -1734,1,0 -1735,1,0 -1736,1,0 -1737,1,0 -1738,1,0 -1739,1,0 -1740,1,0 -1741,1,0 -1742,1,0 -1743,1,0 -1744,1,0 -1745,1,0 -1746,1,0 -1747,1,0 -1748,1,0 -1749,1,0 -1750,1,0 -1751,1,0 -1752,1,0 -1753,1,0 -1754,1,0 -1755,1,0 -1756,1,0 -1757,1,0 -1758,1,0 -1759,1,0 -1760,1,0 -1761,1,0 -1762,1,0 -1763,1,0 -1764,1,0 -1765,1,0 -1766,1,0 -1767,1,0 -1768,1,0 -1769,1,0 -1770,1,0 -1771,1,0 -1772,1,0 -1773,1,0 -1774,1,0 -1775,1,0 -1776,1,0 -1777,1,0 -1778,1,0 -1779,1,0 -1780,1,0 -1781,1,0 -1782,1,0 -1783,1,0 -1784,1,0 -1785,1,0 -1786,1,0 -1787,1,0 -1788,1,0 -1789,1,0 -1790,1,0 -1791,1,0 -1792,1,0 -1793,1,0 -1794,1,0 -1795,1,0 -1796,1,0 -1797,1,0 -1798,1,0 -1799,1,0 -1800,1,0 -1801,1,0 -1802,1,0 -1803,1,0 -1804,1,0 -1805,1,0 -1806,1,0 -1807,1,0 -1808,1,0 -1809,1,0 -1810,1,0 -1811,1,0 -1812,1,0 -1813,1,0 -1814,1,0 -1815,1,0 -1816,1,0 -1817,1,0 -1818,1,0 -1819,1,0 -1820,1,0 -1821,1,0 -1822,1,0 -1823,1,0 -1824,1,0 -1825,1,0 -1826,1,0 -1827,1,0 -1828,1,0 -1829,1,0 -1830,1,0 -1831,1,0 -1832,1,0 -1833,1,0 -1834,1,0 -1835,1,0 -1836,1,0 -1837,1,0 -1838,1,0 -1839,1,0 -1840,1,0 -1841,1,0 -1842,1,0 -1843,1,0 -1844,1,0 -1845,1,0 -1846,1,0 -1847,1,0 -1848,1,0 -1849,1,0 -1850,1,0 -1851,1,0 -1852,1,0 -1853,1,0 -1854,1,0 -1855,1,0 -1856,1,0 -1857,1,0 -1858,1,0 -1859,1,0 -1860,1,0 -1861,1,0 -1862,1,0 -1863,1,0 -1864,1,0 -1865,1,0 -1866,1,0 -1867,1,0 -1868,1,0 -1869,1,0 -1870,1,0 -1871,1,0 -1872,1,0 -1873,1,0 -1874,1,0 -1875,1,0 -1876,1,0 -1877,1,0 -1878,1,0 -1879,1,0 -1880,1,0 -1881,1,0 -1882,1,0 -1883,1,0 -1884,1,0 -1885,1,0 -1886,1,0 -1887,1,0 -1888,1,0 -1889,1,0 -1890,1,0 -1891,1,0 -1892,1,0 -1893,1,0 -1894,1,0 -1895,1,0 -1896,1,0 -1897,1,0 -1898,1,0 -1899,1,0 -1900,1,0 -1901,1,0 -1902,1,0 -1903,1,0 -1904,1,0 -1905,1,0 -1906,1,0 -1907,1,0 -1908,1,0 -1909,1,0 -1910,1,0 -1911,1,0 -1912,1,0 -1913,1,0 -1914,1,0 -1915,1,0 -1916,1,0 -1917,1,0 -1918,1,0 -1919,1,0 -1920,1,0 -1921,1,0 -1922,1,0 -1923,1,0 -1924,1,0 -1925,1,0 -1926,1,0 -1927,1,0 -1928,1,0 -1929,1,0 -1930,1,0 -1931,1,0 -1932,1,0 -1933,1,0 -1934,1,0 -1935,1,0 -1936,1,0 -1937,1,0 -1938,1,0 -1939,1,0 -1940,1,0 -1941,1,0 -1942,1,0 -1943,1,0 -1944,1,0 -1945,1,0 -1946,1,0 -1947,1,0 -1948,1,0 -1949,1,0 -1950,1,0 -1951,1,0 -1952,1,0 -1953,1,0 -1954,1,0 -1955,1,0 -1956,1,0 -1957,1,0 -1958,1,0 -1959,1,0 -1960,1,0 -1961,1,0 -1962,1,0 -1963,1,0 -1964,1,0 -1965,1,0 -1966,1,0 -1967,1,0 -1968,1,0 -1969,1,0 -1970,1,0 -1971,1,0 -1972,1,0 -1973,1,0 -1974,1,0 -1975,1,0 -1976,1,0 -1977,1,0 -1978,1,0 -1979,1,0 -1980,1,0 -1981,1,0 -1982,1,0 -1983,1,0 -1984,1,0 -1985,1,0 -1986,1,0 -1987,1,0 -1988,1,0 -1989,1,0 -1990,1,0 -1991,1,0 -1992,1,0 -1993,1,0 -1994,1,0 -1995,1,0 -1996,1,0 -1997,1,0 -1998,1,0 -1999,1,0 -2000,1,0 -2001,1,0 -2002,1,0 -2003,1,0 -2004,1,0 -2005,1,0 -2006,1,0 -2007,1,0 -2008,1,0 -2009,1,0 -2010,1,0 -2011,1,0 -2012,1,0 -2013,1,0 -2014,1,0 -2015,1,0 -2016,1,0 -2017,1,0 -2018,1,0 -2019,1,0 -2020,1,0 -2021,1,0 -2022,1,0 -2023,1,0 -2024,1,0 -2025,1,0 -2026,1,0 -2027,1,0 -2028,1,0 -2029,1,0 -2030,1,0 -2031,1,0 -2032,1,0 -2033,1,0 -2034,1,0 -2035,1,0 -2036,1,0 -2037,1,0 -2038,1,0 -2039,1,0 -2040,1,0 -2041,1,0 -2042,1,0 -2043,1,0 -2044,1,0 -2045,1,0 -2046,1,0 -2047,1,0 -2048,1,0 -2049,1,0 -2050,1,0 -2051,1,0 -2052,1,0 -2053,1,0 -2054,1,0 -2055,1,0 -2056,1,0 -2057,1,0 -2058,1,0 -2059,1,0 -2060,1,0 -2061,1,0 -2062,1,0 -2063,1,0 -2064,1,0 -2065,1,0 -2066,1,0 -2067,1,0 -2068,1,0 -2069,1,0 -2070,1,0 -2071,1,0 -2072,1,0 -2073,1,0 -2074,1,0 -2075,1,0 -2076,1,0 -2077,1,0 -2078,1,0 -2079,1,0 -2080,1,0 -2081,1,0 -2082,1,0 -2083,1,0 -2084,1,0 -2085,1,0 -2086,1,0 -2087,1,0 -2088,1,0 -2089,1,0 -2090,1,0 -2091,1,0 -2092,1,0 -2093,1,0 -2094,1,0 -2095,1,0 -2096,1,0 -2097,1,0 -2098,1,0 -2099,1,0 -2100,1,0 -2101,1,0 -2102,1,0 -2103,1,0 -2104,1,0 -2105,1,0 -2106,1,0 -2107,1,0 -2108,1,0 -2109,1,0 -2110,1,0 -2111,1,0 -2112,1,0 -2113,1,0 -2114,1,0 -2115,1,0 -2116,1,0 -2117,1,0 -2118,1,0 -2119,1,0 -2120,1,0 -2121,1,0 -2122,1,0 -2123,1,0 -2124,1,0 -2125,1,0 -2126,1,0 -2127,1,0 -2128,1,0 -2129,1,0 -2130,1,0 -2131,1,0 -2132,1,0 -2133,1,0 -2134,1,0 -2135,1,0 -2136,1,0 -2137,1,0 -2138,1,0 -2139,1,0 -2140,1,0 -2141,1,0 -2142,1,0 -2143,1,0 -2144,1,0 -2145,1,0 -2146,1,0 -2147,1,0 -2148,1,0 -2149,1,0 -2150,1,0 -2151,1,0 -2152,1,0 -2153,1,0 -2154,1,0 -2155,1,0 -2156,1,0 -2157,1,0 -2158,1,0 -2159,1,0 -2160,1,0 -2161,1,0 -2162,1,0 -2163,1,0 -2164,1,0 -2165,1,0 -2166,1,0 -2167,1,0 -2168,1,0 -2169,1,0 -2170,1,0 -2171,1,0 -2172,1,0 -2173,1,0 -2174,1,0 -2175,1,0 -2176,1,0 -2177,1,0 -2178,1,0 -2179,1,0 -2180,1,0 -2181,1,0 -2182,1,0 -2183,1,0 -2184,1,0 -2185,1,0 -2186,1,0 -2187,1,0 -2188,1,0 -2189,1,0 -2190,1,0 -2191,1,0 -2192,1,0 -2193,1,0 -2194,1,0 -2195,1,0 -2196,1,0 -2197,1,0 -2198,1,0 -2199,1,0 -2200,1,0 -2201,1,0 -2202,1,0 -2203,1,0 -2204,1,0 -2205,1,0 -2206,1,0 -2207,1,0 -2208,1,0 -2209,1,0 -2210,1,0 -2211,1,0 -2212,1,0 -2213,1,0 -2214,1,0 -2215,1,0 -2216,1,0 -2217,1,0 -2218,1,0 -2219,1,0 -2220,1,0 -2221,1,0 -2222,1,0 -2223,1,0 -2224,1,0 -2225,1,0 -2226,1,0 -2227,1,0 -2228,1,0 -2229,1,0 -2230,1,0 -2231,1,0 -2232,1,0 -2233,1,0 -2234,1,0 -2235,1,0 -2236,1,0 -2237,1,0 -2238,1,0 -2239,1,0 -2240,1,0 -2241,1,0 -2242,1,0 -2243,1,0 -2244,1,0 -2245,1,0 -2246,1,0 -2247,1,0 -2248,1,0 -2249,1,0 -2250,1,0 -2251,1,0 -2252,1,0 -2253,1,0 -2254,1,0 -2255,1,0 -2256,1,0 -2257,1,0 -2258,1,0 -2259,1,0 -2260,1,0 -2261,1,0 -2262,1,0 -2263,1,0 -2264,1,0 -2265,1,0 -2266,1,0 -2267,1,0 -2268,1,0 -2269,1,0 -2270,1,0 -2271,1,0 -2272,1,0 -2273,1,0 -2274,1,0 -2275,1,0 -2276,1,0 -2277,1,0 -2278,1,0 -2279,1,0 -2280,1,0 -2281,1,0 -2282,1,0 -2283,1,0 -2284,1,0 -2285,1,0 -2286,1,0 -2287,1,0 -2288,1,0 -2289,1,0 -2290,1,0 -2291,1,0 -2292,1,0 -2293,1,0 -2294,1,0 -2295,1,0 -2296,1,0 -2297,1,0 -2298,1,0 -2299,1,0 -2300,1,0 -2301,1,0 -2302,1,0 -2303,1,0 -2304,1,0 -2305,1,0 -2306,1,0 -2307,1,0 -2308,1,0 -2309,1,0 -2310,1,0 -2311,1,0 -2312,1,0 -2313,1,0 -2314,1,0 -2315,1,0 -2316,1,0 -2317,1,0 -2318,1,0 -2319,1,0 -2320,1,0 -2321,1,0 -2322,1,0 -2323,1,0 -2324,1,0 -2325,1,0 -2326,1,0 -2327,1,0 -2328,1,0 -2329,1,0 -2330,1,0 -2331,1,0 -2332,1,0 -2333,1,0 -2334,1,0 -2335,1,0 -2336,1,0 -2337,1,0 -2338,1,0 -2339,1,0 -2340,1,0 -2341,1,0 -2342,1,0 -2343,1,0 -2344,1,0 -2345,1,0 -2346,1,0 -2347,1,0 -2348,1,0 -2349,1,0 -2350,1,0 -2351,1,0 -2352,1,0 -2353,1,0 -2354,1,0 -2355,1,0 -2356,1,0 -2357,1,0 -2358,1,0 -2359,1,0 -2360,1,0 -2361,1,0 -2362,1,0 -2363,1,0 -2364,1,0 -2365,1,0 -2366,1,0 -2367,1,0 -2368,1,0 -2369,1,0 -2370,1,0 -2371,1,0 -2372,1,0 -2373,1,0 -2374,1,0 -2375,1,0 -2376,1,0 -2377,1,0 -2378,1,0 -2379,1,0 -2380,1,0 -2381,1,0 -2382,1,0 -2383,1,0 -2384,1,0 -2385,1,0 -2386,1,0 -2387,1,0 -2388,1,0 -2389,1,0 -2390,1,0 -2391,1,0 -2392,1,0 -2393,1,0 -2394,1,0 -2395,1,0 -2396,1,0 -2397,1,0 -2398,1,0 -2399,1,0 -2400,1,0 -2401,1,0 -2402,1,0 -2403,1,0 -2404,1,0 -2405,1,0 -2406,1,0 -2407,1,0 -2408,1,0 -2409,1,0 -2410,1,0 -2411,1,0 -2412,1,0 -2413,1,0 -2414,1,0 -2415,1,0 -2416,1,0 -2417,1,0 -2418,1,0 -2419,1,0 -2420,1,0 -2421,1,0 -2422,1,0 -2423,1,0 -2424,1,0 -2425,1,0 -2426,1,0 -2427,1,0 -2428,1,0 -2429,1,0 -2430,1,0 -2431,1,0 -2432,1,0 -2433,1,0 -2434,1,0 -2435,1,0 -2436,1,0 -2437,1,0 -2438,1,0 -2439,1,0 -2440,1,0 -2441,1,0 -2442,1,0 -2443,1,0 -2444,1,0 -2445,1,0 -2446,1,0 -2447,1,0 -2448,1,0 -2449,1,0 -2450,1,0 -2451,1,0 -2452,1,0 -2453,1,0 -2454,1,0 -2455,1,0 -2456,1,0 -2457,1,0 -2458,1,0 -2459,1,0 -2460,1,0 -2461,1,0 -2462,1,0 -2463,1,0 -2464,1,0 -2465,1,0 -2466,1,0 -2467,1,0 -2468,1,0 -2469,1,0 -2470,1,0 -2471,1,0 -2472,1,0 -2473,1,0 -2474,1,0 -2475,1,0 -2476,1,0 -2477,1,0 -2478,1,0 -2479,1,0 -2480,1,0 -2481,1,0 -2482,1,0 -2483,1,0 -2484,1,0 -2485,1,0 -2486,1,0 -2487,1,0 -2488,1,0 -2489,1,0 -2490,1,0 -2491,1,0 -2492,1,0 -2493,1,0 -2494,1,0 -2495,1,0 -2496,1,0 -2497,1,0 -2498,1,0 -2499,1,0 -2500,1,0 \ No newline at end of file diff --git a/driver/run/rttov_channel_input_AIRSL1C_subset.csv b/driver/run/rttov_channel_input_AIRSL1C_subset.csv deleted file mode 100644 index 766ddd33ed..0000000000 --- a/driver/run/rttov_channel_input_AIRSL1C_subset.csv +++ /dev/null @@ -1,45 +0,0 @@ - 41 ,1 ,0 - 54 ,1 ,0 - 72 ,1 ,0 - 202 ,1 ,0 - 234 ,1 ,0 - 294 ,1 ,0 - 336 ,1 ,0 - 378 ,1 ,0 - 485 ,1 ,0 - 489 ,1 ,0 - 572 ,1 ,0 - 794 ,1 ,0 - 960 ,1 ,0 - 961 ,1 ,0 - 967 ,1 ,0 -1055 ,1 ,0 -1075 ,1 ,0 -1089 ,1 ,0 -1110 ,1 ,0 -1130 ,1 ,0 -1158 ,1 ,0 -1325 ,1 ,0 -1511 ,1 ,0 -1520 ,1 ,0 -1697 ,1 ,0 -1723 ,1 ,0 -1805 ,1 ,0 -1852 ,1 ,0 -1862 ,1 ,0 -1866 ,1 ,0 -1937 ,1 ,0 -2088 ,1 ,0 -2138 ,1 ,0 -2164 ,1 ,0 -2165 ,1 ,0 -2166 ,1 ,0 -2176 ,1 ,0 -2186 ,1 ,0 -2383 ,1 ,0 -2411 ,1 ,0 -2588 ,1 ,0 -2592 ,1 ,0 -2600 ,1 ,0 -2606 ,1 ,0 -2620 ,1 ,0 \ No newline at end of file diff --git a/driver/run/rttov_channel_input_AIRS_subset.csv b/driver/run/rttov_channel_input_AIRS_subset.csv deleted file mode 100644 index 3e56351ca9..0000000000 --- a/driver/run/rttov_channel_input_AIRS_subset.csv +++ /dev/null @@ -1,26 +0,0 @@ - 71 ,1 ,0 - 127 ,1 ,0 - 212 ,1 ,0 - 214 ,1 ,0 - 313 ,1 ,0 - 468 ,1 ,0 - 584 ,1 ,0 - 842 ,1 ,0 - 881 ,1 ,0 - 909 ,1 ,0 - 998 ,1 ,0 -1077 ,1 ,0 -1130 ,1 ,0 -1262 ,1 ,0 -1287 ,1 ,0 -1375 ,1 ,0 -1496 ,1 ,0 -1507 ,1 ,0 -1592 ,1 ,0 -1636 ,1 ,0 -1839 ,1 ,0 -1865 ,1 ,0 -1901 ,1 ,0 -2095 ,1 ,0 -2131 ,1 ,0 -2332 ,1 ,0 \ No newline at end of file diff --git a/driver/run/rttov_channel_input_MODIS16.csv b/driver/run/rttov_channel_input_MODIS16.csv deleted file mode 100644 index d6cf2cb824..0000000000 --- a/driver/run/rttov_channel_input_MODIS16.csv +++ /dev/null @@ -1,16 +0,0 @@ -20,1,0 -21,1,0 -22,1,0 -23,1,0 -24,1,0 -25,1,0 -27,1,0 -28,1,0 -29,1,0 -30,1,0 -31,1,0 -32,1,0 -33,1,0 -34,1,0 -35,1,0 -36,1,0 \ No newline at end of file diff --git a/driver/run/rttov_channel_input_PREFIRE_subset.csv b/driver/run/rttov_channel_input_PREFIRE_subset.csv deleted file mode 100644 index 10d0447249..0000000000 --- a/driver/run/rttov_channel_input_PREFIRE_subset.csv +++ /dev/null @@ -1,55 +0,0 @@ -4,1,0 -5,1,0 -6,1,0 -7,1,0 -8,1,0 -11,1,0 -12,1,0 -13,1,0 -14,1,0 -15,1,0 -16,1,0 -17,1,0 -20,1,0 -21,1,0 -22,1,0 -23,1,0 -24,1,0 -25,1,0 -26,1,0 -27,1,0 -28,1,0 -29,1,0 -30,1,0 -31,1,0 -32,1,0 -33,1,0 -34,1,0 -35,1,0 -38,1,0 -39,1,0 -40,1,0 -41,1,0 -42,1,0 -43,1,0 -44,1,0 -45,1,0 -46,1,0 -47,1,0 -48,1,0 -49,1,0 -50,1,0 -51,1,0 -52,1,0 -53,1,0 -54,1,0 -55,1,0 -56,1,0 -57,1,0 -58,1,0 -59,1,0 -60,1,0 -61,1,0 -62,1,0 -63,1,0 -64,1,0 \ No newline at end of file diff --git a/driver/run/rttov_channel_input_VIIRS_subset.csv b/driver/run/rttov_channel_input_VIIRS_subset.csv deleted file mode 100644 index ccc407dcfd..0000000000 --- a/driver/run/rttov_channel_input_VIIRS_subset.csv +++ /dev/null @@ -1,2 +0,0 @@ -12,1,0 -13,1,0 \ No newline at end of file diff --git a/src/simulator/rttov/cosp_rttov.F90 b/src/simulator/rttov/cosp_rttov.F90 deleted file mode 100644 index 5bde602bbd..0000000000 --- a/src/simulator/rttov/cosp_rttov.F90 +++ /dev/null @@ -1,592 +0,0 @@ -! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -! Copyright (c) 2015, Regents of the University of Colorado -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are -! permitted provided that the following conditions are met: -! -! 1. Redistributions of source code must retain the above copyright notice, this list of -! conditions and the following disclaimer. -! -! 2. Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other -! materials provided with the distribution. -! -! 3. Neither the name of the copyright holder nor the names of its contributors may be -! used to endorse or promote products derived from this software without specific prior -! written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -! MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -! THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -! OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -! -! History: -! Aug 2008 - V. John - Initial version -! Jun 2010 - A. Bodas-Salcedo - Conversion to module and tidy up -! May 2015 - D. Swales - Modified for COSPv2.0 -! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -MODULE MOD_COSP_RTTOV - USE COSP_KINDS, ONLY: wp - USE MOD_COSP_CONFIG, ONLY: RTTOV_MAX_CHANNELS - USE RTTOV_CONST, only: errorstatus_fatal, errorstatus_warning, errorstatus_success - USE RTTOV_TYPES, only: rttov_coef, profile_type, transmission_type, & - radiance_type, rttov_coef_scatt_ir, rttov_optpar_ir - USE PARKIND1, Only : jpim, jprb - IMPLICIT NONE - - ! Include subroutine interfaces - include "rttov_errorreport.interface" - include "rttov_setup.interface" - include "rttov_errorhandling.interface" - include "rttov_direct.interface" - include "rttov_alloc_prof.interface" - include "rttov_alloc_rad.interface" - include "rttov_dealloc_coef.interface" - - ! Fields set during initialization - integer :: & - nch_in, & ! Number of RTTOV channels - plat_in, & ! RTTOV platform - sat_in, & ! RTTOV satellite - sens_in ! RTTOV instrument - integer,dimension(RTTOV_MAX_CHANNELS) :: & - ichan_in ! RTTOV channel indices - -CONTAINS - - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE RTTOV_PIXEL - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - SUBROUTINE RTTOV_subcolumn(surfem_in, prf_num_in, nlevels_in, & - zenang_in, p_in,t_in, q_in, o3_in, co2_in, & - ch4_in, n2o_in, co_in, h_surf, u_surf, & - v_surf, t_skin, p_surf, t_surf, q_surf, & - lsmask, latitude, tbs) - ! INPUTS - integer,intent(in) :: & - prf_num_in, & ! Number of profiles to simulate - nlevels_in ! Number of pressure levels - real(wp),intent(in) :: & - zenang_in, & ! Satellite zenith angle - co2_in, & ! Carbon dioxide - ch4_in, & ! Methane - n2o_in, & ! n2o - co_in ! Carbon monoxide - real(wp),intent(in),dimension(nch_in) :: & - surfem_in ! Surface emissivities for the channels - real(wp),intent(in),dimension(prf_num_in) :: & - h_surf, & ! Surface height - u_surf, & ! U component of surface wind - v_surf, & ! V component of surface wind - t_skin, & ! Surface skin temperature - p_surf, & ! Surface pressure - t_surf, & ! 1.5 m Temperature - q_surf, & ! 1.5 m Specific humidity - lsmask, & ! land-sea mask - latitude ! Latitude - real(wp),intent(in),dimension(prf_num_in,nlevels_in) :: & - p_in, & ! Pressure profiles - t_in, & ! Temperature profiles - q_in, & ! Humidity profiles - o3_in ! Ozone profiles - - ! OUTPUTS - real(wp),intent(inout),dimension(prf_num_in,nch_in) :: & - tbs ! Tbs (in the right format) - - ! LOCAL VARIABLES - type(transmission_type) :: transmission - type(radiance_type) :: radiance - type(rttov_coef ), allocatable, dimension(:) :: coef - type(profile_type), allocatable, dimension(:) :: profiles - type(rttov_coef_scatt_ir),allocatable, dimension(:) :: coef_scatt_ir - type(rttov_optpar_ir), allocatable, dimension(:) :: optp - Integer(Kind=jpim), Allocatable, dimension(:,:) :: & - instrument, & ! Instrument id - nchan, & ! Number of channels per instrument and profile - ichan ! Channel list per instrument - Integer(Kind=jpim), Allocatable, dimension(:) :: & - nchan1, & ! Number of channels per instrument and profile - nchannels, & ! Number of channels per instrument - ifull, & ! Full test (with TL,AD,K) per instrument - nprof, & ! Number of profiles per instrument - nsurf, & ! Surface id number per instrument - nwater, & ! Water id number per instrument - channels, & ! Channel list per instrument*profiles - lprofiles, & ! - rttov_errorstatus, & ! rttov error return code - setup_errorstatus ! Setup return code - Integer(Kind=jpim) :: & - nprofiles,iref,isun,asw,mxchn,i,j,jch,errorstatus,io_status,ioout,interp, & - Err_Unit, & ! Logical error unit (<0 for default) - verbosity_level, & ! (<0 for default) - nrttovid, & ! Maximum number of instruments - no_id, & ! Instrument loop index - Nprofs, & ! Number of calls to RTTOV - nch ! Intermediate variable - Integer(Kind=jpim), Parameter :: & - jpnav = 31, & ! Number of profile variables - jpnsav = 6, & ! Number of surface air variables - jpnssv = 6, & ! Number of skin variables - jpncv = 2, & ! Number of cloud variables - sscvar = jpnsav+jpnssv+jpncv ! Number of surface,skin,cloud vars - Integer(Kind=jpim),dimension(60) :: & - alloc_status - Real(Kind=jprb) :: & - zenang, azang, sunzang, sunazang - Real(kind=jprb), allocatable, dimension(:) :: & - emissivity,fresnrefl,input_emissivity - Real(kind=jprb), allocatable, dimension(:,:) :: & - surfem - Real(Kind=jprb),dimension(nch_in*prf_num_in) :: & - tbs_temp ! A temporary variable to hold Tbs - Character (len=3) :: & - cref, csun - Character (len=80) :: & - errMessage - Character (len=14) :: & - NameOfRoutine = 'rttov_multprof' - Logical :: addinterp,refrac,solrad,laerosl,lclouds,lsun,all_channels - Logical,Allocatable,dimension(:) :: & - calcemis - integer(kind=jpim) :: prof_num,nlevels - - ! Type-casting of input arguments that need to be passed to RTTOV - prof_num = prf_num_in - nlevels = nlevels_in - - ! Unit numbers for input/output - IOOUT = 2 - - ! Curretly we plan to calculate only 1 instrument per call - nrttovid = 1 - mxchn = nch_in - errorstatus = 0 - alloc_status(:) = 0 - all_channels = .false. - sunzang = 0._jprb - sunazang = 0._jprb - - ! Initialise error management with default value for - ! the error unit number and Fatal error message output - Err_unit = -1 - verbosity_level = 0 - - ! All error message output - call rttov_errorhandling( Err_unit, verbosity_level, print_checkinput_warnings=.false. ) - io_status = 0 - errmessage = '' - - ! Assigning the zenith angle - zenang = zenang_in - - ! Allocate - allocate (coef(nrttovid), stat = alloc_status(1)) - allocate (coef_scatt_ir(nrttovid),stat = alloc_status(2)) - allocate (optp(nrttovid), stat = alloc_status(3)) - allocate (instrument(3,nrttovid), stat = alloc_status(4)) - allocate (ifull(nrttovid), stat = alloc_status(5)) - allocate (nprof(nrttovid), stat = alloc_status(6)) - allocate (nsurf(nrttovid), stat = alloc_status(7)) - allocate (nwater(nrttovid), stat = alloc_status(8)) - allocate (nchannels(nrttovid), stat = alloc_status(9)) - allocate (nchan1(nrttovid), stat = alloc_status(10)) - allocate (surfem(mxchn,nrttovid), stat = alloc_status(11)) - allocate (ichan (mxchn,nrttovid), stat = alloc_status(12)) - If( any(alloc_status /= 0) ) then - errorstatus = errorstatus_fatal - Write( errMessage, '( "mem allocation error")' ) - Call Rttov_ErrorReport (errorstatus, errMessage, NameOfRoutine) - Stop - End If - surfem(:,:) = 0.0_JPRB - ichan(:,:) = 0 - - !!! FIXME: Shall we get rid of this loop? We use only one instrument - DO NO_ID = 1, NRTTOVID - instrument(1,no_id) = plat_in - instrument(2,no_id) = sat_in - instrument(3,no_id) = sens_in - - !! Forward model only (0) or TL and AD (1) or K (2)?' - ! This version supports only Forward model - IFULL(no_id) = 0 - - ! Number of profiles to test per call - NPROF(no_id) = prof_num - nprofiles = NPROF(no_id) - - ! Total number of profiles to process - NPROFS = prof_num - NPROFS = NPROFS / NPROF(no_id) ! Number of calls to RTTOV - - ! Check whether it is OK to use ocean all the time - NWATER(no_id) = 1 ! Water type (0=fresh water, 1=ocean water) - - ! Set up channel numbers - allocate (nchan(nprof(no_id),nrttovid),stat= alloc_status(3)) - nchan(1:nprof(no_id),no_id) = nch_in - ichan(:, 1) = ichan_in - surfem(:, 1) = surfem_in - - ! nchan(1,no_id) is now the real number of channels selected - do j = 1 , nprof(no_id) - nchan(j,no_id) = nch_in - enddo - - ! Compute channels*profiles - nchannels(no_id) = 0 - Do j = 1 , nprof(no_id) - nchannels(no_id) = nchannels(no_id) + nchan (j,no_id) - End Do - nchan1(no_id) = nchan(1,no_id) - END DO - - ! Do you want clouds or aerosol? - laerosl = .False. - lclouds = .False. - - !######################################################### - ! Beginning of rttov_setup test - !######################################################### - alloc_status = 0 - allocate ( setup_errorstatus(nrttovid),stat= alloc_status(1)) - If( any(alloc_status /= 0) ) then - errorstatus = errorstatus_fatal - Write( errMessage, '( "mem allocation error for errorsetup")' ) - Call Rttov_ErrorReport (errorstatus, errMessage, NameOfRoutine) - Stop - End If - - If (all_channels)Then - Call rttov_setup ( & - setup_errorstatus, &! out - Err_unit, &! in - verbosity_level, &! in - nrttovid, &! in - laerosl, &! in - lclouds, &! in - coef, &! out - coef_scatt_ir, &! out - optp, & - instrument) ! in - Else - Call rttov_setup ( & - setup_errorstatus, &! out - Err_unit, &! in - verbosity_level, &! in - nrttovid, &! in - laerosl, &! in - lclouds, &! in - coef, &! out - coef_scatt_ir, &! out - optp, & - instrument, &! in - ichan ) ! in Optional - Endif - - if(any(setup_errorstatus(:) /= errorstatus_success ) ) then - print*, 'rttov_setup fatal error' - stop - endif - - deallocate( setup_errorstatus ,stat=alloc_status(1)) - If( any(alloc_status /= 0) ) then - errorstatus = errorstatus_fatal - Write( errMessage, '( "mem deallocation error for setup_errorstatus")' ) - Call Rttov_ErrorReport (errorstatus, errMessage, NameOfRoutine) - Stop - End If - - DO no_id = 1, NRTTOVID - if( any(coef(no_id)%ff_val_chn( : ) /= 1 )) then - WRITE(*,*) ' some requested channels have bad validity parameter' - do i = 1, nchan1(no_id) - write(*,*) i, coef(no_id)%ff_val_chn(i) - end do - endif - End Do - - DO no_id = 1, NRTTOVID - - !######################################################### - ! Allocate memory for RTTOV_DIRECT - !######################################################### - allocate( rttov_errorstatus(nprof(no_id)),stat= alloc_status(3)) - - ! Allocate profiles - allocate( profiles(nprof(no_id)),stat= alloc_status(1)) - - ! Allow profile interpolation - interp = 1 - - if(interp == 0) addinterp = .false. - if(interp == 1) addinterp = .true. - asw = 1 - - call rttov_alloc_prof ( & - errorstatus, & - nprof(no_id), & - profiles, & - nlevels, & - coef_scatt_ir(no_id), & - asw, & - addclouds = lclouds, & - addaerosl = laerosl, & - init = .true. ) - - - Do j = 1 , nprof(no_id) - profiles(j) % nlevels = nlevels - Enddo - - alloc_status = 0_jpim - ! number of channels per RTTOV call is only nchannels - allocate(lprofiles (nchannels(no_id)), stat = alloc_status(9)) - allocate(channels (nchannels(no_id)), stat = alloc_status(10)) - allocate(emissivity (nchannels(no_id)), stat = alloc_status(12)) - allocate(fresnrefl (nchannels(no_id)), stat = alloc_status(13)) - allocate(input_emissivity(nchannels(no_id)), stat = alloc_status(14)) - allocate(calcemis (nchannels(no_id)), stat = alloc_status(15)) - - ! allocate transmittance arrays with number of channels - allocate( transmission % tau_layers (profiles(1) % nlevels,nchannels(no_id) ), & - stat= alloc_status(11)) - allocate( transmission % tau_total (nchannels(no_id) ) , & - stat= alloc_status(12)) - - If( Any(alloc_status /= 0) ) Then - errorstatus = errorstatus_fatal - Write( errMessage, '( "allocation of transmission")' ) - Call Rttov_ErrorReport (errorstatus_fatal, errMessage, NameOfRoutine) - !IF (LHOOK) CALL DR_HOOK('RTTOV_DIRECT',1,ZHOOK_HANDLE) - Stop - End If - - transmission % tau_layers = 0._jprb - transmission % tau_total = 0._jprb - - ! Allocate radiance results arrays with number of channels - asw = 1 ! allocate - call rttov_alloc_rad (errorstatus,nchannels(no_id),radiance, & - profiles(1)%nlevels,asw) - - AZANG = 0 - ISUN = 0 - IREF = 1 - - if(iref==0)then - cref='NO' - refrac=.False. - else if(iref==1)then - cref='YES' - refrac=.True. - endif - - if(sunzang<=87._JPRB)then - solrad=.True. - else - solrad=.False. - endif - - if(isun==1)then - lsun=.true. - if(sunzang<=87._JPRB)then - csun='YES' - solrad=.True. - else - csun='NO' - solrad=.False. - endif - else - csun='NO' - solrad=.False. - endif - - do i = 1, NPROF(no_id) - profiles(i) % p(:) = p_in(i, :) - profiles(i) % t(:) = t_in(i, :) - profiles(i) % q(:) = q_in(i, :) - profiles(i) % o3(:) = o3_in(i, :) - profiles(i) % co2(:) = co2_in - profiles(i) % ch4(:) = ch4_in - profiles(i) % n2o(:) = n2o_in - profiles(i) % co(:) = co_in - profiles(i) % ozone_Data = .False. - profiles(i) % co2_Data = .True. - profiles(i) % n2o_data = .True. - profiles(i) % ch4_Data = .True. - profiles(i) % co_Data = .True. - - !FIXME: Make Cloud variables as passing ones if we go for all sky - profiles(i) % cfraction = 0. - profiles(i) % ctp = 500. - profiles(i) % clw_Data = .False. - - ! 2m parameters - profiles(i) % s2m % p = p_surf(i) - profiles(i) % s2m % t = t_in(i, 1) - profiles(i) % s2m % q = q_in(i, 1) - profiles(i) % s2m % u = 2 - profiles(i) % s2m % v = 2 - - ! Skin variables for emissivity calculations - profiles(i) % skin % t = t_skin(i) - profiles(i) % skin % fastem(1) = 3.0 - profiles(i) % skin % fastem(2) = 5.0 - profiles(i) % skin % fastem(3) = 15.0 - profiles(i) % skin % fastem(4) = 0.1 - profiles(i) % skin % fastem(5) = 0.3 - - profiles(i) % zenangle = zenang - profiles(i) % azangle = azang - profiles(i) % latitude = latitude(i) - profiles(i) % elevation = h_surf(i) - profiles(i) % sunzenangle = SUNZANG - profiles(i) % sunazangle = SUNAZANG - profiles(i) % addsolar = solrad - profiles(i) % addrefrac = refrac - ! surface type - profiles(i) % skin % surftype = lsmask(i) - !! FIXME: Check this one - profiles(i) % skin % watertype = nwater(no_id) - profiles(i) % aer_data = laerosl - profiles(i) % cld_data = lclouds - profiles(i) %idg = 0._jprb - profiles(i) %ish = 0._jprb - if( lclouds ) then - profiles(i) %cloud(:,:) = 0._jprb - profiles(i) %cfrac(:,:) = 0._jprb - endif - enddo - - ! Build the list of channels/profiles indices - emissivity(:) = 0.0_JPRB - channels(:) = 0_jpim - lprofiles(:) = 0_jpim - nch = 0_jpim - Do j = 1 , nprof(no_id) - DO jch = 1,nchan1(no_id) - nch = nch +1_jpim - lprofiles ( nch ) = j - if (all_channels)then - channels( nch ) = ichan(jch,no_id) - else - channels( nch ) = jch - endif - emissivity( nch ) = surfem(jch,no_id) - End Do - End Do - - input_emissivity(:) = emissivity(:) - calcemis(:) = emissivity(:) < 0.01_JPRB - - ! FIXME: Check this one with Roger - do j = 1 , NPROFS - call rttov_direct( & - & rttov_errorstatus, &! out - & nprof(no_id), &! in - & nchannels(no_id), &! in - & channels, &! in - & lprofiles, &! in - & addinterp, &! in - & profiles, &! in - & coef(no_id), &! in - & coef_scatt_ir(no_id), & - & optp(no_id) , & - & lsun, &! in - & laerosl, &! in - & lclouds, &! in - & calcemis, &! in - & emissivity, &! inout - & transmission, &! out - & radiance ) ! inout - enddo - - ! Initialising tbs array - tbs(:, :) = 0.0 - tbs_temp(:) = 0.0 - tbs_temp = radiance%bt - - do i = 1, prof_num - tbs(i, :) = tbs_temp((i-1)*nch_in+1:i*nch_in) - enddo - - - If ( any( rttov_errorstatus(:) == errorstatus_warning ) ) Then - Do j = 1, nprof(no_id) - If ( rttov_errorstatus(j) == errorstatus_warning ) Then - write ( ioout, * ) 'rttov warning for profile', j - End If - End Do - End If - - If ( any( rttov_errorstatus(:) == errorstatus_fatal ) ) Then - Do j = 1, nprof(no_id) - If ( rttov_errorstatus(j) == errorstatus_fatal ) Then - write ( ioout, * ) 'rttov error for profile',j - End If - End Do - Stop - End If - - ! Deallocate - ! number of channels per RTTOV call is only nchannels - deallocate( channels ,stat=alloc_status(2)) - deallocate( lprofiles ,stat=alloc_status(3)) - deallocate( emissivity ,stat=alloc_status(4)) - deallocate( fresnrefl ,stat=alloc_status(5)) - deallocate( calcemis ,stat=alloc_status(6)) - deallocate( input_emissivity ,stat= alloc_status(14)) - If( any(alloc_status /= 0) ) then - errorstatus = errorstatus_fatal - Write( errMessage, '( "mem deallocation error for channels etc")' ) - Call Rttov_ErrorReport (errorstatus, errMessage, NameOfRoutine) - Stop - End If - - asw = 0 ! deallocate radiance arrays - call rttov_alloc_rad (errorstatus,nchan1(no_id),radiance,profiles(1) % nlevels,asw) - If(errorstatus /= errorstatus_success) Then - Write( errMessage, '( "deallocation error for radiances")' ) - Call Rttov_ErrorReport (errorstatus, errMessage, NameOfRoutine) - Endif - - ! deallocate transmittances - Deallocate( transmission % tau_total ,stat= alloc_status(7)) - Deallocate( transmission % tau_layers ,stat= alloc_status(8)) - If(errorstatus /= errorstatus_success) Then - Write( errMessage, '( "deallocation error for transmittances")' ) - Call Rttov_ErrorReport (errorstatus, errMessage, NameOfRoutine) - Stop - Endif - - asw = 0 ! deallocate profile arrays - call rttov_alloc_prof (errorstatus,nprof(no_id),profiles,profiles(1)%nlevels,coef_scatt_ir(no_id),asw,& - & addclouds = lclouds, addaerosl = laerosl ) - deallocate( profiles,stat=alloc_status(1)) - If( any(alloc_status /= 0) ) then - errorstatus = errorstatus_fatal - Write( errMessage, '( "mem deallocation error for profiles")' ) - Call Rttov_ErrorReport (errorstatus, errMessage, NameOfRoutine) - Stop - End If - - EndDo - - DO no_id = 1, NRTTOVID - Call rttov_dealloc_coef (errorstatus, coef(no_id),coef_scatt_ir(no_id),optp(no_id)) - If(errorstatus /= errorstatus_success) Then - Write( errMessage, '( "deallocation error for coeffs")' ) - Call Rttov_ErrorReport (errorstatus, errMessage, NameOfRoutine) - Endif - EndDo - - END SUBROUTINE RTTOV_SUBCOLUMN -END MODULE MOD_COSP_RTTOV diff --git a/src/simulator/rttov/cosp_rttov11.F90 b/src/simulator/rttov/cosp_rttov11.F90 deleted file mode 100644 index 94d82379c5..0000000000 --- a/src/simulator/rttov/cosp_rttov11.F90 +++ /dev/null @@ -1,1060 +0,0 @@ -! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -! Copyright (c) 2016, Regents of the University of Colorado -! All rights reserved. -! -! Redistribution and use in source and binary forms, with or without modification, are -! permitted provided that the following conditions are met: -! -! 1. Redistributions of source code must retain the above copyright notice, this list of -! conditions and the following disclaimer. -! -! 2. Redistributions in binary form must reproduce the above copyright notice, this list -! of conditions and the following disclaimer in the documentation and/or other -! materials provided with the distribution. -! -! 3. Neither the name of the copyright holder nor the names of its contributors may be -! used to endorse or promote products derived from this software without specific prior -! written permission. -! -! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -! EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -! MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -! THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -! OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -! -! History -! March 2016 - M. Johnston - Original version -! April 2016 - D. Swales - Modified for use in COSPv2.0 -! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -module mod_cosp_rttov - use rttov_const, only : errorstatus_success, errorstatus_fatal - use rttov_types, only : rttov_options,rttov_coefs,profile_type, & - transmission_type,radiance_type,rttov_chanprof, & - rttov_emissivity,profile_cloud_type,rttov_scatt_coef, & - rttov_options_scatt - use rttov_const, only : surftype_sea, surftype_land, surftype_seaice - use rttov_unix_env, only : rttov_exit - use cosp_kinds, only : wp - use mod_cosp_config, only : RTTOV_MAX_CHANNELS,N_HYDRO,rttovDir - use cosp_phys_constants, only : mdry=>amd,mO3=>amO3,mco2=>amCO2,mCH4=>amCH4, & - mn2o=>amN2O,mco=>amCO - implicit none -#include "rttov_direct.interface" -#include "rttov_alloc_prof.interface" -#include "rttov_alloc_rad.interface" -#include "rttov_alloc_transmission.interface" -#include "rttov_dealloc_coefs.interface" -#include "rttov_user_options_checkinput.interface" -#include "rttov_read_coefs.interface" -#include "rttov_get_emis.interface" -#include "rttov_boundaryconditions.interface" - - ! Module parameters - integer, parameter :: maxlim = 10000 - real(wp),parameter :: eps = 0.622 - - ! Initialization parameters - integer :: & - platform, & ! RTTOV platform - sensor, & ! RTTOV instrument - satellite, & ! RTTOV satellite - nChannels ! Number of channels - integer,dimension(RTTOV_MAX_CHANNELS) :: & - iChannel ! RTTOV channel numbers - - ! Scattering coefficients (read in once during initialization) - type(rttov_coefs) :: & - coef_rttov - type(rttov_scatt_coef) :: & - coef_scatt - ! RTTOV setup and options (set during initialization) - type(rttov_options) :: & - opts ! defaults to everything optional switched off - type(rttov_options_scatt) :: & - opts_scatt -contains - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE rttov_column - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine rttov_column(nPoints,nLevels,nSubCols,q,p,t,o3,ph,h_surf,u_surf,v_surf, & - p_surf,t_skin,t2m,q2m,lsmask,lon,lat,seaice,co2,ch4,n2o,co, & - zenang,lCleanup, & - ! Outputs - Tb,error, & - ! Optional arguments for surface emissivity calculation. - surfem,month, & - ! Optional arguments for all-sky calculation. - tca,ciw,clw,rain,snow) - ! Inputs - integer,intent(in) :: & - nPoints, & ! Number of gridpoints - nLevels, & ! Number of vertical levels - nSubCols ! Number of subcolumns - real(wp),intent(in) :: & - co2, & ! CO2 mixing ratio (kg/kg) - ch4, & ! CH4 mixing ratio (kg/kg) - n2o, & ! N2O mixing ratio (kg/kg) - co, & ! CO mixing ratio (kg/kg) - zenang ! Satellite zenith angle - real(wp),dimension(nPoints),intent(in) :: & - h_surf, & ! Surface height (m) - u_surf, & ! Surface u-wind (m/s) - v_surf, & ! Surface v-wind (m/s) - p_surf, & ! Surface pressure (Pa) - t_skin, & ! Skin temperature (K) - t2m, & ! 2-meter temperature (K) - q2m, & ! 2-meter specific humidity (kg/kg) - lsmask, & ! Land/sea mask - lon, & ! Longitude (deg) - lat, & ! Latitude (deg) - seaice ! Seaice fraction (0-1) - real(wp),dimension(nPoints,nLevels),intent(in) :: & - q, & ! Specific humidity (kg/kg) - p, & ! Pressure(Pa) - t, & ! Temperature (K) - o3 ! Ozone - real(wp),dimension(nPoints,nLevels+1),intent(in) :: & - ph ! Pressure @ half-levels (Pa) - logical,intent(in) :: & - lCleanup ! Flag to determine whether to deallocate RTTOV types - - ! Optional inputs (Needed for surface emissivity calculation) - integer,optional :: & - month ! Month (needed to determine table to load) - real(wp),dimension(nChannels),optional :: & - surfem ! Surface emissivity for each RTTOV channel - - ! Optional inputs (Needed for all-sky calculation) - real(wp),dimension(nPoints,nLevels),optional :: & - tca ! Total column cloud amount (0-1) - real(wp),dimension(nPoints,nSubCols,nLevels),optional :: & - ciw, & ! Cloud ice - clw, & ! Cloud liquid - rain, & ! Precipitation flux (kg/m2/s) - snow ! Precipitation flux (kg/m2/s) - - ! Outputs - real(wp),dimension(nPoints,nChannels) :: & - Tb ! RTTOV brightness temperature. - character(len=128) :: & - error ! Error messages (only populated if error encountered) - - ! Local variables - integer :: & - nloop,rmod,il,istart,istop,za,i,j,subcol,errorstatus,npts_it - integer,dimension(60) :: & - alloc_status - real(wp),dimension(nPoints) :: & - sh_surf - real(wp),dimension(nPoints,nLevels) :: & - sh,totalice - real(wp),dimension(nSubCols,nPoints,nChannels) :: & - Tbs ! Subcolumn brightness temperature - logical :: & - use_totalice, mmr_snowrain, cfrac - logical :: & - lallSky, & ! Control for type of brightness temperature calculation - ! (False(default) => clear-sky brightness temperature, True => All-sky) - lsfcEmis ! Control for surface emissivity calculation (true => compute surface emissivity, - ! provided that the field "month" is available) - -#include "rttov_read_coefs.interface" -#include "rttov_read_scattcoeffs.interface" -#include "rttov_user_options_checkinput.interface" -#include "rttov_dealloc_coefs.interface" -#include "rttov_dealloc_scattcoeffs.interface" -#include "rttov_setup_emis_atlas.interface" -#include "rttov_deallocate_emis_atlas.interface" -#include "rttov_print_opts.interface" -#include "rttov_print_profile.interface" -#include "rttov_boundaryconditions.interface" - - ! Initialize some things - totalice = 0._wp - Tbs(:,:,:) = 0._wp - Tb(:,:) = 0._wp - error = '' - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Setup for call to RTTOV - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! First, check to see if we are doing an all-sky or clear-sky calculation brightness - ! temperature - lallSky = .false. - if (present(tca) .and. present(clw) .and. present(ciw) .and. present(rain) & - .and. present(snow)) lallSky=.true. - - ! Check to see if we need to compute the surface emissivity (defualt is to compute - ! surface emissivity using the atlas tables) - lsfcEmis = .true. - if (present(surfem)) lsfcEmis = .false. - - ! We also need the month for the emissivity atlas, so check... - if (.not. present(month)) lsfcEmis = .false. - - if (lsfcEmis .eq. .false. .and. .not. present(surfem)) then - error = 'ERROR (rttov_column): User did not provide surface emissivity and did not '//& - 'request the surface emissivity to be calculated!!!' - return - endif - - ! Convert specific humidity to ppmv - sh = ( q / ( q + eps * ( 1._wp - q ) ) ) * 1e6 - sh_surf = ( q2m / ( q2m + eps * ( 1._wp - q2m ) ) ) * 1e6 - - ! Settings unique to all-sky call. - use_totalice = .false. - mmr_snowrain = .true. - cfrac = .true. - opts_scatt%lusercfrac = cfrac - - ! RTTOV can handle only about 100 profiles at a time (fixme: check this with roger), - ! so we are putting a loop of 100 - nloop = npoints / maxlim - rmod = mod( npoints, maxlim ) - if( rmod .ne. 0 ) then - nloop = nloop + 1 - endif - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Initialize emissivity atlas data for chosen sensor. - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - call rttov_setup_emis_atlas(errorstatus,opts,month,coef_rttov,path=trim(rttovDir)//"emis_data/") - if (errorstatus /= errorstatus_success) then - error = 'ERROR (rttov_column): Error reading emis atlas data!' - return - endif - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Some quality control prior to RTTOV call - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Ensure the options and coefficients are consistent - if(opts_scatt%config%do_checkinput) then - call rttov_user_options_checkinput(errorstatus, opts, coef_rttov) - if (errorstatus /= errorstatus_success) then - error = 'ERROR (rttov_column): Error when checking input data!' - return - endif - endif - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Call to RTTOV - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Looping over maxlim number of profiles - do il = 1, nloop - istart = (il - 1) * maxlim + 1 - istop = min(il * maxlim, npoints) - if( ( il .eq. nloop ) .and. ( rmod .ne. 0 ) ) then - npts_it = rmod - else - npts_it = maxlim - endif - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! Clear-sky brightness temperature - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - if (.not. lallSky) then - call rttov_multprof(nChannels,iChannel,surfem,npts_it,nLevels,platform, & - satellite,sensor,opts,coef_rttov,zenang, & - p(istart:istop,:)/100._wp,t(istart:istop,:), & - sh(istart:istop,:),(mdry/mo3)*o3(istart:istop,:)*1e6, & - (mdry/mco2)*co2*1e6,(mdry/mch4)*ch4*1e6,(mdry/mn2o)*n2o*1e6,& - (mdry/mco)*co*1e6,h_surf(istart:istop),u_surf(istart:istop),& - v_surf(istart:istop),t_skin(istart:istop), & - p_surf(istart:istop)/100.,t2m(istart:istop), & - sh_surf(istart:istop),lsmask(istart:istop), & - seaice(istart:istop),lat(istart:istop),lon(istart:istop), & - Tb(istart:istop,:)) - endif - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! All-sky brightness temperature - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - if (lallSky) then - ! Loop over all subcolumns - do subcol = 1, nSubCols - ! Call RTTOV - call cosp_rttov_mwscatt(nChannels,iChannel,surfem,nPoints,nlevels,platform, & - satellite,sensor,opts,opts_scatt,coef_rttov, & - coef_scatt,zenang,p(istart:istop,:)/100._wp, & - ph(istart:istop,:)/100._wp,t(istart:istop, :), & - sh(istart:istop, :), & - (mdry/mo3)*o3(istart:istop,:)*1e6, & - clw(istart:istop,subcol,:), & - ciw(istart:istop,subcol,:),tca(istart:istop, :), & - totalice(istart:istop,:),snow(istart:istop,subcol,:),& - rain(istart:istop,subcol,:),(mdry/mco2)*co2*1e6, & - (mdry/mch4)*ch4*1e6,(mdry/mn2o)*n2o*1e6, & - (mdry/mco)*co*1e6,h_surf(istart:istop), & - u_surf(istart:istop),v_surf(istart:istop), & - t_skin(istart:istop), p_surf(istart:istop)/100., & - t2m(istart:istop),sh_surf(istart:istop), & - lsmask(istart:istop),seaice(istart:istop), & - lat(istart:istop),lon(istart:istop), use_totalice, & - mmr_snowrain,cfrac,Tbs(subcol,istart:istop,:)) - enddo - endif - enddo - - ! For all-sky calculation we need to average together all of the cloudy subcolumns. - if (lallSky) then - do subcol = 1, nSubCols - Tb = Tb + tbs(subcol,:,:) - enddo - Tb = Tb/nSubCols - endif - - ! Free up space - if (lCleanup) then - call rttov_dealloc_coefs(errorstatus,coef_rttov) - call rttov_deallocate_emis_atlas(coef_rttov) - if (lallSky) call rttov_dealloc_scattcoeffs(coef_scatt) - endif - end subroutine rttov_column - - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - ! SUBROUTINE rttov_multprof - ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - subroutine rttov_multprof( & - nch_in, & ! number of channels - ichan_in, & ! channel indices - surfem_in, & ! surface emissivity values - prf_num_in, & ! number of profiles to simulate - nlevels_in, & ! number of pressure levels - plat_in, & ! platform number - sat_in, & ! satellite number - sens_in, & ! instrument number - opts, & - coef_rttov, & - zenang_in, & ! zenith angle - p_in, & ! pressure [hpa] - t_in, & ! temperature [ k ] - q_in, & ! specific humidity [ ppmv ] - o3_in, & ! ozone vmr [ ppmv ] - co2_in, & ! co2 vmr [ ppmv ] *this is a single value* - ch4_in, & ! ch4 vmr [ ppmv ] *this is a single value* - n2o_in, & ! n2o vmr [ ppmv ] *this is a single value* - co_in, & ! co vmr [ ppmv ] *this is a single value* - h_surf, & ! surface height [ m ] - u_surf, & ! u wind at 10 m [ m/s ] - v_surf, & ! v wind at 10 m [ m/s ] - t_skin, & ! skin temperatre [ k ] - p_surf, & ! surface pressure - t_surf, & ! 1.5 m temperature [ k ] - q_surf, & ! 1.5 m specific humidity [ ppmv ] - lsmask, & ! land sea mask - seaice, & ! seaice fraction - latitude, & ! latitude [ deg north ] - longitude, & ! longitude [ deg east ] - tbs & ! brightness temperature [ k ] (output) - ) - - !------ input arguments. no rttov kinds should be used here ----------------- - integer, intent(in) :: nch_in ! number of channels to be computed - integer, intent(in) :: ichan_in(nch_in) ! indices of selected channels - real(wp), intent(in) :: surfem_in(nch_in) ! surface emissivities for the channels - integer, intent(in) :: prf_num_in - integer, intent(in) :: nlevels_in - integer, intent(in) :: plat_in ! satellite platform - integer, intent(in) :: sat_in ! satellite number - integer, intent(in) :: sens_in ! satellite sensor - real(wp), intent(in) :: zenang_in ! satellite zenith angle - - type(rttov_options) :: opts - type(rttov_coefs) :: coef_rttov - - real(wp), intent(in) :: p_in(prf_num_in, nlevels_in) ! pressure profiles - real(wp), intent(in) :: t_in(prf_num_in, nlevels_in) ! temperature profiles - real(wp), intent(in) :: q_in(prf_num_in, nlevels_in) ! humidity profiles - real(wp), intent(in) :: o3_in(prf_num_in, nlevels_in) ! ozone profiles - - ! the following trace gases contain constant values - real(wp), intent(in) :: co2_in ! carbon dioxide - real(wp), intent(in) :: ch4_in ! methane - real(wp), intent(in) :: n2o_in ! n2o - real(wp), intent(in) :: co_in ! carbon monoxide - real(wp), intent(in) :: h_surf(prf_num_in) ! surface height - real(wp), intent(in) :: u_surf(prf_num_in) ! u component of surface wind - real(wp), intent(in) :: v_surf(prf_num_in) ! v component of surface wind - real(wp), intent(in) :: t_skin(prf_num_in) ! surface skin temperature - real(wp), intent(in) :: p_surf(prf_num_in) ! surface pressure - real(wp), intent(in) :: t_surf(prf_num_in) ! 1.5 m temperature - real(wp), intent(in) :: q_surf(prf_num_in) ! 1.5 m specific humidity - real(wp), intent(in) :: lsmask(prf_num_in) ! land-sea mask - real(wp), intent(in) :: seaice(prf_num_in) ! sea-ice fraction - real(wp), intent(in) :: latitude(prf_num_in) ! latitude - real(wp), intent(in) :: longitude(prf_num_in) ! longitude - - real(wp), intent(inout) :: tbs(prf_num_in, nch_in) ! tbs (in the right format) - - !------ local variables. use only rttov kinds or derived types. - ! logical variables are declared with the same kind - ! as integers, as they are affected inthe same way by flags like -qintsize=8 - - ! type(rttov_options) :: opts ! options structure - ! type(rttov_coefs), allocatable :: coefs(:) ! coefficients structure - type(rttov_chanprof), allocatable :: chanprof(:) ! input channel/profile list - type(profile_type), allocatable :: profiles(:) ! input profiles - logical, allocatable :: calcemis(:) ! flag to indicate calculation of emissivity within rttov - type(rttov_emissivity), allocatable :: emissivity(:) ! input/output surface emissivity - type(transmission_type) :: transmission ! output transmittances - type(radiance_type) :: radiance ! output radiances - - integer, allocatable :: instrument(:,:) ! instrument id (3 x n_instruments) - integer, allocatable :: nchan(:) ! number of channels per instrument - integer, allocatable :: ichan(:,:) ! channel list per instrument - - integer :: asw - integer :: mxchn - integer :: nrttovid ! maximum number of instruments - integer :: no_id ! instrument loop index - integer :: i, j, jch - integer :: nprof ! number of calls to rttov - integer :: nch ! intermediate variable - integer :: errorstatus - integer :: ich, ich_temp, nchanprof, nchannels, chan - integer :: alloc_status(60) - - real(wp), allocatable :: input_emissivity (:) - - character (len=14) :: nameofroutine = 'rttov_multprof' - - logical :: refrac, solrad, laerosl, lclouds, lsun, all_channels - - ! local variables for input arguments that need type casting to avoid type-mismatch with - ! rttov kinds. this happens with some compiler flags (-qintsize=8). - integer :: prof_num - integer :: nlevels - - ! -------------------------------------------------------------------------- - ! 0. initialise cosp-specific things - ! -------------------------------------------------------------------------- - - ! type-casting of input arguments that need to be passed to rttov - prof_num = prf_num_in - nlevels = nlevels_in - nprof = prof_num - - ! currently we plan to calculate only 1 instrument per call - nrttovid = 1 - mxchn = nch_in - - errorstatus = 0 - alloc_status(:) = 0 - - ! allocate(coefs(nrttovid), stat = alloc_status(1)) - - ! allocate(instrument(3, nrttovid), stat = alloc_status(4)) - - !maximum number of channels allowed for one instrument is mxchn - ! allocate(surfem(nch_in, nrttovid), stat = alloc_status(11)) - allocate(ichan(nch_in, nrttovid), stat = alloc_status(12)) - call rttov_error('ichan mem allocation error for profile array' , lalloc = .true.) - - - do no_id = 1, nrttovid - ichan(:, no_id) = ichan_in - enddo - - asw = 1 ! switch for allocation passed into rttov subroutines - - ! allocate input profile arrays - allocate(profiles(nprof), stat = alloc_status(1)) - call rttov_error('Profile mem allocation error' , lalloc = .true.) - - call rttov_alloc_prof( & - errorstatus, & - nprof, & - profiles, & - nlevels, & - opts, & - asw, & - coefs = coef_rttov, & - init = .true.) - call rttov_error('Profile 2 mem allocation error' , lalloc = .true.) - ! -------------------------------------------------------------------------- - ! 5. store profile data in profile type - ! -------------------------------------------------------------------------- - do i = 1, nprof - profiles(i)%p(:) = p_in(i, :) - profiles(i)%t(:) = t_in(i, :) - profiles(i)%q(:) = q_in(i, :) - - where(profiles(i)%q(:) < 1e-4) - profiles(i)%q(:) = 1e-4 - end where - - profiles(i)%cfraction = 0. - profiles(i)%ctp = 500. - - ! 2m parameters - profiles(i)%s2m%p = p_surf(i) - profiles(i)%s2m%t = t_surf(i) - profiles(i)%s2m%q = q_surf(i) - profiles(i)%s2m%u = u_surf(i) ! dar: hard-coded at 2ms-1? - profiles(i)%s2m%v = v_surf(i) ! dar: hard-coded at 2ms-1? - profiles(i)%s2m%wfetc = 10000. ! dar: default? - - ! skin variables for emissivity calculations - profiles(i)%skin%t = t_skin(i) - - ! fastem coefficients - for mw calculations - profiles(i)%skin%fastem(1) = 3.0 - profiles(i)%skin%fastem(2) = 5.0 - profiles(i)%skin%fastem(3) = 15.0 - profiles(i)%skin%fastem(4) = 0.1 - profiles(i)%skin%fastem(5) = 0.3 - - profiles(i)%zenangle = zenang_in ! pass in from cosp - - profiles(i)%azangle = 0. ! hard-coded in rttov9 int - - profiles(i)%latitude = latitude(i) - profiles(i)%longitude = longitude(i) - profiles(i)%elevation = h_surf(i) - - profiles(i)%sunzenangle = 0. ! hard-coded in rttov9 int - profiles(i)%sunazangle = 0. ! hard-coded in rttov9 int - - ! surface type - ! land-sea mask indicates proportion of land in grid - if (lsmask(i) < 0.5) then - profiles(i)%skin%surftype = surftype_sea - else - profiles(i)%skin%surftype = surftype_land - endif - ! sea-ice fraction - if (seaice(i) >= 0.5) then - profiles(i)%skin%surftype = surftype_seaice - endif - - ! dar: hard-coded to 1 (=ocean water) in rttov 9 int - profiles(i)%skin%watertype = 1 - profiles(i) %idg = 0. - profiles(i) %ish = 0. - enddo - ! end of 5. - - ich_temp = 1 - nchannels = nch_in - do no_id = 1, nrttovid - - ! -------------------------------------------------------------------------- - ! 3. build the list of profile/channel indices in chanprof - ! -------------------------------------------------------------------------- - - allocate(nchan(nprof)) ! number of channels per profile - nchan(:) = size(ichan(:,no_id)) ! = nch_in - - ! size of chanprof array is total number of channels over all profiles - ! square in this case - here same channels done for all profiles - nchanprof = sum(nchan(:)) - - ! pack channels and input emissivity arrays - allocate(chanprof(nchanprof)) - ! allocate(emis(nchanprof)) - chanprof(:)%chan =0 - - nch = 0 - do j = 1, nprof - do jch = 1, nchan(j) - nch = nch + 1 - chanprof(nch)%prof = j - if(ichan(jch, no_id) < 1) then - errorstatus = errorstatus_fatal - call rttov_error('Sensor channel number must be 1 or greater' , lalloc = .true.) - else - chanprof(nch)%chan = ichan(jch, no_id) - endif - enddo - enddo - ! end of 3. - - ! allocate output radiance arrays - call rttov_alloc_rad( & - errorstatus, & - nchanprof, & - radiance, & - nlevels - 1, & ! nlayers - asw) - call rttov_error('allocation error for radiance arrays' , lalloc = .true.) - - ! allocate transmittance structure - call rttov_alloc_transmission( & - errorstatus, & - transmission, & - nlevels - 1, & - nchanprof, & - asw, & - init=.true.) - call rttov_error('allocation error for transmission arrays' , lalloc = .true.) - - ! allocate arrays for surface emissivity - allocate(calcemis(nchanprof), stat=alloc_status(1)) - allocate(emissivity(nchanprof), stat=alloc_status(2)) - call rttov_error('mem allocation error for emissivity arrays' , lalloc = .true.) - - call rttov_get_emis( & - & errorstatus, & - & opts, & - & chanprof, & - & profiles, & - & coef_rttov, & - !& resolution=resolution, & ! *** MW atlas native - ! resolution is 0.25 degree lat/lon; if you know better - ! value for satellite footprint (larger than this) then - ! you can specify it here - & emissivity=emissivity(:)%emis_in) - ! & emissivity(:)%emis_in) - - call rttov_error('Get emissivity error' , lalloc = .true.) - calcemis(:) = .false. - ! calculate emissivity for missing and ocean location (fastem) - where (emissivity(:)%emis_in <= 0.0) - calcemis(:) = .true. - endwhere - - call rttov_direct( & - errorstatus, &! out - chanprof, & - opts, & - profiles, &! in - coef_rttov, &! in - transmission, &! out - radiance, & - calcemis = calcemis, &! in - emissivity = emissivity) ! inout - call rttov_error('rttov_direct error', lalloc = .true.) - - tbs(1:prof_num , ich_temp:ich_temp + size(ichan(:,no_id)) - 1) = & - transpose(reshape(radiance%bt(1:nchanprof), (/ size(ichan(:,no_id)), prof_num/) )) - - ich_temp = ich_temp + size(ichan(:,no_id)) - - ! -------------------------------------------------------------------------- - ! 8. deallocate all rttov arrays and structures - ! -------------------------------------------------------------------------- - deallocate (nchan, stat=alloc_status(3)) - deallocate (chanprof, stat=alloc_status(4)) - deallocate (emissivity, stat=alloc_status(5)) - deallocate (calcemis, stat=alloc_status(6)) - call rttov_error('rttov array deallocation error', lalloc = .true.) - - asw = 0 ! switch for deallocation passed into rttov subroutines - - ! deallocate radiance arrays - call rttov_alloc_rad(errorstatus, nchannels, radiance, nlevels - 1, asw) - call rttov_error('radiance deallocation error', lalloc = .true.) - - ! deallocate transmission arrays - call rttov_alloc_transmission(errorstatus, transmission, nlevels - 1, nchannels, asw) - call rttov_error('transmission deallocation error', lalloc = .true.) - - enddo - - ! deallocate profile arrays - call rttov_alloc_prof(errorstatus, nprof, profiles, nlevels, opts, asw) - call rttov_error('profile deallocation error', lalloc = .true.) - - deallocate(profiles, stat=alloc_status(1)) - call rttov_error('mem deallocation error for profile array', lalloc= .true.) - - contains - - subroutine rttov_error(msg, lalloc) - character(*) :: msg - logical :: lalloc - - if(lalloc) then - if (any(alloc_status /= 0)) then - write(*,*) msg - errorstatus = 1 - call rttov_exit(errorstatus) - endif - else - if (errorstatus /= errorstatus_success) then - write(*,*) msg - call rttov_exit(errorstatus) - endif - endif - end subroutine rttov_error - - end subroutine rttov_multprof - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - !----------------- subroutine cosp_rttov_mwscatt --------------- - !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - subroutine cosp_rttov_mwscatt(& - nch_in, & ! number of channels - ichan_in, & ! channel indices - surfem_in, & ! surface emissivity values - prf_num_in, & ! number of profiles to simulate - nlevels_in, & ! number of pressure levels - plat_in, & ! platform number - sat_in, & ! satellite number - sens_in, & ! instrument number - opts, & - opts_scatt, & - coef_rttov, & - coef_scatt, & - zenang_in, & ! zenith angle - p_in, & ! pressure [hpa] - ph_in, & ! pressure on half levels [hpa] - t_in, & ! temperature [ k ] - q_in, & ! specific humidity [ ppmv ] - o3_in, & ! ozone vmr [ ppmv ] - clw_in, & ! cloud water [0-1] - ciw_in, & ! cloud ice [0-1] - cc_in, & ! effective cloud fraction [0-1] - totalice_in,& ! total ice, except snow [kg/kg] or [kg/m2/s] - sp_in, & ! solid precip with snow [kg/kg] or [kg/m2/s] - rain_in, & ! total liquid water [kg/kg] or [kg/m2/s] - co2_in, & ! co2 vmr [ ppmv ] *this is a single value* - ch4_in, & ! ch4 vmr [ ppmv ] *this is a single value* - n2o_in, & ! n2o vmr [ ppmv ] *this is a single value* - co_in, & ! co vmr [ ppmv ] *this is a single value* - h_surf, & ! surface height [ m ] - u_surf, & ! u wind at 10 m [ m/s ] - v_surf, & ! v wind at 10 m [ m/s ] - t_skin, & ! skin temperatre [ k ] - p_surf, & ! surface pressure - t_surf, & ! 1.5 m temperature [ k ] - q_surf, & ! 1.5 m specific humidity [ ppmv ] - lsmask, & ! land sea mask - seaice, & ! seaice fraction - latitude, & ! latitude [ deg north ] - longitude, & ! longitude [ deg east ] - use_totalice,& ! separate ice and snow, or total ice hydrometeor types - mmr_snowrain,& ! set units for snow and rain: if true units are kg/kg (the default) - cfrac, & ! opts_scatt%lusercfrac=true., supply the effective cloud fraction - tbs & ! brightness temperature [ k ] (output) - ) - - - - - - implicit none - - !------ input arguments. no rttov kinds should be used here ----------------- - integer, intent(in) :: nch_in ! number of channels to be computed - integer, intent(in) :: ichan_in(nch_in) ! indices of selected channels - real(wp), intent(in) :: surfem_in(nch_in) ! surface emissivities for the channels - integer, intent(in) :: prf_num_in - integer, intent(in) :: nlevels_in - integer, intent(in) :: plat_in ! satellite platform - integer, intent(in) :: sat_in ! satellite number - integer, intent(in) :: sens_in ! satellite sensor - real(wp), intent(in) :: zenang_in ! satellite zenith angle - - type(rttov_options) :: opts - type(rttov_options_scatt) :: opts_scatt - type(rttov_coefs) :: coef_rttov - type(rttov_scatt_coef) :: coef_scatt - - real(wp), intent(in) :: p_in(prf_num_in, nlevels_in) ! pressure profiles - real(wp), intent(in) :: t_in(prf_num_in, nlevels_in) ! temperature profiles - real(wp), intent(in) :: q_in(prf_num_in, nlevels_in) ! humidity profiles - real(wp), intent(in) :: o3_in(prf_num_in, nlevels_in) ! ozone profiles - real(wp), intent(in) :: clw_in(prf_num_in, nlevels_in) - real(wp), intent(in) :: ciw_in(prf_num_in, nlevels_in) - real(wp), intent(in) :: cc_in(prf_num_in, nlevels_in) - real(wp), intent(in) :: totalice_in(prf_num_in, nlevels_in) - real(wp), intent(in) :: sp_in(prf_num_in, nlevels_in) - real(wp), intent(in) :: rain_in(prf_num_in, nlevels_in) - real(wp), intent(in) :: ph_in(prf_num_in, nlevels_in+1) - - ! the following trace gases contain constant values - real(wp), intent(in) :: co2_in ! carbon dioxide - real(wp), intent(in) :: ch4_in ! methane - real(wp), intent(in) :: n2o_in ! n2o - real(wp), intent(in) :: co_in ! carbon monoxide - real(wp), intent(in) :: h_surf(prf_num_in) ! surface height - real(wp), intent(in) :: u_surf(prf_num_in) ! u component of surface wind - real(wp), intent(in) :: v_surf(prf_num_in) ! v component of surface wind - real(wp), intent(in) :: t_skin(prf_num_in) ! surface skin temperature - real(wp), intent(in) :: p_surf(prf_num_in) ! surface pressure - real(wp), intent(in) :: t_surf(prf_num_in) ! 1.5 m temperature - real(wp), intent(in) :: q_surf(prf_num_in) ! 1.5 m specific humidity - real(wp), intent(in) :: lsmask(prf_num_in) ! land-sea mask - real(wp), intent(in) :: seaice(prf_num_in) ! seaice fraction - real(wp), intent(in) :: latitude(prf_num_in) ! latitude - real(wp), intent(in) :: longitude(prf_num_in) ! longitude - logical, intent(in) :: cfrac, use_totalice, mmr_snowrain - - real(wp), intent(inout) :: tbs(prf_num_in, nch_in) ! tbs (in the right format) - !****************** local variables ********************************************** - logical , allocatable :: calcemis (:) - type(rttov_emissivity) , allocatable :: emissivity (:) - integer , allocatable :: frequencies (:) - type(rttov_chanprof) , allocatable :: chanprof (:) ! channel and profile indices - type(profile_type) , allocatable :: profiles (:) - type(profile_cloud_type) , allocatable :: cld_profiles(:) - - integer, allocatable :: ichan(:,:) ! channel list per instrument - - integer :: errorstatus - type (radiance_type) :: radiance - ! type (rttov_options) :: opts ! defaults to everything optional switched off - ! type (rttov_options_scatt) :: opts_scatt - ! type (rttov_coefs) :: coef_rttov - ! type (rttov_scatt_coef) :: coef_scatt - - ! integer, allocatable :: instrument (:,:) - integer :: j,k,asw - integer :: nchanxnprof, ninstruments - real(wp) :: zenangle - character (len=256) :: outstring - integer :: alloc_status(60) - -#include "rttov_init_rad.interface" -#include "rttov_scatt_setupindex.interface" -#include "rttov_scatt.interface" -#include "rttov_alloc_rad.interface" -#include "rttov_alloc_prof.interface" -#include "rttov_alloc_scatt_prof.interface" -#include "rttov_get_emis.interface" -#include "rttov_boundaryconditions.interface" - - errorstatus = 0 - alloc_status(:) = 0 - ninstruments = 1 ! number of sensors or platforms - - allocate(ichan(nch_in, ninstruments), stat = alloc_status(3)) - - do j = 1, ninstruments - ichan(:, j) = ichan_in - enddo - - nchanxnprof = prf_num_in * nch_in ! total channels to simulate * profiles - - allocate (chanprof(nchanxnprof)) - allocate (frequencies(nchanxnprof)) - allocate (emissivity(nchanxnprof)) - allocate (calcemis(nchanxnprof)) - allocate (profiles(prf_num_in)) - allocate (cld_profiles(prf_num_in)) - - ! request rttov / fastem to calculate surface emissivity - calcemis = .true. - emissivity % emis_in = 0.0 - - ! setup indices - call rttov_scatt_setupindex ( & - & prf_num_in, & ! in - & nch_in, & ! in - & coef_rttov%coef, & ! in - & nchanxnprof, & ! in - & chanprof, & ! out - & frequencies) ! out - - ! allocate profiles (input) and radiance (output) structures - asw = 1 - call rttov_alloc_prof( errorstatus,prf_num_in,profiles,nlevels_in,opts,asw, init = .true.) - call rttov_alloc_scatt_prof(prf_num_in,cld_profiles, nlevels_in, .false., 1, init = .true.) - call rttov_alloc_rad(errorstatus,nchanxnprof,radiance,nlevels_in-1,asw) - - ! fill the profile structures with data - do j = 1, prf_num_in - profiles(j)%latitude = latitude(j) - profiles(j)%longitude = longitude(j) - profiles(j)%elevation = h_surf(j) - profiles(j)%sunzenangle = 0.0 ! hard-coded in rttov9 int - profiles(j)%sunazangle = 0.0 ! hard-coded in rttov9 int - profiles(j)%azangle = 0.0 - profiles(j)%zenangle = zenang_in - profiles(j)%s2m%t = t_surf(j) - profiles(j)%s2m%q = q_surf(j) - profiles(j)%s2m%u = u_surf(j) - profiles(j)%s2m%v = v_surf(j) - profiles(j)%s2m%wfetc = 10000. - profiles(j)%skin%t = t_skin(j) - profiles(j)%skin%watertype = 1 ! ocean water - if (lsmask(j) < 0.5) then - profiles(j)%skin%surftype = surftype_sea - else - profiles(j)%skin%surftype = surftype_land - endif - if (seaice(j) >= 0.5) then - profiles(j)%skin%surftype = surftype_seaice - endif - profiles(j)%skin%fastem(1) = 3.0 - profiles(j)%skin%fastem(2) = 5.0 - profiles(j)%skin%fastem(3) = 15.0 - profiles(j)%skin%fastem(4) = 0.1 - profiles(j)%skin%fastem(5) = 0.3 - profiles(j)%cfraction = 0.0 - profiles(j)%ctp = 500.0 ! not used but still required by rttov - profiles(j)%p(:) = p_in(j,:) - profiles(j)%t(:) = t_in(j,:) - profiles(j)%q(:) = q_in(j,:) - profiles(j)%idg = 0. - profiles(j)%ish = 0. - where(profiles(j)%q(:) < 1e-4) - profiles(j)%q(:) = 1e-4 - end where - cld_profiles(j)%ph(:) = ph_in(j,:) - cld_profiles(j)%cc(:) = cc_in(j,:) - cld_profiles(j)%clw(:) = clw_in(j,:) - cld_profiles(j)%ciw(:) = ciw_in(j,:) - cld_profiles(j)%rain(:) = rain_in(j,:) - cld_profiles(j)%sp(:) = sp_in(j,:) - profiles(j)%s2m%p = cld_profiles(j)%ph(nlevels_in+1) - enddo - - call rttov_get_emis( & - & errorstatus, & - & opts, & - & chanprof, & - & profiles, & - & coef_rttov, & - ! & resolution=resolution, & ! *** MW atlas native resolution is - ! 0.25 degree lat/lon; if you know better value for satellite - ! footprint (larger than this) then you can specify it here - & emissivity=emissivity(:)%emis_in) - if (errorstatus /= errorstatus_success) then - write(*,*) 'In COSP_RTTOV11: Error RTTOV_GET_EMIS!' - call rttov_exit(errorstatus) - endif - - calcemis(:) = .false. - where (emissivity(:)%emis_in <= 0.) - calcemis(:) = .true. - endwhere - - call rttov_scatt (& - & errorstatus, &! out - & opts_scatt, &! in - & nlevels_in, &! in - & chanprof, &! in - & frequencies, &! in - & profiles, &! in - & cld_profiles, &! in - & coef_rttov, &! in - & coef_scatt, &! in - & calcemis, &! in - & emissivity, &! in - & radiance) ! out - - if (errorstatus /= errorstatus_success) then - write(*,*) 'In COSP_RTTOV11: Error RTTOV_SCATT!' - call rttov_exit(errorstatus) - endif - - !write(*,*) 'Checking emissivities: ', maxval(emissivity(:)%emis_out), \ - ! minval(emissivity(:)%emis_out) - tbs(1:prf_num_in,1:1+size(ichan(:,1))-1) = & - transpose(reshape(radiance%bt(1:nchanxnprof),(/ size(ichan(:,1)),prf_num_in/) )) - - ! deallocate all storage - asw = 0 - ! call rttov_dealloc_coefs(errorstatus,coef_rttov) - ! call rttov_dealloc_scattcoeffs(coef_scatt) - call rttov_alloc_prof(errorstatus,prf_num_in,profiles,nlevels_in,opts,asw) - call rttov_alloc_scatt_prof(prf_num_in,cld_profiles,nlevels_in,.false.,asw) - call rttov_alloc_rad(errorstatus,nchanxnprof,radiance,nlevels_in-1,asw) - deallocate(ichan,chanprof,frequencies,emissivity,calcemis) !instrument, - !*************************************************************************** - !-------- end section -------- - !*************************************************************************** - end subroutine cosp_rttov_mwscatt - function construct_rttov_coeffilename(platform,satellite,instrument) - ! Inputs - integer,intent(in) :: platform,satellite,instrument - ! Outputs - character(len=256) :: construct_rttov_coeffilename - ! Local variables - character(len=256) :: coef_file - integer :: error - - ! Initialize - error = 0 - - ! Platform - if (platform .eq. 1) coef_file = 'rtcoef_noaa_' - if (platform .eq. 10) coef_file = 'rtcoef_metop_' - if (platform .eq. 11) coef_file = 'rtcoef_envisat_' - if (platform .ne. 1 .and. platform .ne. 10 .and. platform .ne. 11) then - error=error+1 - write ( *,* ) 'Unsupported platform ID ',platform - return - endif - - ! Satellite - if (satellite .lt. 10) then - coef_file = trim(coef_file) // char(satellite+48) - else if (satellite .lt. 100) then - coef_file = trim(coef_file) // char(int(satellite/10)+48) - coef_file = trim(coef_file) // char(satellite-int(satellite/10)*10+48) - else - error=error+1 - write ( *,* ) 'Unsupported satellite number ',satellite - return - endif - - ! Sensor - if (sensor .eq. 3) coef_file = trim(coef_file) // '_amsua.dat' - if (sensor .eq. 5) coef_file = trim(coef_file) // '_avhrr.dat' - if (sensor .eq. 49) coef_file = trim(coef_file) // '_mwr.dat' - if (sensor .ne. 3 .and. sensor .ne. 5 .and. sensor .ne. 49) then - error=error+1 - write ( *,* ) 'Unsupported sensor number ', sensor - return - endif - - if (error .eq. 0) construct_rttov_coeffilename=coef_file - - end function construct_rttov_coeffilename - function construct_rttov_scatfilename(platform,satellite,instrument) - ! Inputs - integer,intent(in) :: platform,satellite,instrument - ! Outputs - character(len=256) :: construct_rttov_scatfilename - ! Local variables - character(len=256) :: coef_file - integer :: error - - ! Initialize - error = 0 - - ! Platform - if (platform .eq. 1) coef_file = 'sccldcoef_noaa_' - if (platform .eq. 10) coef_file = 'sccldcoef_metop_' - if (platform .eq. 11) coef_file = 'sccldcoef_envisat_' - if (platform .ne. 1 .and. platform .ne. 10 .and. platform .ne. 11) then - error=error+1 - write ( *,* ) 'Unsupported platform ID ',platform - return - endif - - ! Satellite - if (satellite .lt. 10) then - coef_file = trim(coef_file) // char(satellite+48) - else if (satellite .lt. 100) then - coef_file = trim(coef_file) // char(int(satellite/10)+48) - coef_file = trim(coef_file) // char(satellite-int(satellite/10)*10+48) - else - error=error+1 - write ( *,* ) 'Unsupported satellite number ',satellite - return - endif - - ! Sensor - if (sensor .eq. 3) coef_file = trim(coef_file) // '_amsua.dat' - if (sensor .eq. 5) coef_file = trim(coef_file) // '_avhrr.dat' - if (sensor .eq. 49) coef_file = trim(coef_file) // '_mwr.dat' - if (sensor .ne. 3 .and. sensor .ne. 5 .and. sensor .ne. 49) then - error=error+1 - write ( *,* ) 'Unsupported sensor number ', sensor - return - endif - - if (error .eq. 0) construct_rttov_scatfilename=coef_file - - end function construct_rttov_scatfilename - -end module mod_cosp_rttov From a8e61ad7270059fe0d98fd41a724c31625f4e29a Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Wed, 3 Sep 2025 13:40:24 -0600 Subject: [PATCH 157/159] Revert MODIS joint optical thickness Reff histograms for kgo check --- src/cosp.F90 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/cosp.F90 b/src/cosp.F90 index 51f3783189..b61e97730d 100755 --- a/src/cosp.F90 +++ b/src/cosp.F90 @@ -1689,12 +1689,12 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) endif if (associated(cospOUT%modis_Optical_Thickness_vs_ReffIce)) then - cospOUT%modis_Optical_Thickness_vs_ReffIce(ij:ik,1:numMODISTauBins,:) = R_UNDEF + ! cospOUT%modis_Optical_Thickness_vs_ReffIce(ij:ik,1:numMODISTauBins,:) = R_UNDEF cospOUT%modis_Optical_Thickness_vs_ReffIce(ij+int(modisIN%sunlit(:))-1, 1:numMODISTauBins,:) = & modisJointHistogramIce(:,:,:) endif if (associated(cospOUT%modis_Optical_Thickness_vs_ReffLiq)) then - cospOUT%modis_Optical_Thickness_vs_ReffLiq(ij:ik,:,:) = R_UNDEF + ! cospOUT%modis_Optical_Thickness_vs_ReffLiq(ij:ik,:,:) = R_UNDEF cospOUT%modis_Optical_Thickness_vs_ReffLiq(ij+int(modisIN%sunlit(:))-1, 1:numMODISTauBins,:) = & modisJointHistogramLiq(:,:,:) endif @@ -1737,10 +1737,10 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospOUT%modis_Ice_Water_Path_Mean(ij+int(modisIN%notSunlit(:))-1) = R_UNDEF if (associated(cospOUT%modis_Optical_Thickness_vs_Cloud_Top_Pressure)) & cospOUT%modis_Optical_Thickness_vs_Cloud_Top_Pressure(ij+int(modisIN%notSunlit(:))-1, :, :) = R_UNDEF - if (associated(cospOUT%modis_Optical_Thickness_vs_ReffIce)) & - cospOUT%modis_Optical_Thickness_vs_ReffIce(ij+int(modisIN%notSunlit(:))-1, :, :) = R_UNDEF - if (associated(cospOUT%modis_Optical_Thickness_vs_ReffLiq)) & - cospOUT%modis_Optical_Thickness_vs_ReffLiq(ij+int(modisIN%notSunlit(:))-1, :, :) = R_UNDEF + ! if (associated(cospOUT%modis_Optical_Thickness_vs_ReffIce)) & + ! cospOUT%modis_Optical_Thickness_vs_ReffIce(ij+int(modisIN%notSunlit(:))-1, :, :) = R_UNDEF + ! if (associated(cospOUT%modis_Optical_Thickness_vs_ReffLiq)) & + ! cospOUT%modis_Optical_Thickness_vs_ReffLiq(ij+int(modisIN%notSunlit(:))-1, :, :) = R_UNDEF end if else ! It's nightime everywhere - everything is undefined @@ -1780,10 +1780,10 @@ function COSP_SIMULATOR(cospIN,cospgridIN,cospOUT,start_idx,stop_idx,debug) cospOUT%modis_Ice_Water_Path_Mean(ij:ik) = R_UNDEF if (associated(cospOUT%modis_Optical_Thickness_vs_Cloud_Top_Pressure)) & cospOUT%modis_Optical_Thickness_vs_Cloud_Top_Pressure(ij:ik, :, :) = R_UNDEF - if (associated(cospOUT%modis_Optical_Thickness_vs_ReffIce)) & - cospOUT%modis_Optical_Thickness_vs_ReffIce(ij:ik, :, :) = R_UNDEF - if (associated(cospOUT%modis_Optical_Thickness_vs_ReffLiq)) & - cospOUT%modis_Optical_Thickness_vs_ReffLiq(ij:ik, :, :) = R_UNDEF + ! if (associated(cospOUT%modis_Optical_Thickness_vs_ReffIce)) & + ! cospOUT%modis_Optical_Thickness_vs_ReffIce(ij:ik, :, :) = R_UNDEF + ! if (associated(cospOUT%modis_Optical_Thickness_vs_ReffLiq)) & + ! cospOUT%modis_Optical_Thickness_vs_ReffLiq(ij:ik, :, :) = R_UNDEF endif ! Free up memory (if necessary) if (allocated(modisRetrievedTau)) deallocate(modisRetrievedTau) From 4d6ac8dd1a476418c8062c9daea3d6af0b4e58db Mon Sep 17 00:00:00 2001 From: jshaw35 Date: Fri, 12 Sep 2025 15:55:34 -0600 Subject: [PATCH 158/159] Add namelist to test swathing and update CI scripts. Still need updated KGOs per Dustin. --- .github/workflows/containerized-ci.yml | 10 ++ .github/workflows/continuous_integration.yml | 9 ++ driver/run/cosp2_swath_input_nl.um_global.txt | 109 ++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 driver/run/cosp2_swath_input_nl.um_global.txt diff --git a/.github/workflows/containerized-ci.yml b/.github/workflows/containerized-ci.yml index f72166ec39..b6542f7ee2 100644 --- a/.github/workflows/containerized-ci.yml +++ b/.github/workflows/containerized-ci.yml @@ -78,6 +78,7 @@ jobs: cd driver/run ./cosp2_test cosp2_input_nl.txt ./cosp2_test cosp2_input_nl.um_global.txt + ./cosp2_test cosp2_swath_input_nl.um_global.txt ############################################################################### # Compare results against known good outputs. As above, # we split it in as many steps as tests. @@ -99,6 +100,15 @@ jobs: TST=data/outputs/UKMO/cosp2_output.um_global.nc STATS=data/outputs/UKMO/cosp2_output.um_global.${{ matrix.compiler }}.out python compare_to_kgo.py ${KGO} ${TST} --atol=${ATOL} --rtol=${RTOL} --stats_file=${STATS} + # 3. UM global snapshot with swathing. + - name: UM global with swathing against known good output (KGO) + if: always() + run: | + cd driver + KGO=data/outputs/UKMO/cosp2_output.um_global.${{ matrix.compiler }}.kgo.$KGO_VERSION.nc + TST=data/outputs/UKMO/cosp2_swath_output.um_global.nc + STATS=data/outputs/UKMO/cosp2_output.um_global.${{ matrix.compiler }}.out + python compare_to_kgo.py ${KGO} ${TST} --atol=${ATOL} --rtol=${RTOL} --stats_file=${STATS} ############################################################################### # Produce plots when it fails during global snapshot tests, # and create a tarball with outputs. diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 9e7ce87611..baef1e0668 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -102,6 +102,7 @@ jobs: cd driver/run ./cosp2_test cosp2_input_nl.txt ./cosp2_test cosp2_input_nl.um_global.txt + ./cosp2_test cosp2_swath_input_nl.um_global.txt # 2. UM global snapshot. Diagnostics on model levels. - name: UM global snapshot. Diagnostics on model levels. run: | @@ -134,6 +135,14 @@ jobs: KGO=data/outputs/UKMO/cosp2_output.um_global_model_levels.${F90_SHORT_NAME}.kgo.$KGO_VERSION.nc TST=data/outputs/UKMO/cosp2_output.um_global_model_levels.nc python compare_to_kgo.py ${KGO} ${TST} --atol=${ATOL} --rtol=${RTOL} + # 4. UM global snapshot. + - name: UM global with swathing against known good output (KGO) + if: always() + run: | + cd driver + KGO=data/outputs/UKMO/cosp2_output.um_global.${F90_SHORT_NAME}.kgo.$KGO_VERSION.nc + TST=data/outputs/UKMO/cosp2_swath_output.um_global.nc + python compare_to_kgo.py ${KGO} ${TST} --atol=${ATOL} --rtol=${RTOL} ############################################################################### # Produce plots when it fails during global snapshot tests, # and create a tarball with outputs. diff --git a/driver/run/cosp2_swath_input_nl.um_global.txt b/driver/run/cosp2_swath_input_nl.um_global.txt new file mode 100644 index 0000000000..a833fa6312 --- /dev/null +++ b/driver/run/cosp2_swath_input_nl.um_global.txt @@ -0,0 +1,109 @@ +! (c) British Crown Copyright 2008, the Met Office. +! All rights reserved. +! +! Redistribution and use in source and binary forms, with or without modification, are permitted +! provided that the following conditions are met: +! +! * Redistributions of source code must retain the above copyright notice, this list +! of conditions and the following disclaimer. +! * Redistributions in binary form must reproduce the above copyright notice, this list +! of conditions and the following disclaimer in the documentation and/or other materials +! provided with the distribution. +! * Neither the name of the Met Office nor the names of its contributors may be used +! to endorse or promote products derived from this software without specific prior written +! permission. +! +! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +! Namelist that sets up the main COSP options +&COSP_INPUT + NPOINTS=1728, ! 1728,6912 + NPOINTS_IT=1000,! Max number of gridpoints to be processed in one iteration + NCOLUMNS=20, ! Number of subcolumns + NLEVELS=54, ! Number of model levels + USE_VGRID=.true., ! Use fixed vertical grid for outputs? (if .true. then you need to define number of levels with Nlr) + NLVGRID=40, ! Number of levels in statistical outputs (only used if USE_VGRID=.true.) + CSAT_VGRID=.true., ! CloudSat vertical grid? (if .true. then the CloudSat standard grid is used for the outputs. + ! USE_VGRID needs also be .true.) + DINPUT='./', ! Directory where the input files are located. Useful when processing multiple files. + ! Leave blank ('') if you are using the full path in FINPUT. + FINPUT='../data/inputs/UKMO/cosp_input.um_global.nc', ! List input NetCDF files + FOUTPUT='../data/outputs/UKMO/cosp2_swath_output.um_global.nc', + !---------------------------------------------------------------------------------- + !--------------- Inputs related to radar simulations + !---------------------------------------------------------------------------------- + cloudsat_RADAR_FREQ=94.0, ! CloudSat radar frequency (GHz) + SURFACE_RADAR=0, ! surface=1, spaceborne=0 + cloudsat_use_gas_abs=1, ! include gaseous absorption? yes=1,no=0 + cloudsat_do_ray=0, ! calculate/output Rayleigh refl=1, not=0 + cloudsat_k2=-1, ! |K|^2, -1=use frequency dependent default + use_precipitation_fluxes=.true., ! True if precipitation fluxes are input to the algorithm + cloudsat_micro_scheme='MMF_v3_single_moment', !'MMF_v3.5_two_moment' + !---------------------------------------------------------------------------------- + !---------------- Inputs related to lidar simulations + !---------------------------------------------------------------------------------- + lidar_ice_type=0, ! Ice particle shape in lidar calculations (0=ice-spheres ; 1=ice-non-spherical) + OVERLAP=3, ! overlap assumption used by scops: 1=max, 2=rand, 3=max/rand + !---------------------------------------------------------------------------------- + !---------------- Inputs related to ISCCP simulator + !---------------------------------------------------------------------------------- + ISCCP_TOPHEIGHT=1, ! 1 = adjust top height using both a computed + ! infrared brightness temperature and the visible + ! optical depth to adjust cloud top pressure. Note + ! that this calculation is most appropriate to compare + ! to ISCCP data during sunlit hours. + ! 2 = do not adjust top height, that is cloud top + ! pressure is the actual cloud top pressure + ! in the model + ! 3 = adjust top height using only the computed + ! infrared brightness temperature. Note that this + ! calculation is most appropriate to compare to ISCCP + ! IR only algortihm (i.e. you can compare to nighttime + ! ISCCP data with this option) + ISCCP_TOPHEIGHT_DIRECTION=2, ! direction for finding atmosphere pressure level + ! with interpolated temperature equal to the radiance + ! determined cloud-top temperature + ! 1 = find the *lowest* altitude (highest pressure) level + ! with interpolated temperature equal to the radiance + ! determined cloud-top temperature + ! 2 = find the *highest* altitude (lowest pressure) level + ! with interpolated temperature equal to the radiance + ! determined cloud-top temperature. This is the + ! default value since V4.0 of the ISCCP simulator. + ! ONLY APPLICABLE IF top_height EQUALS 1 or 3 + !---------------------------------------------------------------------------------- + !-------------- Swathing inputs + !---------------------------------------------------------------------------------- + N_SWATHS_ISCCP=2, + SWATH_LOCALTIMES_ISCCP=5.25,18.0, + SWATH_WIDTHS_ISCCP=2000,2000, + N_SWATHS_MISR=2, + SWATH_LOCALTIMES_MISR=6.5,18.25, + SWATH_WIDTHS_MISR=2000,2000, + N_SWATHS_MODIS=2, + SWATH_LOCALTIMES_MODIS=5.75,13.5, + SWATH_WIDTHS_MODIS=2000,2000, + N_SWATHS_CSCAL=2, + SWATH_LOCALTIMES_CSCAL=6.75,19.25, + SWATH_WIDTHS_CSCAL=2000,2000, + N_SWATHS_PARASOL=2, + SWATH_LOCALTIMES_PARASOL=6.75,19, + SWATH_WIDTHS_PARASOL=2000,2000, + N_SWATHS_ATLID=2, + SWATH_LOCALTIMES_ATLID=7.25,19.5, + SWATH_WIDTHS_ATLID=2000,2000, + !---------------------------------------------------------------------------------- + !-------------- RTTOV inputs + !---------------------------------------------------------------------------------- +! rttov_Ninstruments=1, +! rttov_instrument_namelists='instrument_nls/cosp2_rttov_inst1.txt', + rttov_verbose=.false. +/ From 9a8f9d9313b83244d10cac484fa3f5837369c492 Mon Sep 17 00:00:00 2001 From: dustinswales Date: Fri, 26 Sep 2025 09:33:20 -0600 Subject: [PATCH 159/159] Add swathed output files to tarball. Ready fro KGO update to v007 --- .github/workflows/containerized-ci.yml | 2 +- .github/workflows/continuous_integration.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/containerized-ci.yml b/.github/workflows/containerized-ci.yml index b6542f7ee2..a116ccbe1f 100644 --- a/.github/workflows/containerized-ci.yml +++ b/.github/workflows/containerized-ci.yml @@ -122,7 +122,7 @@ jobs: fi cd data/outputs/UKMO tar --ignore-failed-read -czf outputs.${{ matrix.compiler }}.UKMO.tgz cosp2_output.um_global.nc \ - cosp2_output_um.nc *.png cosp2_output*.${{ matrix.compiler }}.out + cosp2_output_um.nc cosp2_swath_output.um_global.nc *.png cosp2_output*.${{ matrix.compiler }}.out ls -lh ############################################################################### # Make output files available if any test fails diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index baef1e0668..7ed6289e9c 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -160,7 +160,7 @@ jobs: fi cd data/outputs/UKMO tar --ignore-failed-read -czf outputs.${{ matrix.compiler }}.UKMO.tgz cosp2_output.um_global.nc \ - cosp2_output_um.nc cosp2_output.um_global_model_levels.nc *.png \ + cosp2_output_um.nc cosp2_swath_output.um_global.nc cosp2_output.um_global_model_levels.nc *.png \ cosp2_output.um_global.out ls -lh ###############################################################################