Skip to content

Commit

Permalink
Remove open_file_unit and associated interface
Browse files Browse the repository at this point in the history
No longer need this function, since the other one uses the internal unit
of file_type.

Also, might as well switch the .testing Makefile to check the FMS2
infra (although this really ought to be configurable, if not active over
all infra).
  • Loading branch information
marshallward committed Jun 21, 2022
1 parent 04af887 commit e2289cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 40 deletions.
4 changes: 2 additions & 2 deletions .testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ SOURCE = \
$(foreach ext,F90 inc c h,$(wildcard $(1)/*/*.$(ext) $(1)/*/*/*.$(ext)))

MOM_SOURCE = $(call SOURCE,../src) \
$(wildcard ../config_src/infra/FMS1/*.F90) \
$(wildcard ../config_src/infra/FMS2/*.F90) \
$(wildcard ../config_src/drivers/solo_driver/*.F90) \
$(wildcard ../config_src/ext*/*/*.F90)
TARGET_SOURCE = $(call SOURCE,build/target_codebase/src) \
$(wildcard build/target_codebase/config_src/infra/FMS1/*.F90) \
$(wildcard build/target_codebase/config_src/infra/FMS2/*.F90) \
$(wildcard build/target_codebase/config_src/drivers/solo_driver/*.F90) \
$(wildcard build/target_codebase/config_src/ext*/*.F90)
FMS_SOURCE = $(call SOURCE,$(DEPS)/fms/src)
Expand Down
43 changes: 5 additions & 38 deletions config_src/infra/FMS2/MOM_io_infra.F90
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ module MOM_io_infra
module procedure MOM_file_exists
end interface

!> Open a file (or fileset) for parallel or single-file I/O.
interface open_file
module procedure open_file_type, open_file_unit
end interface open_file

!> Read a data field from a file
interface read_field
module procedure read_field_4d
Expand Down Expand Up @@ -260,35 +255,7 @@ subroutine write_version(version, tag, unit)
end subroutine write_version

!> open_file opens a file for parallel or single-file I/O.
subroutine open_file_unit(unit, filename, action, form, threading, fileset, nohdrs, domain, MOM_domain)
integer, intent(out) :: unit !< The I/O unit for the opened file
character(len=*), intent(in) :: filename !< The name of the file being opened
integer, optional, intent(in) :: action !< A flag indicating whether the file can be read
!! or written to and how to handle existing files.
integer, optional, intent(in) :: form !< A flag indicating the format of a new file. The
!! default is ASCII_FILE, but NETCDF_FILE is also common.
integer, optional, intent(in) :: threading !< A flag indicating whether one (SINGLE_FILE)
!! or multiple PEs (MULTIPLE) participate in I/O.
!! With the default, the root PE does I/O.
integer, optional, intent(in) :: fileset !< A flag indicating whether multiple PEs doing I/O due
!! to threading=MULTIPLE write to the same file (SINGLE_FILE)
!! or to one file per PE (MULTIPLE, the default).
logical, optional, intent(in) :: nohdrs !< If nohdrs is .TRUE., headers are not written to
!! ASCII files. The default is .false.
type(domain2d), optional, intent(in) :: domain !< A domain2d type that describes the decomposition
type(MOM_domain_type), optional, intent(in) :: MOM_Domain !< A MOM_Domain that describes the decomposition

if (present(MOM_Domain)) then
call mpp_open(unit, filename, action=action, form=form, threading=threading, fileset=fileset, &
nohdrs=nohdrs, domain=MOM_Domain%mpp_domain)
else
call mpp_open(unit, filename, action=action, form=form, threading=threading, fileset=fileset, &
nohdrs=nohdrs, domain=domain)
endif
end subroutine open_file_unit

!> open_file opens a file for parallel or single-file I/O.
subroutine open_file_type(IO_handle, filename, action, MOM_domain, threading, fileset)
subroutine open_file(IO_handle, filename, action, MOM_domain, threading, fileset)
type(file_type), intent(inout) :: IO_handle !< The handle for the opened file
character(len=*), intent(in) :: filename !< The path name of the file being opened
integer, optional, intent(in) :: action !< A flag indicating whether the file can be read
Expand Down Expand Up @@ -316,12 +283,12 @@ subroutine open_file_type(IO_handle, filename, action, MOM_domain, threading, fi
integer :: index_nc

if (IO_handle%open_to_write) then
call MOM_error(WARNING, "open_file_type called for file "//trim(filename)//&
call MOM_error(WARNING, "open_file called for file "//trim(filename)//&
" with an IO_handle that is already open to to write.")
return
endif
if (IO_handle%open_to_read) then
call MOM_error(FATAL, "open_file_type called for file "//trim(filename)//&
call MOM_error(FATAL, "open_file called for file "//trim(filename)//&
" with an IO_handle that is already open to to read.")
endif

Expand All @@ -344,7 +311,7 @@ subroutine open_file_type(IO_handle, filename, action, MOM_domain, threading, fi
elseif (file_mode == OVERWRITE_FILE) then ; mode = "overwrite"
elseif (file_mode == READONLY_FILE) then ; mode = "read"
else
call MOM_error(FATAL, "open_file_type called with unrecognized action.")
call MOM_error(FATAL, "open_file called with unrecognized action.")
endif

IO_handle%num_times = 0
Expand Down Expand Up @@ -381,7 +348,7 @@ subroutine open_file_type(IO_handle, filename, action, MOM_domain, threading, fi
IO_handle%open_to_read = .false. ; IO_handle%open_to_write = .true.
endif

end subroutine open_file_type
end subroutine open_file

!> open_file opens an ascii file for parallel or single-file I/O using Fortran read and write calls.
subroutine open_ASCII_file(unit, file, action, threading, fileset)
Expand Down

0 comments on commit e2289cf

Please sign in to comment.