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

Subaxis setup #1056

Merged
merged 27 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d30cf29
Adds fms_diag_time_utils.F90 and copies get_time_string and diag_time…
uramirez8707 Sep 13, 2022
42a6820
Use diag_time_inc in the fileobj
uramirez8707 Sep 13, 2022
da0e941
bring up to date with dmUpdate
uramirez8707 Sep 13, 2022
eeb1d2d
Fix typos ...
uramirez8707 Sep 13, 2022
3719566
one more typo
uramirez8707 Sep 13, 2022
913e66f
merge the diag_time stuff
uramirez8707 Sep 13, 2022
1b63887
even more typos
uramirez8707 Sep 13, 2022
7183439
Merge branch 'time_utils' of github.com:uramirez8707/FMS into io_for_…
uramirez8707 Sep 13, 2022
25a4b43
finish setting up the io to open the file
uramirez8707 Sep 15, 2022
34157c1
fix typo add #ifdef use_yaml
uramirez8707 Sep 15, 2022
eab4cf6
Adds documentation, non-domain decomposed files now only get written …
uramirez8707 Sep 15, 2022
7ce9a77
merge dmUpdate
uramirez8707 Sep 15, 2022
cc67f91
set up the time for the next open and some bug fixes
uramirez8707 Sep 16, 2022
0a47f89
Fix bug that was causing issues with getting the type of domain
Sep 21, 2022
0c6d655
Adds code to setups the subaxis
uramirez8707 Sep 26, 2022
7d6b28d
fix line length limit
uramirez8707 Sep 26, 2022
dd2b7c2
removes allocating a pointer ...
uramirez8707 Sep 28, 2022
760e126
Merge branch 'io_for_real' of github.com:uramirez8707/FMS into subaxi…
uramirez8707 Sep 28, 2022
4594f32
Fix bugs in the code that get the starting and ending index of the su…
Sep 28, 2022
17c82e8
fixes bugs in the code that sets up the subaxis object, updates the i…
uramirez8707 Sep 30, 2022
0baf98b
fixes some #ifdefs
uramirez8707 Sep 30, 2022
3a7c09b
merge main, solve conflicts
uramirez8707 Oct 4, 2022
5a25c24
merge dmUpdate, solve merge conflicts
uramirez8707 Oct 17, 2022
af7dd97
revert some bad changes
uramirez8707 Oct 17, 2022
e8180bd
revert some bad changes
uramirez8707 Oct 17, 2022
cddfdc7
address reviwer's comments: rename variables, label long if's/do's
uramirez8707 Nov 7, 2022
2b26992
clean up use statements
uramirez8707 Nov 8, 2022
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
36 changes: 17 additions & 19 deletions diag_manager/fms_diag_axis_object.F90
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ subroutine write_axis_metadata(this, fileobj, parent_axis)

