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

Generalize train cloud microphysics #220

Merged
merged 25 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3da9fb1
chore(demo/app): rm unused normalization function
rouson Oct 16, 2024
187d8de
WIP: define/read NetCDF_variable_t objects
rouson Oct 16, 2024
308e9d0
chore(ubounds_t): rm derived type
rouson Oct 18, 2024
23113c5
feat(train_cloud_microphysics):generalize file I/O
rouson Oct 18, 2024
84c24bb
feat(NetCDF_variable): generalize time derivatives
rouson Oct 18, 2024
0b0e16a
feat(train_cloud_micro): assert no NaN derivatives
rouson Oct 18, 2024
ba04e9f
refac(train-cloud): generalize tensor/tensor-range
rouson Oct 18, 2024
e490110
refac(train-cloud): generalize max-entropy filter
rouson Oct 23, 2024
681cc14
chore(train-cloud-micro):label associate statement
rouson Oct 23, 2024
b542b09
chore(train-cloud-micro): white space edits
rouson Oct 23, 2024
4a916f3
feat(tensor_names): define type, constructors, I/O
rouson Oct 27, 2024
9d92687
chore(fpm.toml): update julienne version to 1.5.0
rouson Oct 27, 2024
1ae827f
refac(training_config): rm hardwired obj locations
rouson Oct 27, 2024
9d6d735
chore(fpm.toml): update julienne version to 1.5.2
rouson Oct 27, 2024
9060930
fix(training_configuration_t): define tensor_names
rouson Oct 27, 2024
7caad25
feat(tensor_names): {inputs,outputs}_names getters
rouson Oct 27, 2024
bb119af
chore(fpm.toml): update to julienne 1.5.3
rouson Oct 27, 2024
b969f81
feat(training_configuration):tensor_names_t object
rouson Oct 27, 2024
cb9a173
chore(train-cloud-micro): rm diagnostic output
rouson Oct 27, 2024
2dd7bb4
fix(training_configuration.json): reorder outputs
rouson Oct 28, 2024
027f072
test(NetCDF_variable):check "-" operand name match
rouson Oct 28, 2024
3bf6d0e
fix(train-cloud-micro): time difference formula
rouson Oct 28, 2024
bb8ca86
fix(write-read-infer): grammatical fixes in output
rouson Oct 28, 2024
3f382f3
fix(train-cloud-micro): inquire about network file
rouson Oct 29, 2024
3654313
chore(train-cloud-micro): indent block internals
rouson Oct 29, 2024
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
24 changes: 23 additions & 1 deletion demo/app/tensor-statistics.f90
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
! Copyright (c), The Regents of the University of California
! Terms of use are as specified in LICENSE.txt

module ubounds_m
!! This module serves only to support array bounds checking in the main program below
implicit none

type ubounds_t
integer, allocatable :: ubounds_(:)
contains
procedure equals
generic :: operator(==) => equals
end type

contains

elemental function equals(lhs, rhs) result(lhs_equals_rhs)
class(ubounds_t), intent(in) :: lhs, rhs
logical lhs_equals_rhs
lhs_equals_rhs = all(lhs%ubounds_ == rhs%ubounds_)
end function

end module

program tensor_statistics
!! This program
!! 1. Computes the ranges and histograms of input and output tensors saved by
Expand All @@ -9,7 +31,7 @@ program tensor_statistics
! External dependencies:
use julienne_m, only : command_line_t, file_t, string_t
use assert_m, only : assert, intrinsic_array_t
use fiats_m, only : ubounds_t
use ubounds_m, only : ubounds_t
use ieee_arithmetic, only : ieee_is_nan
use iso_fortran_env, only : int64, real64

Expand Down
632 changes: 308 additions & 324 deletions demo/app/train-cloud-microphysics.F90

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo/fpm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ maintainer = "(Please see fiats/fpm.toml.)"

[dependencies]
assert = {git = "https://github.com/sourceryinstitute/assert", tag = "1.7.0"}
julienne = {git = "https://github.com/berkeleylab/julienne", tag = "1.2.2"}
julienne = {git = "https://github.com/berkeleylab/julienne", tag = "1.5.3"}
fiats = {path = "../"}
netcdf-interfaces = {git = "https://github.com/LKedward/netcdf-interfaces.git", rev = "d2bbb71ac52b4e346b62572b1ca1620134481096"}
6 changes: 1 addition & 5 deletions demo/src/NetCDF_file_m.f90
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
! Copyright (c), The Regents of the University of California
! Terms of use are as specified in LICENSE.txt
#ifndef __INTEL_FORTRAN
!! Due to a suspected bug in the Intel ifx compiler, the above C preprocessor macro
!! effectively eliminates this file's source code when building with an Intel compiler.
module NetCDF_file_m
implicit none

