From 6e815576f24d22a62c3bd69065dcc52af4a6af03 Mon Sep 17 00:00:00 2001 From: "Edward.Safford" Date: Wed, 15 Jul 2020 14:13:42 +0000 Subject: [PATCH] Add fixes to OznMon. --- util/Ozone_Monitor/CMakeLists.txt | 39 ++++-- .../fix/gdas_oznmon_base.tar | Bin 0 -> 30720 bytes .../sorc/oznmon_horiz.fd/horiz.f90 | 2 +- .../{read_diag.f90 => oznmon_read_diag.f90} | 122 +++++++++--------- .../{read_diag.f90 => oznmon_read_diag.f90} | 122 +++++++++--------- .../sorc/oznmon_time.fd/time.f90 | 2 +- .../oznmon_shared.v2.0.0/ush/ozn_xtrct.sh | 5 +- 7 files changed, 151 insertions(+), 141 deletions(-) create mode 100644 util/Ozone_Monitor/nwprod/gdas_oznmon.v2.0.0/fix/gdas_oznmon_base.tar rename util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/sorc/oznmon_horiz.fd/{read_diag.f90 => oznmon_read_diag.f90} (90%) rename util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/sorc/oznmon_time.fd/{read_diag.f90 => oznmon_read_diag.f90} (90%) diff --git a/util/Ozone_Monitor/CMakeLists.txt b/util/Ozone_Monitor/CMakeLists.txt index b8f928a61d..03f5129cfc 100644 --- a/util/Ozone_Monitor/CMakeLists.txt +++ b/util/Ozone_Monitor/CMakeLists.txt @@ -1,9 +1,9 @@ -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 2.8) if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) # I am top-level project. if( NOT DEFINED ENV{CC} ) find_path( crayComp "ftn" ) -# find_path( wcossIntel "mpfort" ) + find_path( wcossIntel "mpfort" ) find_path( intelComp "ifort" ) find_path( pgiComp "pgf90" ) if( crayComp ) @@ -22,7 +22,7 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) message("Setting env for wcoss intel") set(ENV{CC} "mpcc") set(ENV{CXX} "mpCC") -# set(ENV{FC} "mpfort") + set(ENV{FC} "mpfort") endif() if( pgiComp ) set(ENV{CC} "pgcc") @@ -32,8 +32,8 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) endif() project(COV_Calc) enable_language (Fortran) -# find_package(OpenMP) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../../cmake/Modules/") + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setPlatformVariables.cmake) include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setIntelFlags.cmake) include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setGNUFlags.cmake) @@ -64,20 +64,40 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) message("Setting PGI flags") setPGI() endif() + + cmake_policy(SET CMP0009 NEW) + find_package(OpenMP) + message("found openmp with flag ${OPENMP_Fortran_FLAGS}") + +# Set Host specific flags and options setHOST() + + if(FIND_HDF5_HL) + find_package(HDF5 COMPONENTS C HL Fortran_HL ) + elseif(FIND_HDF5) + find_package(HDF5) + endif() + find_package(MPI REQUIRED) + message("MPI version is ${MPI_Fortran_VERSION}") + message("MPI f90 version is ${MPI_Fortran_HAVE_F90_MODULE}") + message("MPI f08 version is ${MPI_Fortran_HAVE_F08_MODULE}") + add_definitions(${MPI_Fortran_COMPILE_FLAGS}) include_directories(${MPI_Fortran_INCLUDE_DIRS} ${MPI_INCLUDE_PATH} "./" ${CMAKE_INCLUDE_OUTPUT_DIRECTORY}) link_directories(${MPI_Fortran_LIBRARIES} ${ARCHIVE_OUTPUT_PATH} ) find_package( NetCDF REQUIRED) - if(FIND_HDF5_HL) - find_package(HDF5 COMPONENTS C HL Fortran_HL ) - elseif(FIND_HDF5) - find_package(HDF5) + if(NETCDF4) + if(CMAKE_MAJOR_VERSION GREATER 2) + find_package( ZLIB ) + endif() + find_package( CURL ) endif() + find_package( W3NCO ) - set(NCDIAG_INCS "${PROJECT_BINARY_DIR}/libsrc/ncdiag") + set(BUILD_NCDIAG ON) + set(NCDIAG_INCS "${PROJECT_BINARY_DIR}/libsrc/ncdiag") add_subdirectory(${PROJECT_SOURCE_DIR}/../../src/ncdiag ${PROJECT_BINARY_DIR}/libsrc/ncdiag) set(NCDIAG_LIBRARIES ncdiag ) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) @@ -86,4 +106,3 @@ endif() add_subdirectory(nwprod/oznmon_shared.v2.0.0/sorc/oznmon_horiz.fd) add_subdirectory(nwprod/oznmon_shared.v2.0.0/sorc/oznmon_time.fd) add_subdirectory(data_xtrct/sorc/make_base.fd) - diff --git a/util/Ozone_Monitor/nwprod/gdas_oznmon.v2.0.0/fix/gdas_oznmon_base.tar b/util/Ozone_Monitor/nwprod/gdas_oznmon.v2.0.0/fix/gdas_oznmon_base.tar new file mode 100644 index 0000000000000000000000000000000000000000..0526bd1b1e89ef0376d2957a0fae43fe0fb4c944 GIT binary patch literal 30720 zcmeI4S+d+j7KZ)IDzpGlCzU5Fs|sJ*NPy@lJ=mp^ zD)ZNwC*3#i-oAeM_Vq9Ce*WfZ{qE_*>leo#h9iaW!Wb7!vixs?^X-4RbVmw*3nmN%0C zEcb_~c%Pj6oS>)pqne))R&@amI( zeEY*sCLRc4|*{Qo5y`&^9l@c+L}qlf?h60`NV_aF+qd;7!7r;qRdu-so@ zO0xDp=l@b4us*~`{(lgMpI>HC0Z@m3^Z)GX&f)(T3Po`>sptPows{T3;bYnnQXbU- z@khagBwzH))~&{sQ2MD`U5Pc4GPi@3a!qbrwQH=ww5y-_fiX%*dSi%W{g zZGajAS;fUN5OV76noBUX0g$y;??TbF1g~}DYAI_n)#EId<#UJxZmD^VvFdZVV%89f zo|ZLO7yWoH>tl0J3Zbqprl5DnwRmT9?pN!Yy)Bjux*a@hNiH+NZGD7hCvj| zCVqP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35_{dw9`VVh2XXr|FQ5Y2w=9EfJWb`C_K7{@sf&3;YLF&7}Ec{Sxy zSv2Gq9koPRb1o9LKSD7gAWHmkyhcq8jUH$Yd22fqX&f`zD_scI!(ifZ7yyu^Cwp|2 zi|j|l+YZw0*zgnTQ@r7wz;Q|&87sM+V&M5R0qL%neU*#sMI@Wh4btv9Mw+tTD5{YN zFhoX`za!$!gOvIV$4sNyuN{GioKStKI5OtuwP3_4qX6VX9g%nuDB1u{h|~?XyAD9a zXy1tKnJ~z-wk}-5k1>y}B1-a1Hn&9vGol-ty-Tujo{myyxJZhG_LrA6Wccth?UQ(U zgY@#&_p6^ihDI{FLgK9Y+uryetr_Au{xBvGJJ)!@9x>XA1T&3P&g8b;T*Fi_?K9dA zKn5k?czLbSK$^!gAXIG@_d}rHqUt&_L@)B7Y&GKjUwRJ@$A| q;6Z^01s)W5P~bs<2L&D!cu?R$fd>U16nIeJL4gMa9uzn)1^x@z^uX%? literal 0 HcmV?d00001 diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/sorc/oznmon_horiz.fd/horiz.f90 b/util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/sorc/oznmon_horiz.fd/horiz.f90 index 60744fdde2..497fc1802f 100644 --- a/util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/sorc/oznmon_horiz.fd/horiz.f90 +++ b/util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/sorc/oznmon_horiz.fd/horiz.f90 @@ -1,5 +1,5 @@ program horiz - use read_diag + use oznmon_read_diag implicit none integer ntype, mls2_levs,mls3_levs diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/sorc/oznmon_horiz.fd/read_diag.f90 b/util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/sorc/oznmon_horiz.fd/oznmon_read_diag.f90 similarity index 90% rename from util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/sorc/oznmon_horiz.fd/read_diag.f90 rename to util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/sorc/oznmon_horiz.fd/oznmon_read_diag.f90 index 7e592d3a5e..b2c59e9bb8 100644 --- a/util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/sorc/oznmon_horiz.fd/read_diag.f90 +++ b/util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/sorc/oznmon_horiz.fd/oznmon_read_diag.f90 @@ -1,27 +1,18 @@ !$$$ subprogram documentation block ! . . . . -! subprogram: read_diag read ozone diag file -! prgmmr: hliu org: np20 date: 2009-04-15 +! subprogram: oznmon_read_diag read ozone diag file ! ! abstract: This module contains code to process ozone ! diagnostic files. The module defines structures ! to contain information from the ozone ! diagnostic files and then provides two routines -! to access contents of the file. +! to access contents of the file. Both binary +! and NetCDF formats are supported. ! -! program history log: -! -! contains -! read_ozndiag_header - read ozone diagnostic file header -! read_ozndiag_data - read ozone diagnostic file data -! set_netcdf_read - call set_netcdf_read(.true.) to use nc4 hooks, -! otherwise read file as binary format -! open_ozndiag - open a diag file for reading -! close_ozndiag - close an open diag file !------------------------------------------------------------ -! -module read_diag + +module oznmon_read_diag !--- use ---! @@ -299,19 +290,19 @@ subroutine read_ozndiag_header( ftin, header_fix, header_nlev, new_hdr, istatus call read_ozndiag_header_bin( ftin, header_fix, header_nlev, new_hdr, istatus ) endif - print*, 'ftin = ', ftin - print*, 'header_fix%isis = ', header_fix%isis - print*, 'header_fix%id = ', header_fix%id - print*, 'header_fix%obstype = ', header_fix%obstype - print*, 'header_fix%jiter = ', header_fix%jiter - print*, 'header_fix%nlevs = ', header_fix%nlevs - print*, 'header_fix%ianldate = ', header_fix%ianldate - print*, 'header_fix%iint = ', header_fix%iint - print*, 'header_fix%ireal = ', header_fix%ireal - print*, 'header_fix%iextra = ', header_fix%iextra - - print*, 'istatus = ', istatus - print*, '' + write(6,*) 'ftin = ', ftin + write(6,*) 'header_fix%isis = ', header_fix%isis + write(6,*) 'header_fix%id = ', header_fix%id + write(6,*) 'header_fix%obstype = ', header_fix%obstype + write(6,*) 'header_fix%jiter = ', header_fix%jiter + write(6,*) 'header_fix%nlevs = ', header_fix%nlevs + write(6,*) 'header_fix%ianldate = ', header_fix%ianldate + write(6,*) 'header_fix%iint = ', header_fix%iint + write(6,*) 'header_fix%ireal = ', header_fix%ireal + write(6,*) 'header_fix%iextra = ', header_fix%iextra + + write(6,*) 'istatus = ', istatus + write(6,*) '' end subroutine read_ozndiag_header @@ -349,9 +340,9 @@ subroutine read_ozndiag_header_nc( ftin, header_fix, header_nlev, new_hdr, istat !--- get global attr ! ! This may look like overkill with a check on each variable - ! name, but due to the genius of the ncdiag library, a - ! failure on these read operations is fatal, because, reasons - ! I guess. Thus, this abundance of caution. + ! name, but a failure on these nc library read operations + ! is fatal. Thus, this abundance of caution verifying the + ! variable exists before attempting to retreive it. ! if( verify_var_name_nc( "date_time" ) ) then call nc_diag_read_get_global_attr(ftin, "date_time", idate) @@ -377,12 +368,6 @@ subroutine read_ozndiag_header_nc( ftin, header_fix, header_nlev, new_hdr, istat write(6,*) 'WARNING: unable to read global var Observation_type from file ' end if - if( verify_var_name_nc( "Number_of_state_vars" ) ) then - call nc_diag_read_get_global_attr(ftin, "Number_of_state_vars", nsdim ) - else - write(6,*) 'WARNING: unable to read global var Number_of_state_vars from file ' - end if - if( verify_var_name_nc( "pobs" ) ) then call nc_diag_read_get_global_attr(ftin, "pobs", pobs ) else @@ -401,7 +386,6 @@ subroutine read_ozndiag_header_nc( ftin, header_fix, header_nlev, new_hdr, istat write(6,*) 'WARNING: unable to read global var tnoise from file ' end if - !------------------------------------------------------------------- ! The Anaysis_Use_Flag in the netcdf file resides in the ! obs data rather than global (equivalent of binary file header @@ -438,6 +422,8 @@ subroutine read_ozndiag_header_nc( ftin, header_fix, header_nlev, new_hdr, istat !--- allocate if necessary + write(6,*) 'header_fix%nlevs, nlevs_last = ', header_fix%nlevs, nlevs_last + if( header_fix%nlevs /= nlevs_last )then if( nlevs_last > 0 )then deallocate( header_nlev ) @@ -455,8 +441,10 @@ subroutine read_ozndiag_header_nc( ftin, header_fix, header_nlev, new_hdr, istat header_nlev(k)%iouse = iuse_flag(k) end do - deallocate( pobs,gross,tnoise,iuse_flag ) - + if( allocated( pobs )) deallocate( pobs ) + if( allocated( gross )) deallocate( gross ) + if( allocated( tnoise )) deallocate( tnoise ) + if( allocated( iuse_flag )) deallocate( iuse_flag ) end subroutine read_ozndiag_header_nc @@ -511,8 +499,8 @@ subroutine read_ozndiag_header_bin( ftin, header_fix, header_nlev, new_hdr, ista if( header_fix%ireal /= IREAL_RESERVE ) then - print *, '### ERROR: UNEXPECTED DATA RECORD FORMAT' - print *, 'ireal =', header_fix%ireal + write(6,*) '### ERROR: UNEXPECTED DATA RECORD FORMAT' + write(6,*) 'ireal =', header_fix%ireal stop 99 endif @@ -524,6 +512,7 @@ subroutine read_ozndiag_header_bin( ftin, header_fix, header_nlev, new_hdr, ista !--- allocate if necessary + write(6,*) 'header_fix%nlevs, nlevs_last = ', header_fix%nlevs, nlevs_last if( header_fix%nlevs /= nlevs_last )then if( nlevs_last > 0 )then deallocate( header_nlev ) @@ -545,7 +534,11 @@ subroutine read_ozndiag_header_bin( ftin, header_fix, header_nlev, new_hdr, ista header_nlev(k)%err = err(k) header_nlev(k)%iouse = iouse(k) end do - deallocate (pob,grs,err,iouse) + + if( allocated( pob )) deallocate( pob ) + if( allocated( grs )) deallocate( grs ) + if( allocated( err )) deallocate( err ) + if( allocated( iouse )) deallocate( iouse ) end subroutine read_ozndiag_header_bin @@ -628,7 +621,7 @@ subroutine read_ozndiag_data_nc( ftin, header_fix, data_fix, data_nlev, data_ext logical :: test cur_idx = ncdiag_open_id( nopen_ncdiag ) - + !---------------------------------------------------------- ! The binary file read (the original version of the file ! read) is designed to be called in a loop, as it reads @@ -715,12 +708,13 @@ subroutine read_ozndiag_data_nc( ftin, header_fix, data_fix, data_nlev, data_ext data_fix(ii)%obstime = obstime(ii + ((ii-1)*nlevs) ) end do - deallocate( lat, lon, obstime ) + if( allocated( lat )) deallocate( lat ) + if( allocated( lon )) deallocate( lon ) + if( allocated( obstime )) deallocate( obstime ) !--------------------------------- ! load data_nlev structure ! - allocate( data_nlev( header_fix%nlevs,nrecords ) ) allocate( ozobs(nrecords) ) allocate( ozone_inv(nrecords) ) allocate( varinv(nrecords) ) @@ -769,23 +763,23 @@ subroutine read_ozndiag_data_nc( ftin, header_fix, data_fix, data_nlev, data_ext ! All vars used to read the file are dimensioned ! to nrecord, which is nobs * nlevs ! - do jj=0,ntobs-1 + do jj=1,ntobs-1 do ii=1,header_fix%nlevs - data_nlev(ii,jj)%ozobs = ozobs( ii + (jj * nlevs) ) - data_nlev(ii,jj)%ozone_inv = ozone_inv( ii + (jj * nlevs) ) - data_nlev(ii,jj)%varinv = varinv( ii + (jj * nlevs) ) - data_nlev(ii,jj)%sza = sza( ii + (jj * nlevs) ) - data_nlev(ii,jj)%fovn = fovn( ii + (jj * nlevs) ) - data_nlev(ii,jj)%toqf = toqf( ii + (jj * nlevs) ) + data_nlev(ii,jj)%ozobs = ozobs( ii + ((jj-1) * nlevs) ) + data_nlev(ii,jj)%ozone_inv = ozone_inv( ii + ((jj-1) * nlevs) ) + data_nlev(ii,jj)%varinv = varinv( ii + ((jj-1) * nlevs) ) + data_nlev(ii,jj)%sza = sza( ii + ((jj-1) * nlevs) ) + data_nlev(ii,jj)%fovn = fovn( ii + ((jj-1) * nlevs) ) + data_nlev(ii,jj)%toqf = toqf( ii + ((jj-1) * nlevs) ) end do end do - deallocate( ozobs ) - deallocate( ozone_inv ) - deallocate( varinv ) - deallocate( sza ) - deallocate( fovn ) - deallocate( toqf ) + if( allocated( ozobs )) deallocate( ozobs ) + if( allocated( ozone_inv )) deallocate( ozone_inv ) + if( allocated( varinv )) deallocate( varinv ) + if( allocated( sza )) deallocate( sza ) + if( allocated( fovn )) deallocate( fovn ) + if( allocated( toqf )) deallocate( toqf ) ncdiag_open_status(cur_idx)%nc_read = .true. @@ -831,6 +825,7 @@ subroutine read_ozndiag_data_bin( ftin, header_fix, data_fix, data_nlev, data_ex read(ftin,IOSTAT=iflag) ntobs write(6,*) ' READ 1, ntobs, iflag = ', ntobs, iflag + write(6,*) 'header_fix%nlevs, nlevs_last = ', header_fix%nlevs, nlevs_last if( header_fix%nlevs /= nlevs_last )then if( nlevs_last > 0 )then write(6,*) ' DEALLOCATING data_nlev, data_fix, data_mpi' @@ -845,8 +840,9 @@ subroutine read_ozndiag_data_bin( ftin, header_fix, data_fix, data_nlev, data_ex nlevs_last = header_fix%nlevs endif + write(6,*) 'iextra_last = ', iextra_last if (iextra_last > 0) then - deallocate (data_extra) + deallocate ( data_extra ) endif allocate( data_extra(header_fix%iextra,ntobs) ) @@ -869,7 +865,7 @@ subroutine read_ozndiag_data_bin( ftin, header_fix, data_fix, data_nlev, data_ex end do end do - deallocate(tmp_extra) + if( allocated( tmp_extra )) deallocate( tmp_extra ) endif do j=1,ntobs @@ -877,7 +873,7 @@ subroutine read_ozndiag_data_bin( ftin, header_fix, data_fix, data_nlev, data_ex data_fix(j)%lon = tmp_fix(2,j) data_fix(j)%obstime = tmp_fix(3,j) end do - deallocate(tmp_fix) + if( allocated( tmp_fix )) deallocate( tmp_fix ) do j=1,ntobs do i=1,header_fix%nlevs @@ -889,7 +885,7 @@ subroutine read_ozndiag_data_bin( ftin, header_fix, data_fix, data_nlev, data_ex data_nlev(i,j)%toqf = tmp_nlev(6,i,j) end do end do - deallocate(tmp_nlev) + if( allocated( tmp_nlev )) deallocate( tmp_nlev ) nlevs_last = -1 @@ -966,5 +962,5 @@ logical function verify_var_name_nc( test_name ) end function verify_var_name_nc -end module read_diag +end module oznmon_read_diag diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/sorc/oznmon_time.fd/read_diag.f90 b/util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/sorc/oznmon_time.fd/oznmon_read_diag.f90 similarity index 90% rename from util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/sorc/oznmon_time.fd/read_diag.f90 rename to util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/sorc/oznmon_time.fd/oznmon_read_diag.f90 index 7e592d3a5e..b2c59e9bb8 100644 --- a/util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/sorc/oznmon_time.fd/read_diag.f90 +++ b/util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/sorc/oznmon_time.fd/oznmon_read_diag.f90 @@ -1,27 +1,18 @@ !$$$ subprogram documentation block ! . . . . -! subprogram: read_diag read ozone diag file -! prgmmr: hliu org: np20 date: 2009-04-15 +! subprogram: oznmon_read_diag read ozone diag file ! ! abstract: This module contains code to process ozone ! diagnostic files. The module defines structures ! to contain information from the ozone ! diagnostic files and then provides two routines -! to access contents of the file. +! to access contents of the file. Both binary +! and NetCDF formats are supported. ! -! program history log: -! -! contains -! read_ozndiag_header - read ozone diagnostic file header -! read_ozndiag_data - read ozone diagnostic file data -! set_netcdf_read - call set_netcdf_read(.true.) to use nc4 hooks, -! otherwise read file as binary format -! open_ozndiag - open a diag file for reading -! close_ozndiag - close an open diag file !------------------------------------------------------------ -! -module read_diag + +module oznmon_read_diag !--- use ---! @@ -299,19 +290,19 @@ subroutine read_ozndiag_header( ftin, header_fix, header_nlev, new_hdr, istatus call read_ozndiag_header_bin( ftin, header_fix, header_nlev, new_hdr, istatus ) endif - print*, 'ftin = ', ftin - print*, 'header_fix%isis = ', header_fix%isis - print*, 'header_fix%id = ', header_fix%id - print*, 'header_fix%obstype = ', header_fix%obstype - print*, 'header_fix%jiter = ', header_fix%jiter - print*, 'header_fix%nlevs = ', header_fix%nlevs - print*, 'header_fix%ianldate = ', header_fix%ianldate - print*, 'header_fix%iint = ', header_fix%iint - print*, 'header_fix%ireal = ', header_fix%ireal - print*, 'header_fix%iextra = ', header_fix%iextra - - print*, 'istatus = ', istatus - print*, '' + write(6,*) 'ftin = ', ftin + write(6,*) 'header_fix%isis = ', header_fix%isis + write(6,*) 'header_fix%id = ', header_fix%id + write(6,*) 'header_fix%obstype = ', header_fix%obstype + write(6,*) 'header_fix%jiter = ', header_fix%jiter + write(6,*) 'header_fix%nlevs = ', header_fix%nlevs + write(6,*) 'header_fix%ianldate = ', header_fix%ianldate + write(6,*) 'header_fix%iint = ', header_fix%iint + write(6,*) 'header_fix%ireal = ', header_fix%ireal + write(6,*) 'header_fix%iextra = ', header_fix%iextra + + write(6,*) 'istatus = ', istatus + write(6,*) '' end subroutine read_ozndiag_header @@ -349,9 +340,9 @@ subroutine read_ozndiag_header_nc( ftin, header_fix, header_nlev, new_hdr, istat !--- get global attr ! ! This may look like overkill with a check on each variable - ! name, but due to the genius of the ncdiag library, a - ! failure on these read operations is fatal, because, reasons - ! I guess. Thus, this abundance of caution. + ! name, but a failure on these nc library read operations + ! is fatal. Thus, this abundance of caution verifying the + ! variable exists before attempting to retreive it. ! if( verify_var_name_nc( "date_time" ) ) then call nc_diag_read_get_global_attr(ftin, "date_time", idate) @@ -377,12 +368,6 @@ subroutine read_ozndiag_header_nc( ftin, header_fix, header_nlev, new_hdr, istat write(6,*) 'WARNING: unable to read global var Observation_type from file ' end if - if( verify_var_name_nc( "Number_of_state_vars" ) ) then - call nc_diag_read_get_global_attr(ftin, "Number_of_state_vars", nsdim ) - else - write(6,*) 'WARNING: unable to read global var Number_of_state_vars from file ' - end if - if( verify_var_name_nc( "pobs" ) ) then call nc_diag_read_get_global_attr(ftin, "pobs", pobs ) else @@ -401,7 +386,6 @@ subroutine read_ozndiag_header_nc( ftin, header_fix, header_nlev, new_hdr, istat write(6,*) 'WARNING: unable to read global var tnoise from file ' end if - !------------------------------------------------------------------- ! The Anaysis_Use_Flag in the netcdf file resides in the ! obs data rather than global (equivalent of binary file header @@ -438,6 +422,8 @@ subroutine read_ozndiag_header_nc( ftin, header_fix, header_nlev, new_hdr, istat !--- allocate if necessary + write(6,*) 'header_fix%nlevs, nlevs_last = ', header_fix%nlevs, nlevs_last + if( header_fix%nlevs /= nlevs_last )then if( nlevs_last > 0 )then deallocate( header_nlev ) @@ -455,8 +441,10 @@ subroutine read_ozndiag_header_nc( ftin, header_fix, header_nlev, new_hdr, istat header_nlev(k)%iouse = iuse_flag(k) end do - deallocate( pobs,gross,tnoise,iuse_flag ) - + if( allocated( pobs )) deallocate( pobs ) + if( allocated( gross )) deallocate( gross ) + if( allocated( tnoise )) deallocate( tnoise ) + if( allocated( iuse_flag )) deallocate( iuse_flag ) end subroutine read_ozndiag_header_nc @@ -511,8 +499,8 @@ subroutine read_ozndiag_header_bin( ftin, header_fix, header_nlev, new_hdr, ista if( header_fix%ireal /= IREAL_RESERVE ) then - print *, '### ERROR: UNEXPECTED DATA RECORD FORMAT' - print *, 'ireal =', header_fix%ireal + write(6,*) '### ERROR: UNEXPECTED DATA RECORD FORMAT' + write(6,*) 'ireal =', header_fix%ireal stop 99 endif @@ -524,6 +512,7 @@ subroutine read_ozndiag_header_bin( ftin, header_fix, header_nlev, new_hdr, ista !--- allocate if necessary + write(6,*) 'header_fix%nlevs, nlevs_last = ', header_fix%nlevs, nlevs_last if( header_fix%nlevs /= nlevs_last )then if( nlevs_last > 0 )then deallocate( header_nlev ) @@ -545,7 +534,11 @@ subroutine read_ozndiag_header_bin( ftin, header_fix, header_nlev, new_hdr, ista header_nlev(k)%err = err(k) header_nlev(k)%iouse = iouse(k) end do - deallocate (pob,grs,err,iouse) + + if( allocated( pob )) deallocate( pob ) + if( allocated( grs )) deallocate( grs ) + if( allocated( err )) deallocate( err ) + if( allocated( iouse )) deallocate( iouse ) end subroutine read_ozndiag_header_bin @@ -628,7 +621,7 @@ subroutine read_ozndiag_data_nc( ftin, header_fix, data_fix, data_nlev, data_ext logical :: test cur_idx = ncdiag_open_id( nopen_ncdiag ) - + !---------------------------------------------------------- ! The binary file read (the original version of the file ! read) is designed to be called in a loop, as it reads @@ -715,12 +708,13 @@ subroutine read_ozndiag_data_nc( ftin, header_fix, data_fix, data_nlev, data_ext data_fix(ii)%obstime = obstime(ii + ((ii-1)*nlevs) ) end do - deallocate( lat, lon, obstime ) + if( allocated( lat )) deallocate( lat ) + if( allocated( lon )) deallocate( lon ) + if( allocated( obstime )) deallocate( obstime ) !--------------------------------- ! load data_nlev structure ! - allocate( data_nlev( header_fix%nlevs,nrecords ) ) allocate( ozobs(nrecords) ) allocate( ozone_inv(nrecords) ) allocate( varinv(nrecords) ) @@ -769,23 +763,23 @@ subroutine read_ozndiag_data_nc( ftin, header_fix, data_fix, data_nlev, data_ext ! All vars used to read the file are dimensioned ! to nrecord, which is nobs * nlevs ! - do jj=0,ntobs-1 + do jj=1,ntobs-1 do ii=1,header_fix%nlevs - data_nlev(ii,jj)%ozobs = ozobs( ii + (jj * nlevs) ) - data_nlev(ii,jj)%ozone_inv = ozone_inv( ii + (jj * nlevs) ) - data_nlev(ii,jj)%varinv = varinv( ii + (jj * nlevs) ) - data_nlev(ii,jj)%sza = sza( ii + (jj * nlevs) ) - data_nlev(ii,jj)%fovn = fovn( ii + (jj * nlevs) ) - data_nlev(ii,jj)%toqf = toqf( ii + (jj * nlevs) ) + data_nlev(ii,jj)%ozobs = ozobs( ii + ((jj-1) * nlevs) ) + data_nlev(ii,jj)%ozone_inv = ozone_inv( ii + ((jj-1) * nlevs) ) + data_nlev(ii,jj)%varinv = varinv( ii + ((jj-1) * nlevs) ) + data_nlev(ii,jj)%sza = sza( ii + ((jj-1) * nlevs) ) + data_nlev(ii,jj)%fovn = fovn( ii + ((jj-1) * nlevs) ) + data_nlev(ii,jj)%toqf = toqf( ii + ((jj-1) * nlevs) ) end do end do - deallocate( ozobs ) - deallocate( ozone_inv ) - deallocate( varinv ) - deallocate( sza ) - deallocate( fovn ) - deallocate( toqf ) + if( allocated( ozobs )) deallocate( ozobs ) + if( allocated( ozone_inv )) deallocate( ozone_inv ) + if( allocated( varinv )) deallocate( varinv ) + if( allocated( sza )) deallocate( sza ) + if( allocated( fovn )) deallocate( fovn ) + if( allocated( toqf )) deallocate( toqf ) ncdiag_open_status(cur_idx)%nc_read = .true. @@ -831,6 +825,7 @@ subroutine read_ozndiag_data_bin( ftin, header_fix, data_fix, data_nlev, data_ex read(ftin,IOSTAT=iflag) ntobs write(6,*) ' READ 1, ntobs, iflag = ', ntobs, iflag + write(6,*) 'header_fix%nlevs, nlevs_last = ', header_fix%nlevs, nlevs_last if( header_fix%nlevs /= nlevs_last )then if( nlevs_last > 0 )then write(6,*) ' DEALLOCATING data_nlev, data_fix, data_mpi' @@ -845,8 +840,9 @@ subroutine read_ozndiag_data_bin( ftin, header_fix, data_fix, data_nlev, data_ex nlevs_last = header_fix%nlevs endif + write(6,*) 'iextra_last = ', iextra_last if (iextra_last > 0) then - deallocate (data_extra) + deallocate ( data_extra ) endif allocate( data_extra(header_fix%iextra,ntobs) ) @@ -869,7 +865,7 @@ subroutine read_ozndiag_data_bin( ftin, header_fix, data_fix, data_nlev, data_ex end do end do - deallocate(tmp_extra) + if( allocated( tmp_extra )) deallocate( tmp_extra ) endif do j=1,ntobs @@ -877,7 +873,7 @@ subroutine read_ozndiag_data_bin( ftin, header_fix, data_fix, data_nlev, data_ex data_fix(j)%lon = tmp_fix(2,j) data_fix(j)%obstime = tmp_fix(3,j) end do - deallocate(tmp_fix) + if( allocated( tmp_fix )) deallocate( tmp_fix ) do j=1,ntobs do i=1,header_fix%nlevs @@ -889,7 +885,7 @@ subroutine read_ozndiag_data_bin( ftin, header_fix, data_fix, data_nlev, data_ex data_nlev(i,j)%toqf = tmp_nlev(6,i,j) end do end do - deallocate(tmp_nlev) + if( allocated( tmp_nlev )) deallocate( tmp_nlev ) nlevs_last = -1 @@ -966,5 +962,5 @@ logical function verify_var_name_nc( test_name ) end function verify_var_name_nc -end module read_diag +end module oznmon_read_diag diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/sorc/oznmon_time.fd/time.f90 b/util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/sorc/oznmon_time.fd/time.f90 index d6402196aa..d9010cdbd9 100755 --- a/util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/sorc/oznmon_time.fd/time.f90 +++ b/util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/sorc/oznmon_time.fd/time.f90 @@ -1,5 +1,5 @@ program main - use read_diag + use oznmon_read_diag use valid use kinds, only: i_kind diff --git a/util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/ush/ozn_xtrct.sh b/util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/ush/ozn_xtrct.sh index 5ee05253fe..f05b0081b3 100755 --- a/util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/ush/ozn_xtrct.sh +++ b/util/Ozone_Monitor/nwprod/oznmon_shared.v2.0.0/ush/ozn_xtrct.sh @@ -75,7 +75,7 @@ fi # validate=".FALSE." if [[ $VALIDATE_DATA -eq 1 ]]; then - if [[ ! -e $ozn_val_file ]]; then + if [[ ! -e $ozn_val_file && ! -h $ozn_val_file ]]; then echo "WARNING: VALIDATE_DATA set to 1, but unable to locate $ozn_val_file" echo " Setting VALIDATE_DATA to 0/OFF" VALIDATE_DATA=0 @@ -153,8 +153,7 @@ else #--------------------------------------------------------------------------- - # NOTE: If ges && anl are to be processed then add an outer for loop on - # $ozn_ptype + # Outer loop over $ozn_ptype (default values 'ges', 'anl') # echo "ozn_ptype = $ozn_ptype" for ptype in ${ozn_ptype}; do