character(len=:), ALLOCATABLE :: axis_edges_name !< Name of the edges, if it exist
character(len=:), pointer :: axis_name !< Name of the axis
character(len=:), ALLOCATABLE, target :: sub_axis_name !< Name of the sub_axis
integer :: axis_length !< Size of the axis
integer :: i !< For do loops
type(fmsDiagFullAxis_type), pointer :: diag_axis !< Local pointer to the diag_axis
Expand All @@ -277,8 +276,7 @@ subroutine write_axis_metadata(this, fileobj, parent_axis)
axis_length = this%length
diag_axis => this
type is (fmsDiagSubAxis_type)
sub_axis_name = this%subaxis_name//"_sub01"
axis_name => sub_axis_name
axis_name => this%subaxis_name
axis_length = this%ending_index - this%starting_index + 1
!< Get all the other information from the parent axis (i.e the cart_name, units, etc)
if (present(parent_axis)) then
Expand Down Expand Up @@ -367,7 +365,7 @@ subroutine write_axis_data(this, fileobj, parent_axis)
if (present(parent_axis)) then
select type(parent_axis)
type is (fmsDiagFullAxis_type)
call write_data(fileobj, this%subaxis_name//"_sub01", parent_axis%axis_data(i:j))
call write_data(fileobj, this%subaxis_name, parent_axis%axis_data(i:j))
end select
endif
end select
Expand Down Expand Up @@ -418,10 +416,10 @@ subroutine set_edges_name(this, edges_name)

!> @brief Determine if the subRegion is in the current PE.
!! If it is, determine the starting and ending indices of the current PE that belong to the subRegion
subroutine get_indices(this, compute_idx, corners, starting_index, ending_index, need_to_define_axis)
subroutine get_indices(this, compute_idx, corners_indices, starting_index, ending_index, need_to_define_axis)
class(fmsDiagFullAxis_type), intent(inout) :: this !< diag_axis obj
integer, intent(in) :: compute_idx(:) !< Current PE's compute domain
class(*), intent(in) :: corners(:) !< The corners of the subRegion
class(*), intent(in) :: corners_indices(:) !< The indices of the corners of the subRegion
integer, intent(out) :: starting_index !< Starting index of the subRegion
!! for the current PE
integer, intent(out) :: ending_index !< Ending index of the subRegion
Expand All @@ -435,10 +433,10 @@ subroutine get_indices(this, compute_idx, corners, starting_index, ending_index,
!< Get the rectangular coordinates of the subRegion
!! If the subRegion is not rectangular, the points outside of the subRegion will be masked
!! out later
select type (corners)
select type (corners_indices)
type is (integer(kind=i4_kind))
thomas-robinson marked this conversation as resolved.
Show resolved Hide resolved
subregion_start = minval(corners)
subregion_end = maxval(corners)
subregion_start = minval(corners_indices)
subregion_end = maxval(corners_indices)
end select

!< Initiliaze the output
Expand Down Expand Up @@ -534,7 +532,7 @@ subroutine fill_subaxis(this, starting_index, ending_index, axis_id, parent_id,
this%ending_index = ending_index
this%parent_axis_id = parent_id
this%subRegion = subRegion
this%subaxis_name = trim(parent_axis_name)
this%subaxis_name = trim(parent_axis_name)//"_sub01"
end subroutine fill_subaxis

!> @brief Get the ntiles in a domain
Expand Down Expand Up @@ -784,12 +782,12 @@ subroutine define_subaxis_latlon(diag_axis, axis_ids, naxis, subRegion, is_cube_
lat(2) = maxval(corners(:,2))
end select

if (is_cube_sphere) then
if_is_cube_sphere: if (is_cube_sphere) then
!< Get the starting and ending indices of the subregion in the cubesphere relative to the global domain
call get_local_indices_cubesphere(lat(1), lat(2), lon(1), lon(2),&
& lon_indices(1), lon_indices(2), lat_indices(1), lat_indices(2))
do i = 1, size(axis_ids)
select type (parent_axis => diag_axis(axis_ids(i))%axis)
loop_over_axis_ids: do i = 1, size(axis_ids)
select_axis_type: select type (parent_axis => diag_axis(axis_ids(i))%axis)
type is (fmsDiagFullAxis_type)
!< Get the PEs compute domain
call parent_axis%get_compute_domain(compute_idx, need_to_define_axis)
Expand All @@ -815,10 +813,10 @@ subroutine define_subaxis_latlon(diag_axis, axis_ids, naxis, subRegion, is_cube_

call define_new_axis(diag_axis, parent_axis, naxis, axis_ids(i), &
subRegion, starting_index, ending_index)
end select
enddo
else
do i = 1, size(axis_ids)
end select select_axis_type
enddo loop_over_axis_ids
else if_is_cube_sphere
loop_over_axis_ids2: do i = 1, size(axis_ids)
select type (parent_axis => diag_axis(axis_ids(i))%axis)
type is (fmsDiagFullAxis_type)
!< Get the PEs compute domain
Expand Down Expand Up @@ -855,8 +853,8 @@ subroutine define_subaxis_latlon(diag_axis, axis_ids, naxis, subRegion, is_cube_
call define_new_axis(diag_axis, parent_axis, naxis, axis_ids(i), &
subRegion, starting_index, ending_index)
end select
end do
endif
enddo loop_over_axis_ids2
endif if_is_cube_sphere
end subroutine define_subaxis_latlon

!< Creates a new subaxis and fills it will all the information it needs
Expand Down
2 changes: 1 addition & 1 deletion diag_manager/fms_diag_field_object.F90
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module fms_diag_field_object_mod
use diag_data_mod, only: max_field_attributes, fmsDiagAttribute_type
use diag_data_mod, only: diag_null, diag_not_found, diag_not_registered, diag_registered_id, &
&DIAG_FIELD_NOT_FOUND
use mpp_mod, only: fatal, note, warning, mpp_error, stdout, mpp_pe, mpp_root_pe
use mpp_mod, only: fatal, note, warning, mpp_error, mpp_pe, mpp_root_pe
use fms_diag_yaml_mod, only: diagYamlFilesVar_type, get_diag_fields_entries, get_diag_files_id, &
& find_diag_field, get_num_unique_fields
use fms_diag_axis_object_mod, only: diagDomain_t, get_domain_and_domain_type, fmsDiagAxis_type, &
Expand Down
22 changes: 11 additions & 11 deletions diag_manager/fms_diag_file_object.F90
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ module fms_diag_file_object_mod
get_instance_filename, open_file, close_file, get_mosaic_tile_file
use diag_data_mod, only: DIAG_NULL, NO_DOMAIN, max_axes, SUB_REGIONAL, get_base_time, DIAG_NOT_REGISTERED, &
TWO_D_DOMAIN, UG_DOMAIN, prepend_date, DIAG_DAYS, VERY_LARGE_FILE_FREQ
use time_manager_mod, only: time_type, operator(>), operator(/=), operator(==), get_date
use time_manager_mod, only: time_type, operator(>), operator(/=), operator(==), get_date, &
operator(/=), operator(==), date_to_string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you have the operator(/=), operator(==) twice in this use statement

use fms_diag_time_utils_mod, only: diag_time_inc, get_time_string
use fms_diag_yaml_mod, only: diag_yaml, diagYamlObject_type, diagYamlFiles_type, subRegion_type
use fms_diag_axis_object_mod, only: diagDomain_t, get_domain_and_domain_type, fmsDiagAxis_type, &
fmsDiagAxisContainer_type, DIAGDOMAIN2D_T, DIAGDOMAINUG_T, &
fmsDiagFullAxis_type, define_subaxis
use mpp_mod, only: mpp_get_current_pelist, mpp_npes, mpp_root_pe, mpp_pe, mpp_error, FATAL, stdout
use time_manager_mod, only: time_type, operator(/=), operator(==), date_to_string

implicit none
private
Expand Down Expand Up @@ -124,7 +124,7 @@ module fms_diag_file_object_mod
type, extends (fmsDiagFile_type) :: subRegionalFile_type
integer, dimension(:), allocatable :: sub_axis_ids !< Array of axis ids in the file
logical :: write_on_this_pe !< Flag indicating if the subregion is on the current PE
logical :: subaxis_defined !< Flag indicating if the subaxes have already been defined
logical :: is_subaxis_defined !< Flag indicating if the subaxes have already been defined
end type subRegionalFile_type

!> \brief A container for fmsDiagFile_type. This is used to create the array of files
Expand All @@ -133,7 +133,7 @@ module fms_diag_file_object_mod

contains
procedure :: open_diag_file
procedure :: write_metadata
procedure :: write_axis_metadata
procedure :: write_axis_data
end type fmsDiagFileContainer_type

Expand Down Expand Up @@ -163,7 +163,7 @@ logical function fms_diag_files_object_init (files_array)
allocate(obj%sub_axis_ids(max_axes))
obj%sub_axis_ids = diag_null
obj%write_on_this_pe = .false.
obj%subaxis_defined = .false.
obj%is_subaxis_defined = .false.
obj%number_of_axis = 0
end select
else
Expand Down Expand Up @@ -335,7 +335,7 @@ end function get_file_unlimdim
!> \brief Returns a copy of file_sub_region from the yaml object
!! \return Copy of file_sub_region
function get_file_sub_region (obj) result(res)
class(fmsDiagFile_type), target, intent(in) :: obj !< The file object
class(fmsDiagFile_type), intent(in) :: obj !< The file object
type(subRegion_type) :: res
res = obj%diag_yaml_file%get_file_sub_region()
end function get_file_sub_region
Expand Down Expand Up @@ -555,14 +555,14 @@ subroutine add_axes(this, axis_ids, diag_axis, naxis)

select type(this)
type is (subRegionalFile_type)
if (.not. this%subaxis_defined) then
if (.not. this%is_subaxis_defined) then
if (associated(this%domain)) then
if (this%domain%get_ntiles() .eq. 6) is_cube_sphere = .true.
endif

call define_subaxis(diag_axis, axis_ids, naxis, this%get_file_sub_region(), &
is_cube_sphere, this%write_on_this_pe)
this%subaxis_defined = .true.
this%is_subaxis_defined = .true.

!> add the axis to the list of axis in the file
if (this%write_on_this_pe) then
Expand Down Expand Up @@ -621,7 +621,7 @@ subroutine add_start_time(this, start_time)
subroutine dump_file_obj(this, unit_num)
class(fmsDiagFile_type), intent(in) :: this !< the file object
integer, intent(in) :: unit_num !< passed in from dump_diag_obj
!! will either be for new log file or stdout
!! will either be for new log file or stdout
write( unit_num, *) 'file id:', this%id
write( unit_num, *) 'start time:', date_to_string(this%start_time)
write( unit_num, *) 'last_output', date_to_string(this%last_output)
Expand Down Expand Up @@ -789,7 +789,7 @@ subroutine open_diag_file(this, time_step, file_is_opened)
end subroutine open_diag_file

!< @brief Writes the axis metadata for the file
subroutine write_metadata(this, diag_axis)
subroutine write_axis_metadata(this, diag_axis)
class(fmsDiagFileContainer_type), intent(inout), target :: this !< The file object
class(fmsDiagAxisContainer_type), intent(in) :: diag_axis(:) !< Diag_axis object

Expand All @@ -812,7 +812,7 @@ subroutine write_metadata(this, diag_axis)
endif
enddo

end subroutine write_metadata
end subroutine write_axis_metadata

!< @brief Writes the axis data for the file
subroutine write_axis_data(this, diag_axis)
Expand Down
14 changes: 7 additions & 7 deletions diag_manager/fms_diag_object.F90
Original file line number Diff line number Diff line change
Expand Up @@ -427,14 +427,14 @@ subroutine fms_diag_send_complete(this, time_step)
#else
class(fmsDiagFileContainer_type), pointer :: diag_file !< Pointer to this%FMS_diag_files(i) (for convenience)

logical :: file_is_opened !< True if the file was opened in this time_step
!! If true the metadata will need to be written
logical :: file_is_opened_this_time_step !< True if the file was opened in this time_step
!! If true the metadata will need to be written

do i = 1, size(this%FMS_diag_files)
diag_file => this%FMS_diag_files(i)
call diag_file%open_diag_file(time_step, file_is_opened)
if (file_is_opened) then
call diag_file%write_metadata(this%diag_axis)
call diag_file%open_diag_file(time_step, file_is_opened_this_time_step)
if (file_is_opened_this_time_step) then
call diag_file%write_axis_metadata(this%diag_axis)
call diag_file%write_axis_data(this%diag_axis)
endif
enddo
Expand Down Expand Up @@ -627,7 +627,7 @@ subroutine dump_diag_obj( filename )
write(unit_num, *) 'axes_initialized:', fms_diag_object%axes_initialized
write(unit_num, *) 'Files:'
if( fms_diag_object%files_initialized ) then
do i=1, SIZE(fms_diag_object%FMS_diag_files)
do i=1, SIZE(fms_diag_object%FMS_diag_files)
write(unit_num, *) 'File num:', i
fileptr => fms_diag_object%FMS_diag_files(i)%FMS_diag_file
call fileptr%dump_file_obj(unit_num)
Expand All @@ -636,7 +636,7 @@ subroutine dump_diag_obj( filename )
write(unit_num, *) 'files not initialized'
endif
if( fms_diag_object%fields_initialized) then
do i=1, SIZE(fms_diag_object%FMS_diag_fields)
do i=1, SIZE(fms_diag_object%FMS_diag_fields)
write(unit_num, *) 'Field num:', i
fieldptr => fms_diag_object%FMS_diag_fields(i)
call fieldptr%dump_field_obj(unit_num)
Expand Down
12 changes: 6 additions & 6 deletions diag_manager/fms_diag_yaml.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1338,20 +1338,20 @@ end function get_diag_files_id

!> Prints out values from diag_yaml object for debugging.
!! Only writes on root.
subroutine dump_diag_yaml_obj( filename )
subroutine dump_diag_yaml_obj( filename )
character(len=*), optional, intent(in) :: filename !< optional name of logfile to write to, otherwise
!! prints to stdout
type(diagyamlfilesvar_type), allocatable :: fields(:)
type(diagyamlfiles_type), allocatable :: files(:)
integer :: i, unit_num
if( present(filename)) then
open(newunit=unit_num, file=trim(filename), action='WRITE')
open(newunit=unit_num, file=trim(filename), action='WRITE')
else
unit_num = stdout()
unit_num = stdout()
endif
!! TODO write to log
if( mpp_pe() .eq. mpp_root_pe()) then
write(unit_num, *) '**********Dumping diag_yaml object**********'
write(unit_num, *) '**********Dumping diag_yaml object**********'
if( diag_yaml%has_diag_title()) write(unit_num, *) 'Title:', diag_yaml%diag_title
if( diag_yaml%has_diag_basedate()) write(unit_num, *) 'basedate array:', diag_yaml%diag_basedate
write(unit_num, *) 'FILES'
Expand All @@ -1360,7 +1360,7 @@ subroutine dump_diag_yaml_obj( filename )
files = diag_yaml%get_diag_files()
fields = diag_yaml%get_diag_fields()
do i=1, SIZE(files)
write(unit_num, *) 'File: ', files(i)%get_file_fname()
write(unit_num, *) 'File: ', files(i)%get_file_fname()
if(files(i)%has_file_frequnit()) write(unit_num, *) 'file_frequnit:', files(i)%get_file_frequnit()
if(files(i)%has_file_freq()) write(unit_num, *) 'freq:', files(i)%get_file_freq()
if(files(i)%has_file_timeunit()) write(unit_num, *) 'timeunit:', files(i)%get_file_timeunit()
Expand All @@ -1379,7 +1379,7 @@ subroutine dump_diag_yaml_obj( filename )
enddo
write(unit_num, *) 'FIELDS'
do i=1, SIZE(fields)
write(unit_num, *) 'Field: ', fields(i)%get_var_fname()
write(unit_num, *) 'Field: ', fields(i)%get_var_fname()
if(fields(i)%has_var_fname()) write(unit_num, *) 'fname:', fields(i)%get_var_fname()
if(fields(i)%has_var_varname()) write(unit_num, *) 'varname:', fields(i)%get_var_varname()
if(fields(i)%has_var_reduction()) write(unit_num, *) 'reduction:', fields(i)%get_var_reduction()
Expand Down