Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fixes to OznMon. #36

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 29 additions & 10 deletions util/Ozone_Monitor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 )
Expand All @@ -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")
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
program horiz
use read_diag
use oznmon_read_diag

implicit none
integer ntype, mls2_levs,mls3_levs
Expand Down
Original file line number Diff line number Diff line change
@@ -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 ---!

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 )
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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 )
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) )
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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'
Expand All @@ -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) )
Expand All @@ -869,15 +865,15 @@ 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
data_fix(j)%lat = tmp_fix(1,j)
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
Expand All @@ -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

Expand Down Expand Up @@ -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

Loading