Skip to content
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
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@
# Graphics
*.plt
*.png

# archives and compressed files
*.gz
*.bz2
*.tar
*.tbz2
*.tgz
*.zip
252 changes: 119 additions & 133 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
@@ -1,6 +1,6 @@
name = "Fiats-Demonstration-Applications"

[dependencies]
julienne = {git = "https://github.com/berkeleylab/julienne", tag = "3.2.1"}
julienne = {git = "https://github.com/berkeleylab/julienne", tag = "3.6.1"}
fiats = {path = "../"}
netcdf-interfaces = {git = "https://github.com/berkeleylab/netcdf-interfaces.git", rev = "d2bbb71ac52b4e346b62572b1ca1620134481096"}
19 changes: 16 additions & 3 deletions demo/src/NetCDF_variable_m.f90
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ module NetCDF_variable_m
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 :: start_step => default_real_start_step , double_precision_start_step
procedure, private, non_overridable :: default_real_start_step , double_precision_start_step
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
Expand Down Expand Up @@ -145,6 +147,18 @@ elemental module function double_precision_rank(self) result(my_rank)
integer my_rank
end function

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

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

elemental module function default_real_end_step(self) result(end_step)
implicit none
class(NetCDF_variable_t), intent(in) :: self
Expand Down Expand Up @@ -205,11 +219,10 @@ elemental module function double_precision_maximum(self) result(maximum)
real maximum
end function

