From d62f97f47e04830a554061a63a917d262357a79d Mon Sep 17 00:00:00 2001 From: Katherine Rasmussen Date: Thu, 1 Feb 2024 17:17:05 -0800 Subject: [PATCH] Wrap all `random_init` calls with directives so they don't execute when compiling with nagfor. These directives should be removed when, as expected, nagfor provides support for `random_init` in an upcoming version. --- example/learn-addition.f90 | 2 ++ example/learn-exponentiation.f90 | 6 ++++-- example/learn-microphysics-procedures.f90 | 2 ++ example/learn-multiplication.f90 | 2 ++ example/learn-power-series.f90 | 2 ++ example/learn-saturated-mixing-ratio.f90 | 2 ++ example/train-and-write.f90 | 2 ++ test/main.f90 | 8 +++++--- 8 files changed, 21 insertions(+), 5 deletions(-) diff --git a/example/learn-addition.f90 b/example/learn-addition.f90 index cf36ea488..9a3294f08 100644 --- a/example/learn-addition.f90 +++ b/example/learn-addition.f90 @@ -47,7 +47,9 @@ program learn_addition type(bin_t), allocatable :: bins(:) real, allocatable :: cost(:), random_numbers(:) +#ifndef NAGFOR call random_init(image_distinct=.true., repeatable=.true.) +#endif trainable_engine = perturbed_identity_network(perturbation_magnitude=0.05) call output(trainable_engine%to_inference_engine(), string_t("initial-network.json")) diff --git a/example/learn-exponentiation.f90 b/example/learn-exponentiation.f90 index 124bc4132..d3f6982a6 100644 --- a/example/learn-exponentiation.f90 +++ b/example/learn-exponentiation.f90 @@ -47,7 +47,9 @@ program learn_exponentiation type(bin_t), allocatable :: bins(:) real, allocatable :: cost(:), random_numbers(:) +#ifndef NAGFOR call random_init(image_distinct=.true., repeatable=.true.) +#endif trainable_engine = perturbed_identity_network(perturbation_magnitude=0.05) call output(trainable_engine%to_inference_engine(), string_t("initial-network.json")) @@ -60,10 +62,10 @@ program learn_exponentiation inputs = [(tensor_t(real([(j*i, j = 1,num_inputs)])/(num_inputs*num_pairs)), i = 1, num_pairs)] desired_outputs = y(inputs) output_sizes = [(size(desired_outputs(i)%values()),i=1,size(desired_outputs))] - call assert(all([num_outputs==output_sizes]), "fit-polynomials: # outputs", intrinsic_array_t([num_outputs,output_sizes])) + call assert(all([num_outputs==output_sizes]), "fit-polynomials: # outputs", intrinsic_array_t([num_outputs,output_sizes])) end block input_output_pairs = input_output_pair_t(inputs, desired_outputs) - block + block integer b bins = [(bin_t(num_items=num_pairs, num_bins=num_mini_batches, bin_number=b), b = 1, num_mini_batches)] end block diff --git a/example/learn-microphysics-procedures.f90 b/example/learn-microphysics-procedures.f90 index 5a115c690..a9e444731 100644 --- a/example/learn-microphysics-procedures.f90 +++ b/example/learn-microphysics-procedures.f90 @@ -39,7 +39,9 @@ program learn_microphysics_procedures integer, parameter :: nodes_per_layer(*) = [2, 72, 2] real, parameter :: cost_tolerance = 1.E-08 +#ifndef NAGFOR call random_init(image_distinct=.true., repeatable=.true.) +#endif open(newunit=network_unit, file=network_file%string(), form='formatted', status='old', iostat=io_status, action='read') diff --git a/example/learn-multiplication.f90 b/example/learn-multiplication.f90 index cc996415e..0e175ab47 100644 --- a/example/learn-multiplication.f90 +++ b/example/learn-multiplication.f90 @@ -47,7 +47,9 @@ program learn_multiplication type(bin_t), allocatable :: bins(:) real, allocatable :: cost(:), random_numbers(:) +#ifndef NAGFOR call random_init(image_distinct=.true., repeatable=.true.) +#endif trainable_engine = perturbed_identity_network(perturbation_magnitude=0.05) call output(trainable_engine%to_inference_engine(), string_t("initial-network.json")) diff --git a/example/learn-power-series.f90 b/example/learn-power-series.f90 index df136204b..e37d32eef 100644 --- a/example/learn-power-series.f90 +++ b/example/learn-power-series.f90 @@ -47,7 +47,9 @@ program learn_power_series type(bin_t), allocatable :: bins(:) real, allocatable :: cost(:), random_numbers(:) +#ifndef NAGFOR call random_init(image_distinct=.true., repeatable=.true.) +#endif trainable_engine = perturbed_identity_network(perturbation_magnitude=0.05) call output(trainable_engine%to_inference_engine(), string_t("initial-network.json")) diff --git a/example/learn-saturated-mixing-ratio.f90 b/example/learn-saturated-mixing-ratio.f90 index 472653cb1..08dcad2dc 100644 --- a/example/learn-saturated-mixing-ratio.f90 +++ b/example/learn-saturated-mixing-ratio.f90 @@ -38,7 +38,9 @@ program train_saturated_mixture_ratio integer, parameter :: nodes_per_layer(*) = [2, 72, 1] real, parameter :: cost_tolerance = 1.E-08 +#ifndef NAGFOR call random_init(image_distinct=.true., repeatable=.true.) +#endif open(newunit=network_unit, file=network_file%string(), form='formatted', status='old', iostat=io_status, action='read') diff --git a/example/train-and-write.f90 b/example/train-and-write.f90 index 78a9c9411..4f492bdac 100644 --- a/example/train-and-write.f90 +++ b/example/train-and-write.f90 @@ -34,7 +34,9 @@ program train_and_write type(bin_t), allocatable :: bins(:) real, allocatable :: cost(:), random_numbers(:) +#ifndef NAGFOR call random_init(image_distinct=.true., repeatable=.true.) +#endif trainable_engine = perturbed_identity_network(perturbation_magnitude=0.2) call output(trainable_engine%to_inference_engine(), string_t("initial-network.json")) diff --git a/test/main.f90 b/test/main.f90 index cfb350749..78911a10e 100644 --- a/test/main.f90 +++ b/test/main.f90 @@ -1,9 +1,9 @@ ! Copyright (c), The Regents of the University of California ! Terms of use are as specified in LICENSE.txt program main - use inference_engine_test_m, only : inference_engine_test_t - use asymmetric_engine_test_m, only : asymmetric_engine_test_t - use trainable_engine_test_m, only : trainable_engine_test_t + use inference_engine_test_m, only : inference_engine_test_t + use asymmetric_engine_test_m, only : asymmetric_engine_test_t + use trainable_engine_test_m, only : trainable_engine_test_t use hyperparameters_test_m, only : hyperparameters_test_t use network_configuration_test_m, only : network_configuration_test_t use training_configuration_test_m, only : training_configuration_test_t @@ -20,7 +20,9 @@ program main integer :: passes=0, tests=0 call cpu_time(t_start) +#ifndef NAGFOR call random_init(image_distinct=.true., repeatable=.true.) +#endif call inference_engine_test%report(passes, tests) call asymmetric_engine_test%report(passes, tests) call trainable_engine_test%report(passes, tests)