Skip to content

Commit

Permalink
Update to silam_v5_8@601208
Browse files Browse the repository at this point in the history
Fix fast-math compilation (disable it for fishpack)
Enabled passing with FPE trap enabled (PUHTI_BUG #define for MPI)
 (https://gitlab.gnome.org/GNOME/libxml2/-/issues/478)
Added definitions for Danish Harmonie GRIBs for SLIM project
cleanup of config.pl
Unified puhti options for gcc-10
FRP plume rise for point source for NordStream paper

git-svn-id: https://svn.fmi.fi/svn/tie/SILAM/silam_v5_8@601208 250f1e8d-2010-0410-9efa-e22dadc992bd
  • Loading branch information
kouzne authored and rkouznetsov committed Feb 2, 2023
1 parent 54b7ae2 commit 63af8c7
Show file tree
Hide file tree
Showing 17 changed files with 616 additions and 152 deletions.
217 changes: 107 additions & 110 deletions build/config.pl
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,38 @@
# example: depend.pl source_list.txt silam_main linux_intel
#
# The source file silam_main.f90 will be taken as the main program.
#
#
# The script scans the fortran source files contained in the text file FILELIST, and
# uses the information to write the files source_build_rules and all_object_codes.
# uses the information to write the files source_build_rules and all_object_codes.
# These are in turn included into the SILAM makefile. Two versions of source_build_rules
# are generated: the full version lists the actual dependencies of each module,
# are generated: the full version lists the actual dependencies of each module,
# while in the simple version each module is considered to only depende on its own
# source code. The machine-dependent (md) file corresponding to PLATFORM
# will be used.
# source code. The machine-dependent (md) file corresponding to PLATFORM
# will be used.

#use warnings;
use File::Spec;

#my $rootfile = "silam_main.f90"; # The topmost object is specified here.
die(usage()) if (@ARGV < 2);
die(usage()) if (@ARGV < 2);
my ($filelist, $rootfile) = @ARGV;

my $srcdirname = '$(SRCDIR)';

# The "external" modules. Dependency to these is not included in the
# The "external" modules. Dependency to these is not included in the
# resulting makefile.

my @external = qw(iflport ifport omp_lib netcdf pnetcdf ifcore grib_api iso_c_binding iso_fortran_env mpi omp_lib_kinds eccodes psapi);
my @external = qw(iflport ifport omp_lib netcdf pnetcdf ifcore grib_api iso_c_binding iso_fortran_env mpi omp_lib_kinds eccodes psapi);

# Fixed form source files

my @fixed_files = qw(fortran_libraries bfgs m1qn3);

# Special compiler options

my %specials = (qr/cbm4_integrator/i => '-O1',
# qr/cbm4/ => '$(PREPROCESS)',
qr/netcdf/ => '-O0',
# qr/advection/ => '$(PREPROCESS)',
# qr/globals/ => '$(PREPROCESS)',
# qr/diffusion_3d/ => '$(PREPROCESS)'
qr/netcdf/ => '-O0',
qr/fishpack.silam/i => '-fno-fast-math',
);


Expand Down Expand Up @@ -95,99 +92,99 @@
open (my $fh2,"<$file_path") or die $!;
#print "$fn: \n";
foreach (@fixed_files) {
$fixed = '$(FIXED)' if ($fn =~ /$_/i);
$fixed = '$(FIXED)' if ($fn =~ /$_/i);
}
foreach (keys(%specials)) {
$special = sprintf("%s %s", $special, $specials{$_}) if ($fn =~ $_);
$special = sprintf("%s %s", $special, $specials{$_}) if ($fn =~ $_);
}

$modname = "";
my $use_array = [];

while (my $line = <$fh2>) {
if (($line =~ /(^\s*)module/i || $line =~ /^\s*program/i) && !$modname) {
# The header line of a module (or the program)
$is_program = ($line =~ /^\s*program/i);
($modname) = ($line =~ /^\s*(?:module|program) +(\w*)/i);
$modname =~ s/ //g;
$modname = lc($modname);
print $fhex "$modname \n" if (defined($fhex));
if (defined($fmake)) {
# write the name of object and its source file.
if ($is_program) {
print $fmake "\$(OBJDIR)${modname}.o : ${srcdirname}$fn ";
print $fh_make_simple "\$(OBJDIR)${modname}.o : ${srcdirname}$fn ";
} else {
print $fmake "\$(OBJDIR)${modname}.mod.o : ${srcdirname}$fn ";
print $fh_make_simple "\$(OBJDIR)${modname}.mod.o : ${srcdirname}$fn ";
}
}
$modname2fn{$modname} = $fn;
$deptree{$modname} = {'links',[], 'visited', 0};
if ($fn eq "$rootfile.f90") { $root_module = $modname; }
}
elsif ($line =~ /^ *(?:\!\$)? *use /i) {
# Then check the USE statements (note the !$ conditional before possible omp_lib).
($uses) = ($line =~ /^ *(?:\!\$)? *use +(\w*)/i);
$uses = lc($uses);
$openmp = '$(OPENMP)' if ($uses =~ /omp_lib/i);
next if (grep(/$uses/, @external));
print $fhex " $uses \n" if (defined($fhex));
if (defined($fmake)) {
print $fmake "\$(OBJDIR)${uses}.mod.o "; # write the additional dependencies.
}
if (defined($fhdot) && !(grep(/$uses/, @$use_array))) {
print $fhdot "$modname -> $uses \n";
}
#print $fmake "\\ \n" if !($makef_itemcounter % 3);
push @$use_array, $uses;
$makef_itemcounter++;
}# elsif ($line =~ /implicit/i) {
# last; # no USE statements will occur after this.
#}

# Check if this module has default private visibility - scan
# for the lone 'private' keyword - but it must be outside a
# derived type definition.
# check for the beginning of typedef
$in_type_def = $in_type_def || ($line =~ /^\s*type +\w+\s*$/i);
# check for the end of typedef
if ($in_type_def && $line =~ /^\s*end *type/i) { $in_type_def = 0; }

if (defined($fhdot) && !$in_type_def && ($line =~ /^\s*private\s*$/i || $line =~ /^\s*private\s*\!/i)) {
#print "private: $modname\n";
print $fhdot "$modname [style=bold]\n";
}
if (($line =~ /(^\s*)module/i || $line =~ /^\s*program/i) && !$modname) {
# The header line of a module (or the program)
$is_program = ($line =~ /^\s*program/i);
($modname) = ($line =~ /^\s*(?:module|program) +(\w*)/i);
$modname =~ s/ //g;
$modname = lc($modname);
print $fhex "$modname \n" if (defined($fhex));
if (defined($fmake)) {
# write the name of object and its source file.
if ($is_program) {
print $fmake "\$(OBJDIR)${modname}.o : ${srcdirname}$fn ";
print $fh_make_simple "\$(OBJDIR)${modname}.o : ${srcdirname}$fn ";
} else {
print $fmake "\$(OBJDIR)${modname}.mod.o : ${srcdirname}$fn ";
print $fh_make_simple "\$(OBJDIR)${modname}.mod.o : ${srcdirname}$fn ";
}
}

$modname2fn{$modname} = $fn;
$deptree{$modname} = {'links',[], 'visited', 0};
if ($fn eq "$rootfile.f90") { $root_module = $modname; }
}
elsif ($line =~ /^ *(?:\!\$)? *use /i) {
# Then check the USE statements (note the !$ conditional before possible omp_lib).
($uses) = ($line =~ /^ *(?:\!\$)? *use +(\w*)/i);
$uses = lc($uses);
$openmp = '$(OPENMP)' if ($uses =~ /omp_lib/i);
next if (grep(/$uses/, @external));
print $fhex " $uses \n" if (defined($fhex));
if (defined($fmake)) {
print $fmake "\$(OBJDIR)${uses}.mod.o "; # write the additional dependencies.
}
if (defined($fhdot) && !(grep(/$uses/, @$use_array))) {
print $fhdot "$modname -> $uses \n";
}
#print $fmake "\\ \n" if !($makef_itemcounter % 3);
push @$use_array, $uses;
$makef_itemcounter++;
}# elsif ($line =~ /implicit/i) {
# last; # no USE statements will occur after this.
#}

# Check if this module has default private visibility - scan
# for the lone 'private' keyword - but it must be outside a
# derived type definition.

# check for the beginning of typedef
$in_type_def = $in_type_def || ($line =~ /^\s*type +\w+\s*$/i);
# check for the end of typedef
if ($in_type_def && $line =~ /^\s*end *type/i) { $in_type_def = 0; }

if (defined($fhdot) && !$in_type_def && ($line =~ /^\s*private\s*$/i || $line =~ /^\s*private\s*\!/i)) {
#print "private: $modname\n";
print $fhdot "$modname [style=bold]\n";
}
}

$deptree{$modname}->{'links'} = $use_array;
close($fh2);
# Now write the commands.
if (defined($fmake)) {
unless ($is_program) {
print $fmake "\n\t\$(F90C) \$(FFLAGS) \$(PREPROCESS) -c $special $fixed $openmp -o \$(OBJDIR)${modname}.mod.o \$(SRCDIR)${fn}";
#print $fmake "|revision \n\t\$(F90C) \$(FFLAGS) -c $special $fixed $openmp -o \$(OBJDIR)${modname}.mod.o \$(SRCDIR)${fn}";
#print $fh_make_simple "|revision \n\t\$(F90C) \$(FFLAGS) -c $special $fixed $openmp -o \$(OBJDIR)${modname}.mod.o \$(SRCDIR)${fn}";
print $fh_make_simple "\n\t\$(F90C) \$(FFLAGS) \$(PREPROCESS) -c $special $fixed $openmp -o \$(OBJDIR)${modname}.mod.o \$(SRCDIR)${fn}";
if ($use_semicolon) {
print $fmake "&& mv ${modname}.mod \$(OBJDIR)";
print $fh_make_simple "&& mv ${modname}.mod \$(OBJDIR)";
} else {
print $fmake "\n\tmv *.mod \$(OBJDIR)";
print $fh_make_simple "\n\tmv *.mod \$(OBJDIR)";
}
} else {
print $fmake "\n\t\$(F90C) \$(FFLAGS) \$(PREPROCESS) -c $special $fixed $openmp -o \$(OBJDIR)${modname}.o \$(SRCDIR)${fn}";
print $fh_make_simple "\n\t\$(F90C) \$(FFLAGS) \$(PREPROCESS) -c $special $fixed $openmp -o \$(OBJDIR)${modname}.o \$(SRCDIR)${fn}";
}
print $fh_make_simple "\n\n";
print $fmake "\n\n";
unless ($is_program) {
print $fmake "\n\t\$(F90C) \$(FFLAGS) \$(PREPROCESS) -c $special $fixed $openmp -o \$(OBJDIR)${modname}.mod.o \$(SRCDIR)${fn}";
#print $fmake "|revision \n\t\$(F90C) \$(FFLAGS) -c $special $fixed $openmp -o \$(OBJDIR)${modname}.mod.o \$(SRCDIR)${fn}";
#print $fh_make_simple "|revision \n\t\$(F90C) \$(FFLAGS) -c $special $fixed $openmp -o \$(OBJDIR)${modname}.mod.o \$(SRCDIR)${fn}";
print $fh_make_simple "\n\t\$(F90C) \$(FFLAGS) \$(PREPROCESS) -c $special $fixed $openmp -o \$(OBJDIR)${modname}.mod.o \$(SRCDIR)${fn}";
if ($use_semicolon) {
print $fmake "&& mv ${modname}.mod \$(OBJDIR)";
print $fh_make_simple "&& mv ${modname}.mod \$(OBJDIR)";
} else {
print $fmake "\n\tmv *.mod \$(OBJDIR)";
print $fh_make_simple "\n\tmv *.mod \$(OBJDIR)";
}
} else {
print $fmake "\n\t\$(F90C) \$(FFLAGS) \$(PREPROCESS) -c $special $fixed $openmp -o \$(OBJDIR)${modname}.o \$(SRCDIR)${fn}";
print $fh_make_simple "\n\t\$(F90C) \$(FFLAGS) \$(PREPROCESS) -c $special $fixed $openmp -o \$(OBJDIR)${modname}.o \$(SRCDIR)${fn}";
}
print $fh_make_simple "\n\n";
print $fmake "\n\n";
}
}

print $fhdot '}' if defined($fhdot);
print $fhdot '}' if defined($fhdot);
# alternative way to write the makefile

#foreach $modname(keys %modname2fn) {
Expand All @@ -200,20 +197,20 @@
# #print $module_object;
# printf $fmake "%s : ${srcdirname}%s","\$(OBJDIR)${module_object}", $modname2fn{$modname};
# foreach my $dependency(@$depend_ptr) {
# (my $module_object2 = $modname2fn{$dependency}) =~ s/f90/o/;
# print "Dependecy $modname not found, assuming external....\n" if !$module_object2;
# print $fmake " \$(OBJDIR)${module_object2}"
# (my $module_object2 = $modname2fn{$dependency}) =~ s/f90/o/;
# print "Dependecy $modname not found, assuming external....\n" if !$module_object2;
# print $fmake " \$(OBJDIR)${module_object2}"
# }
# print $fmake "\n\t\$(F90C) $fixed -o \$(OBJDIR)${module_object} \$(SRCDIR_MIKHAIL)${fn} \n\t\mv *.mod \$(OBJDIR)";
# print $fmake "\n\n";
# print $fmake "\n\n";
# $fixed = '';
#}

# write the object file list
print $fh_objects 'COMMON_OBJS =' if (defined($fh_objects));

# We traverse the graph of dependecies, described by the %deptree.
# This way, the all_object_codes lists the objects in order of
# This way, the all_object_codes lists the objects in order of
# dependency.

visit($root_module);
Expand All @@ -232,25 +229,25 @@ ($)
my @children = @$children_ptr;
my $child;
# perform the depth-first search, recursively.

$deptree{$node}->{'visited'} = 1;
if (!@children) {
print $fhtree "$node \n" if defined($fhtree);
print $fh_objects " \\\n\$(OBJDIR)${node}.mod.o" if defined($fh_objects);
push @stack, $node;
return;
print $fhtree "$node \n" if defined($fhtree);
print $fh_objects " \\\n\$(OBJDIR)${node}.mod.o" if defined($fh_objects);
push @stack, $node;
return;
} else {
while ($child = pop @children) {
next unless $deptree{$child};
visit($child) unless $deptree{$child}->{'visited'};
}
while ($child = pop @children) {
next unless $deptree{$child};
visit($child) unless $deptree{$child}->{'visited'};
}
}

print $fhtree "$node \n" if defined($fhtree);
if ($node eq $root_module) {
print $fh_objects " \\\n\$(OBJDIR)${node}.o" if defined($fh_objects);
print $fh_objects " \\\n\$(OBJDIR)${node}.o" if defined($fh_objects);
} else {
print $fh_objects " \\\n\$(OBJDIR)${node}.mod.o" if defined($fh_objects);
print $fh_objects " \\\n\$(OBJDIR)${node}.mod.o" if defined($fh_objects);
}
push @stack, $node;
}
Expand Down
2 changes: 1 addition & 1 deletion build/options.puhti
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ SILAM_LIBS =
INCLUDE = -I$(OBJDIR) -I/usr/include -I${NCDIR}/include -I${GRDIR}/include -I${PNCDIR}/include #-m64 -I${MKLROOT}/include
# Libraries given as linker options