Expand Down Expand Up @@ -52,5 +49,4 @@ module subroutine input_double_precision(self, varname, values)

end interface

end module NetCDF_file_m
#endif // __INTEL_FORTRAN
end module NetCDF_file_m
6 changes: 1 addition & 5 deletions demo/src/NetCDF_file_s.f90
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
! Copyright (c), The Regents of the University of California
! Terms of use are as specified in LICENSE.txt
#ifndef __INTEL_FORTRAN
!! Due to a suspected bug in the Intel ifx compiler, the above C preprocessor macro
!! effectively eliminates this file's source code when building with an Intel compiler.
submodule(netCDF_file_m) netCDF_file_s
use netcdf, only : &
nf90_create, nf90_def_dim, nf90_def_var, nf90_enddef, nf90_put_var, nf90_inquire_dimension, & ! functions
Expand Down Expand Up @@ -226,5 +223,4 @@ function get_shape(ncid, varname) result(array_shape)

end procedure

end submodule netCDF_file_s
#endif // __INTEL_FORTRAN
end submodule netCDF_file_s
237 changes: 237 additions & 0 deletions demo/src/NetCDF_variable_m.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
! Copyright (c), The Regents of the University of California
! Terms of use are as specified in LICENSE.txt
module NetCDF_variable_m
use NetCDF_file_m, only : NetCDF_file_t
use kind_parameters_m, only : default_real, double_precision
use julienne_m, only : string_t
use fiats_m, only : tensor_t
implicit none

private
public :: NetCDF_variable_t
public :: tensors

type NetCDF_variable_t(k)
integer, kind :: k = default_real
private
real(k), allocatable :: values_1D_(:), values_2D_(:,:), values_3D_(:,:,:), values_4D_(:,:,:,:)
character(len=:), allocatable :: name_
contains
generic :: input => default_real_input, double_precision_input, default_real_input_character_name, double_precision_input_character_name
procedure, private, non_overridable :: default_real_input, double_precision_input, default_real_input_character_name, double_precision_input_character_name
generic :: conformable_with => default_real_conformable_with, double_precision_conformable_with
procedure, private, non_overridable :: default_real_conformable_with, double_precision_conformable_with
generic :: rank => default_real_rank , double_precision_rank
procedure, private, non_overridable :: default_real_rank , double_precision_rank
generic :: end_step => default_real_end_step , double_precision_end_step
procedure, private, non_overridable :: default_real_end_step , double_precision_end_step
generic :: any_nan => default_real_any_nan , double_precision_any_nan
procedure, private, non_overridable :: default_real_any_nan , double_precision_any_nan
generic :: minimum => default_real_minimum , double_precision_minimum
procedure, private, non_overridable :: default_real_minimum , double_precision_minimum
generic :: maximum => default_real_maximum , double_precision_maximum
procedure, private, non_overridable :: default_real_maximum , double_precision_maximum
generic :: operator(-) => default_real_subtract , double_precision_subtract
procedure, private, non_overridable :: default_real_subtract , double_precision_subtract
generic :: operator(/) => default_real_divide , double_precision_divide
procedure, private, non_overridable :: default_real_divide , double_precision_divide
generic :: assignment(=) => default_real_assign , double_precision_assign
procedure, private, non_overridable :: default_real_assign , double_precision_assign
end type

interface NetCDF_variable_t

elemental module function default_real_copy(source, rename) result(NetCDF_variable)
implicit none
type(NetCDF_variable_t), intent(in) :: source
type(string_t), intent(in), optional :: rename
type(NetCDF_variable_t) NetCDF_variable
end function

elemental module function default_real_copy_character_name(source, rename) result(NetCDF_variable)
implicit none
type(NetCDF_variable_t), intent(in) :: source
character(len=*), intent(in), optional :: rename
type(NetCDF_variable_t) NetCDF_variable
end function

elemental module function double_precision_copy(source, rename) result(NetCDF_variable)
implicit none
type(NetCDF_variable_t(double_precision)), intent(in) :: source
type(string_t), intent(in), optional :: rename
type(NetCDF_variable_t(double_precision)) NetCDF_variable
end function

elemental module function double_precision_copy_character_name(source, rename) result(NetCDF_variable)
implicit none
type(NetCDF_variable_t(double_precision)), intent(in) :: source
character(len=*), intent(in), optional :: rename
type(NetCDF_variable_t(double_precision)) NetCDF_variable
end function

end interface

interface

impure elemental module subroutine default_real_input(self, variable_name, file, rank)
implicit none
class(NetCDF_variable_t), intent(inout) :: self
type(string_t), intent(in) :: variable_name
type(NetCDF_file_t), intent(in) :: file
integer, intent(in) :: rank
end subroutine