module function tensors(NetCDF_variables, step_start, step_end, step_stride)
module function tensors(NetCDF_variables)
implicit none
class(NetCDF_variable_t), intent(in) :: NetCDF_variables(:)
class(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)
Expand Down
74 changes: 54 additions & 20 deletions demo/src/NetCDF_variable_s.F90
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,36 @@ pure function double_precision_components_allocated(NetCDF_variable) result(allo
end associate
end procedure

module procedure default_real_start_step
select case(self%rank())
case(1)
start_step = lbound(self%values_1D_,1)
case(2)
start_step = lbound(self%values_2D_,2)
case(3)
start_step = lbound(self%values_3D_,3)
case(4)
start_step = lbound(self%values_4D_,4)
case default
error stop "NetCDF_variable_s(default_real_start_step): unsupported rank"
end select
end procedure

module procedure double_precision_start_step
select case(self%rank())
case(1)
start_step = lbound(self%values_1D_,1)
case(2)
start_step = lbound(self%values_2D_,2)
case(3)
start_step = lbound(self%values_3D_,3)
case(4)
start_step = lbound(self%values_4D_,4)
case default
error stop "NetCDF_variable_s(double_precision_start_step): unsupported rank"
end select
end procedure

module procedure default_real_end_step
select case(self%rank())
case(1)
Expand Down Expand Up @@ -399,30 +429,34 @@ pure function double_precision_upper_bounds(NetCDF_variable) result(ubounds)

module procedure tensors

integer t_start, t_end, t_stride

select case(NetCDF_variables(1)%rank())
case(4)
integer v, f, lon, lat, lev, time

t_start = default_or_present_value(1, step_start )
t_stride = default_or_present_value(1, step_stride)
t_end = default_or_present_value(size(NetCDF_variables(1)%values_4D_,4), step_end)
associate(component_rank => NetCDF_variables(1,1)%rank())

associate( longitudes => size(NetCDF_variables(1)%values_4D_,1) &
,latitudes => size(NetCDF_variables(1)%values_4D_,2) &
,levels => size(NetCDF_variables(1)%values_4D_,3) &
)
block
integer v, lon, lat, lev, time
call_julienne_assert(.all. (NetCDF_variables(:,:)%rank() .equalsExpected. component_rank))

tensors = [( [( [( [( tensor_t( [( NetCDF_variables(v)%values_4D_(lon,lat,lev,time), v=1,size(NetCDF_variables) )] ), &
lon = 1, longitudes)], lat = 1, latitudes)], lev = 1, levels)], time = t_start, t_end, t_stride)]
end block
end associate
select case(component_rank)
case(4)
associate( longitudes => size(NetCDF_variables(1,1)%values_4D_,1) &
,latitudes => size(NetCDF_variables(1,1)%values_4D_,2) &
,levels => size(NetCDF_variables(1,1)%values_4D_,3) &
,t_end => size(NetCDF_variables(1,1)%values_4D_,4) &
,variables => size(NetCDF_variables,1) &
,files => size(NetCDF_variables,2) &
)
call_julienne_assert(.all. ([( [( size(NetCDF_variables(v,f)%values_4D_,1), v = 1, variables)], f = 1, files)] .equalsExpected. longitudes))
call_julienne_assert(.all. ([( [( size(NetCDF_variables(v,f)%values_4D_,2), v = 1, variables)], f = 1, files)] .equalsExpected. latitudes))
call_julienne_assert(.all. ([( [( size(NetCDF_variables(v,f)%values_4D_,3), v = 1, variables)], f = 1, files)] .equalsExpected. levels))
call_julienne_assert(.all. ([( [( size(NetCDF_variables(v,f)%values_4D_,4), v = 1, variables)], f = 1, files)] .equalsExpected. t_end))

tensors = [( [( [( [( [( tensor_t( [( NetCDF_variables(v,f)%values_4D_(lon,lat,lev,time), v=1,size(NetCDF_variables,1) )] ), &
lon = 1, longitudes)], lat = 1, latitudes)], lev = 1, levels)], time = 1, t_end )], f = 1, files )]
end associate
case default
error stop "NetCDF_variable_s(tensors): unsupported rank)"
end select

case default
error stop "NetCDF_variable_s(tensors): unsupported rank)"
end select
end associate

end procedure

Expand Down
16 changes: 13 additions & 3 deletions demo/train.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
#!/bin/bash
min_bins=$1
max_bins=$2

set -e # exit if any simple command returns a non-zero exit code

min_bins=${1:-3}
max_bins=${2:-4}
executable=${3:-"train-cloud-microphysics"}

if [ ! -x $executable ]; then
printf "\n $executable not found or not executable. Search ./build and, if you find $executable, create a soft link to it in this directory.\n\n"
exit 1
fi

let subfloor=$min_bins-1
j=subfloor
while (( j++ < max_bins )); do
Expand All @@ -19,7 +29,7 @@ while (( j++ < max_bins )); do

echo ""
echo "---------> Run $i <---------"
./train-cloud-microphysics --base training --epochs 1000000 --bins $j --report 1000 --start 360 --stride 10 --tolerance "5.0E-08"
./"$executable" --base fiats-training-data/training --epochs 1000000 --bins $j --report 1000 --tolerance "5.0E-08"

if [ -f converged ]; then
echo ""
Expand Down
2 changes: 1 addition & 1 deletion demo/training_data_files.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"path" : "fiats-training-data",
"inputs prefix" : "training_input-image-_",
"outputs prefix" : "training_output-image-_",
"infixes" : ["0", "50"]
"infixes" : ["450", "500"]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module saturated_mixing_ratio_m
!! in the Intermediate Complexity Atmospheric Research (ICAR) model file src/physics/mp_simple.f90.
!! ICAR is distributed under the above MIT license. See https://github.com/ncar/icar.
use fiats_m, only : tensor_t
use julienne_m, only : call_julienne_assert_, operator(.equalsExpected.)
use julienne_m, only : call_julienne_assert_, operator(.also.), operator(.equalsExpected.), operator(//)
implicit none

private
Expand Down Expand Up @@ -75,7 +75,7 @@ elemental function y(x_in) result(a)
type(tensor_t), intent(in) :: x_in
type(tensor_t) a
associate(x => x_in%values())
call_julienne_assert((lbound(x,1) .equalsExpected. 1) .also. (ubound(x,1) .equalsExpected. 2,"y(x) :: sufficient input"))
call_julienne_assert((lbound(x,1) .equalsExpected. 1) .also. ((ubound(x,1) .equalsExpected. 2) // "y(x) :: sufficient input"))
a = tensor_t([saturated_mixing_ratio(x(1),x(2))])
end associate
end function
Expand Down
2 changes: 1 addition & 1 deletion fpm.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name = "fiats"
[dependencies]
julienne = {git = "https://github.com/berkeleylab/julienne", tag = "3.2.1"}
julienne = {git = "https://github.com/berkeleylab/julienne", tag = "3.6.1"}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
! Copyright (c), The Regents of the University of California
! Terms of use are as specified in LICENSE.txt

#ifndef FIATS_LANGUAGE_SUPPORT
#define FIATS_LANGUAGE_SUPPORT

#ifndef F2023_LOCALITY
#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 202400)
# define F2023_LOCALITY 1
Expand All @@ -18,3 +21,5 @@
# define MULTI_IMAGE_SUPPORT 1
#endif
#endif

#endif