LFLAGS = -fopenmp -leccodes_f90 -leccodes -lnetcdff -lnetcdf -lm -ldl -lbz2 -lscalapack -lproj -L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core
LFLAGS = -fopenmp -leccodes_f90 -leccodes -lnetcdff -lnetcdf -lm -ldl -lbz2 -lproj -L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_sequential -lmkl_intel_lp64 -lmkl_core

#LFLAGS = -fopenmp -ljasper -llapack -ljasper -lblas -llapack -leccodes_f90 -leccodes -lnetcdff -lnetcdf -lpnetcdf -lbz2
10 changes: 5 additions & 5 deletions build/options.puhti_mpi
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ F90C = mpif90
# Flags for optimization, etc.
OPTIMIZATION = -fopenmp -O2 -ffast-math

DEBUG = -g -fbacktrace #-Waliasing #-DDEBUG
#DEBUG = -g -fbacktrace -finit-real=snan -fcheck=all -finit-integer=-88888888 -ffpe-trap=invalid,zero,overflow -DDEBUG #-DDEBUG_OBS ##-ffpe-trap causes trouble
DEBUG = -g -fbacktrace #-fcheck=all #-DDEBUG
#DEBUG = -g -fbacktrace -Waliasing -finit-real=snan -fcheck=all -finit-integer=-88888888 -ffpe-trap=invalid,zero,overflow -DDEBUG #-DDEBUG_OBS ##-ffpe-trap causes trouble