impure elemental module subroutine double_precision_input(self, variable_name, file, rank)
implicit none
class(NetCDF_variable_t(double_precision)), intent(inout) :: self
type(string_t), intent(in) :: variable_name
type(NetCDF_file_t), intent(in) :: file
integer, intent(in) :: rank
end subroutine

impure elemental module subroutine default_real_input_character_name(self, variable_name, file, rank)
implicit none
class(NetCDF_variable_t), intent(inout) :: self
character(len=*), intent(in) :: variable_name
type(NetCDF_file_t), intent(in) :: file
integer, intent(in) :: rank
end subroutine

impure elemental module subroutine double_precision_input_character_name(self, variable_name, file, rank)
implicit none
class(NetCDF_variable_t(double_precision)), intent(inout) :: self
character(len=*), intent(in) :: variable_name
type(NetCDF_file_t), intent(in) :: file
integer, intent(in) :: rank
end subroutine

elemental module function default_real_conformable_with(self, NetCDF_variable) result(conformable)
implicit none
class(NetCDF_variable_t), intent(in) :: self, NetCDF_variable
logical conformable
end function

elemental module function double_precision_conformable_with(self, NetCDF_variable) result(conformable)
implicit none
class(NetCDF_variable_t(double_precision)), intent(in) :: self, NetCDF_variable
logical conformable
end function

elemental module function default_real_rank(self) result(my_rank)
implicit none
class(NetCDF_variable_t), intent(in) :: self
integer my_rank
end function

elemental module function double_precision_rank(self) result(my_rank)
implicit none
class(NetCDF_variable_t(double_precision)), intent(in) :: self
integer my_rank
end function

elemental module function default_real_end_step(self) result(end_step)
implicit none
class(NetCDF_variable_t), intent(inout) :: self
integer end_step
end function

elemental module function double_precision_end_step(self) result(end_step)
implicit none
class(NetCDF_variable_t(double_precision)), intent(inout) :: self
integer end_step
end function

elemental module function default_real_subtract(lhs, rhs) result(difference)
implicit none
class(NetCDF_variable_t), intent(in) :: lhs, rhs
type(NetCDF_variable_t) difference
end function

elemental module function double_precision_subtract(lhs, rhs) result(difference)
implicit none
class(NetCDF_variable_t(double_precision)), intent(in) :: lhs, rhs
type(NetCDF_variable_t(double_precision)) difference
end function

elemental module function default_real_divide(lhs, rhs) result(ratio)
implicit none
class(NetCDF_variable_t), intent(in) :: lhs, rhs
type(NetCDF_variable_t) ratio
end function

elemental module function double_precision_divide(lhs, rhs) result(ratio)
implicit none
class(NetCDF_variable_t(double_precision)), intent(in) :: lhs, rhs
type(NetCDF_variable_t(double_precision)) ratio
end function

elemental module subroutine default_real_assign(lhs, rhs)
implicit none
class(NetCDF_variable_t), intent(inout) :: lhs
type(NetCDF_variable_t), intent(in) :: rhs
end subroutine

elemental module subroutine double_precision_assign(lhs, rhs)
implicit none
class(NetCDF_variable_t(double_precision)), intent(inout) :: lhs
type(NetCDF_variable_t(double_precision)), intent(in) :: rhs
end subroutine

elemental module function default_real_any_nan(self) result(any_nan)
implicit none
class(NetCDF_variable_t), intent(in) :: self
logical any_nan
end function

elemental module function double_precision_any_nan(self) result(any_nan)
implicit none
class(NetCDF_variable_t(double_precision)), intent(in) :: self
logical any_nan
end function

elemental module function default_real_minimum(self) result(minimum)
implicit none
class(NetCDF_variable_t), intent(in) :: self
real minimum
end function

elemental module function double_precision_minimum(self) result(minimum)
implicit none
class(NetCDF_variable_t(double_precision)), intent(in) :: self
real minimum
end function

elemental module function default_real_maximum(self) result(maximum)
implicit none
class(NetCDF_variable_t), intent(in) :: self
real maximum
end function

elemental module function double_precision_maximum(self) result(maximum)
implicit none
class(NetCDF_variable_t(double_precision)), intent(in) :: self
real maximum
end function

module function tensors(NetCDF_variables, step_start, step_end, step_stride)
implicit none
type(NetCDF_variable_t), intent(in) :: NetCDF_variables(:)
type(tensor_t), allocatable :: tensors(:)
integer, optional :: step_start, step_end, step_stride
end function

elemental module function default_real_end_time(self) result(end_time)
implicit none
class(NetCDF_variable_t), intent(inout) :: self
integer end_time
end function

elemental module function double_precision_end_time(self) result(end_time)
implicit none
class(NetCDF_variable_t), intent(inout) :: self
integer end_time
end function

end interface

end module
Loading
Loading