Skip to content

Commit

Permalink
Merge pull request #1 from billsacks/hardcoded_params_out
Browse files Browse the repository at this point in the history
Fix Fortran unit tests
  • Loading branch information
slevis-lmwg authored May 3, 2019
2 parents 6ac7429 + e11794d commit 1aa02ac
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 12 deletions.
12 changes: 1 addition & 11 deletions src/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
# Note that this is just used for unit testing; hence, we only need to add
# source files that are currently used in unit tests

set(genf90_files
ncdio_pio.F90.in
)

process_genf90_source_list("${genf90_files}" ${CMAKE_CURRENT_SOURCE_DIR} clm_genf90_sources)

sourcelist_to_parent(clm_genf90_sources)

list(APPEND clm_sources "${clm_genf90_sources}")

list(APPEND clm_sources
ColumnType.F90
pftconMod.F90
Expand All @@ -37,10 +27,10 @@ list(APPEND clm_sources
lnd2glcMod.F90
ncdio_utils.F90
organicFileMod.F90
paramUtilMod.F90
subgridAveMod.F90
subgridWeightsMod.F90
surfrdUtilsMod.F90
paramUtilMod.F90
)

sourcelist_to_parent(clm_sources)
72 changes: 72 additions & 0 deletions src/unit_test_stubs/main/ncdio_pio_fake.F90.in
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module ncdio_pio
!
! !PUBLIC MEMBER FUNCTIONS:

public :: check_var ! determine if variable is on netcdf file
public :: ncd_io ! do fake i/o (currently only set up to read)
public :: ncd_inqvid ! inquire on a variable id
public :: ncd_set_var ! set data on "file" for one variable
Expand All @@ -54,7 +55,9 @@ module ncdio_pio
public :: ncd_pio_openfile ! stub: open file
public :: ncd_pio_closefile ! stub: close file
public :: ncd_inqdid ! stub: inquire dimension id
public :: ncd_inqvdims ! stub: inquire variable dimensions
public :: ncd_inqvdlen ! stub: inquire size of a dimension
public :: ncd_inqvdname ! stub: inquire name of a dimension
public :: ncd_inqdlen ! stub: inquire size of a dimension
public :: ncd_defvar ! define variables
public :: ncd_inqfdims ! stub: inquire file dimensions
Expand Down Expand Up @@ -263,6 +266,29 @@ contains
end if
end subroutine ncd_inqvid

!-----------------------------------------------------------------------
subroutine check_var(ncid, varname, vardesc, readvar, print_err)
!
! !DESCRIPTION:
! Fake to check if variable is on netcdf file
!
! !ARGUMENTS:
class(file_desc_t) , intent(inout) :: ncid ! PIO file descriptor
character(len=*) , intent(in) :: varname ! Varible name to check
type(Var_desc_t) , intent(out) :: vardesc ! Output variable descriptor (not set in this implementation)
logical , intent(out) :: readvar ! If variable exists or not
logical, optional , intent(in) :: print_err ! If should print about error (ignored in this implementation)
!
! !LOCAL VARIABLES:
integer :: varid

character(len=*), parameter :: subname = 'check_var'
!-----------------------------------------------------------------------

call ncd_inqvid(ncid, varname, varid, vardesc, readvar)

end subroutine check_var

!-----------------------------------------------------------------------
subroutine ncd_inqdid(ncid, name, dimid, dimexist)
!
Expand Down Expand Up @@ -559,6 +585,27 @@ contains
end if
end subroutine ncd_io_{DIMS}d_{TYPE}_glob

!-----------------------------------------------------------------------
subroutine ncd_inqvdims(ncid,ndims,vardesc)
!
! !DESCRIPTION:
! Stub replacement for ncd_inqvdims. This does nothing, but just satisfies the
! interface for ncd_inqvdims.
!
! !ARGUMENTS:
class(file_desc_t), intent(in) :: ncid ! netcdf file id
integer , intent(out) :: ndims ! variable ndims
type(Var_desc_t) , intent(inout):: vardesc ! variable descriptor
!
! !LOCAL VARIABLES:

character(len=*), parameter :: subname = 'ncd_inqvdims'
!-----------------------------------------------------------------------

ndims = -1

end subroutine ncd_inqvdims

!-----------------------------------------------------------------------
subroutine ncd_inqvdlen(ncid,varname,dimnum,dlen,err_code)
!
Expand All @@ -579,6 +626,31 @@ contains

end subroutine ncd_inqvdlen

!-----------------------------------------------------------------------
subroutine ncd_inqvdname(ncid,varname,dimnum,dname,err_code)
!
! !DESCRIPTION:
! Stub replacement for ncd_inqvdname_byName (note that we currently do not support
! ncd_inqvdlen_byDesc). This does nothing, but just satisfies the interface for
! ncd_inqvdname.
!
! !ARGUMENTS:
class(file_desc_t),intent(inout) :: ncid ! netcdf file id
character(len=*) ,intent(in) :: varname ! variable name
integer ,intent(in) :: dimnum ! dimension number to query
character(len=*) ,intent(out) :: dname ! name of the dimension
integer ,intent(out) :: err_code ! error code (0 means no error)
!
! !LOCAL VARIABLES:

character(len=*), parameter :: subname = 'ncd_inqvdname'
!-----------------------------------------------------------------------

dname = ' '
err_code = 0

end subroutine ncd_inqvdname

!-----------------------------------------------------------------------
subroutine ncd_inqfdims(ncid, isgrid2d, ni, nj, ns)
!
Expand Down
1 change: 0 additions & 1 deletion src/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ list(APPEND clm_sources
quadraticMod.F90
fileutils.F90
NumericsMod.F90
spmdMod.F90
)

sourcelist_to_parent(clm_sources)

0 comments on commit 1aa02ac

Please sign in to comment.