FIXED = -ffixed-form
PREPROCESS = -x f95-cpp-input -D WITH_NF90_NETCDF4 -D WITH_PNETCDF -DSILAM_MPI -D WITH_BZIP2 -D USE_PROJ4
FFLAGS = $(OPTIMIZATION) $(DEBUG) $(TESTOPTIONS) $(INCLUDE) -ffree-line-length-none
PREPROCESS = -x f95-cpp-input -D WITH_NF90_NETCDF4 -D WITH_PNETCDF -DSILAM_MPI -D WITH_BZIP2 -D USE_PROJ4 -D PUHTI_BUG
FFLAGS = $(OPTIMIZATION) $(DEBUG) $(TESTOPTIONS) $(INCLUDE) -ffree-line-length-none


# netcdf install directory
Expand All @@ -31,6 +31,6 @@ SILAM_LIBS =
INCLUDE = -I$(OBJDIR) -I/usr/include -I${NCDIR}/include -I${GRDIR}/include -I${PNCDIR}/include #-m64 -I${MKLROOT}/include
# Libraries given as linker options

LFLAGS = -fopenmp -leccodes_f90 -leccodes -lnetcdff -lnetcdf -lm -ldl -lbz2 -lscalapack -lproj -L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -lpnetcdf
LFLAGS = -fopenmp -leccodes_f90 -leccodes -lnetcdff -lnetcdf -lm -ldl -lbz2 -lproj -L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_sequential -lmkl_intel_lp64 -lmkl_core -lpnetcdf

#LFLAGS = -fopenmp -ljasper -llapack -ljasper -lblas -llapack -leccodes_f90 -leccodes -lnetcdff -lnetcdf -lpnetcdf -lbz2
1 change: 1 addition & 0 deletions ini/eccodes/definitions/grib1/localConcepts/ekmi
Loading

0 comments on commit 63af8c7

Please sign in to comment.