Skip to content

Commit

Permalink
fix(train-cloud-micro): inquire about network file
Browse files Browse the repository at this point in the history
This commit replaces an `open` statement with an `inquire`
statatement to prevent a crash when mistakenly attempting
to reopen an already open file.
  • Loading branch information
rouson committed Oct 29, 2024
1 parent bb8ca86 commit 3f382f3
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions demo/app/train-cloud-microphysics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,14 @@ subroutine read_train_write(training_configuration, args, plot_file)
), &
network_file => args%base_name // "_network.json" &
)
open(newunit=network_unit, file=network_file, form='formatted', status='old', iostat=io_status, action='read')

check_for_network_file: &
block
logical preexisting_network_file

inquire(file=network_file, exist=preexisting_network_file)

read_or_initialize_network: &
if (io_status==0) then
if (preexisting_network_file) then
print *,"Reading network from file " // network_file
trainable_network = trainable_network_t(neural_network_t(file_t(string_t(network_file))))
close(network_unit)
Expand Down Expand Up @@ -303,6 +307,8 @@ subroutine read_train_write(training_configuration, args, plot_file)

end if read_or_initialize_network

end block check_for_network_file

print *, "Conditionally sampling for a flat distribution of output values"

flatten_histogram: &
Expand Down

0 comments on commit 3f382f3

Please sign in to comment.