Skip to content

Commit

Permalink
Squashed 'src/externals/pio2/' changes from e41e6a6..1ff0f44
Browse files Browse the repository at this point in the history
1ff0f44 Merge pull request ESMCI#1653 from jedwards4b/short_type_in_fortran
b089073 Merge branch 'master' into short_type_in_fortran
30a1b79 Merge pull request ESMCI#1650 from NCAR/ejh_fix_warnings_2
1c448af fix mem error
038b3a7 Correct -D_PNETCDF flag
14140f8 revert travis
b78ee97 bionic didnt work try Xenial
750209f try updating travis build
f44b71e update genf90 external
01452c3 add short data type to fortran interface and tests
b049420 add a short datatype to the fortran interface
ceff4ea fixed warnings in tests
a4fb42f Merge pull request ESMCI#1644 from NCAR/ejh_netcdf_4_7_4_more
82e781c changed test to always use deflate of 1
20c529c Merge pull request ESMCI#1643 from NCAR/ejh_netcdf_4_7_4
e722b81 turned off logging in test
ed7c53a restored test
8365a2c no longer try to set deflate on scalar vars
f8a3275 adjusted dispatch table for netcdf-c-4.7.4

git-subtree-dir: src/externals/pio2
git-subtree-split: 1ff0f44
  • Loading branch information
jedwards4b committed Jun 9, 2020
1 parent 580381b commit c295eb3
Show file tree
Hide file tree
Showing 26 changed files with 333 additions and 241 deletions.
66 changes: 36 additions & 30 deletions scripts/genf90.pl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
# to generate F90 code for all of the desired specific types.
#
# Keywords are delimited by curly brackets: {}
#
# {TYPE} and {DIMS} are used to generate the specific subroutine names from the
#
# {TYPE} and {DIMS} are used to generate the specific subroutine names from the
# generic template
# {TYPE} : Variable type name; implemented types are character, 4 or 8 byte real,
# and 4 or 8 byte integer.
Expand All @@ -20,7 +20,7 @@
# if {TYPE}=double then {VTYPE} is "real(r8)"
# {ITYPE}, {ITYPENAME} : Used to generate CPP statements for the specific type.
# {MPITYPE} : Used to generate MPI types corresponding to the specific type.
#
#
# {DIMS} : Rank of arrays, "0" for scalar.
# allowed values: 0-7
# default values : 0-5
Expand All @@ -33,40 +33,46 @@
# expands to this:
# foo(1, bar), foo(2, bar), foo(3, bar), ...

# defaults
my @types = qw(text real double int);
my $vtype = {'text' => 'character(len=*)',
'real' => 'real(r4)',
# defaults
my @types = qw(text real double int short);
my $vtype = {'text' => 'character(len=*)',
'real' => 'real(r4)',
'double' => 'real(r8)',
'int' => 'integer(i4)',
'short' => 'integer(i2)',
'long' => 'integer(i8)',
'logical' => 'logical' };
my $itype = {'text' => 100,
'real' => 101,
my $itype = {'text' => 100,
'real' => 101,
'double' => 102,
'int' => 103,
'long' => 104,
'logical' => 105};
my $itypename = {'text' => 'TYPETEXT',
'real' => 'TYPEREAL',
'logical' => 105,
'short' => 106};
my $itypename = {'text' => 'TYPETEXT',
'real' => 'TYPEREAL',
'double' => 'TYPEDOUBLE',
'int' => 'TYPEINT',
'short' => 'TYPESHORT',
'long' => 'TYPELONG',
'logical' => 'TYPELOGICAL'};
my $mpitype = {'text' => 'MPI_CHARACTER',
'real' => 'MPI_REAL4',
'short' => 'MPI_SHORT',
'double' => 'MPI_REAL8',
'int' => 'MPI_INTEGER'};
# Netcdf C datatypes
my $nctype = {'text' => 'text',
'real' => 'float',
'short' => 'short',
'double' => 'double',
'int' => 'int'};
# C interoperability types
my $ctype = {'text' => 'character(C_CHAR)',
'real' => 'real(C_FLOAT)',
'double' => 'real(C_DOUBLE)',
'int' => 'integer(C_INT)'};
'int' => 'integer(C_INT)',
'short' => 'integer(C_SHORT)'};



Expand Down Expand Up @@ -108,9 +114,9 @@
my @unit;
my $unitcnt=0;
my $date = localtime();
my $preamble =
my $preamble =
"!===================================================
! DO NOT EDIT THIS FILE, it was generated using $0
! DO NOT EDIT THIS FILE, it was generated using $0
! Any changes you make to this file may be lost
!===================================================\n";
my @output ;
Expand All @@ -134,7 +140,7 @@
$itypeflag=1 if($line =~ /TYPEINT/);
$itypeflag=1 if($line =~ /TYPELONG/);


if($contains==0){
if($line=~/\s*!\s*DIMS\s+[\d,]+!*/){
$dimmodifier=$line;
Expand Down Expand Up @@ -186,12 +192,12 @@
if(defined $dimmodifier){
$line = $dimmodifier.$line;
undef $dimmodifier;
}
}
if(defined $typemodifier){
$line = $typemodifier.$line;
undef $typemodifier;
}
}

push(@output, buildout($line));
if(($line =~ /^\s*contains\s*!*/i && ! $in_type_block) or
($line =~ /^\s*!\s*Not a module/i)){
Expand All @@ -218,7 +224,7 @@
}
}


push(@{$unit[$unitcnt]},$line);
if ($line=~/^\s*interface/i) {
$block_type="interface";
Expand All @@ -242,10 +248,10 @@
if(defined($unit[$i])){
my $func = join('',@{$unit[$i]});
push(@output, buildout($func));
}
}
}
push(@output,@{$unit[$#unit]}) if($unitcnt==$#unit);
push(@output, $end);
push(@output, $end);
if($itypeflag==1){
my $str;
$str.="#include \"dtypes.h\"\n";
Expand Down Expand Up @@ -283,9 +289,9 @@ sub build_repeatstr{

sub writedtypes{
open(F,">dtypes.h");
print F
print F
"#define TYPETEXT 100
#define TYPEREAL 101
#define TYPEREAL 101
#define TYPEDOUBLE 102
#define TYPEINT 103
#define TYPELONG 104
Expand All @@ -296,7 +302,7 @@ sub writedtypes{

sub buildout{
my ($func) = @_;

my $outstr;
my(@ldims, @ltypes);

Expand All @@ -306,12 +312,12 @@ sub buildout{
@ldims = @dims;
}
if($func=~/\s*!\s*TYPE\s+([^!\s]+)\s*/){
@ltypes = split(/,/,$1);
@ltypes = split(/,/,$1);
# print ">$func<>@ltypes<\n";
}else{
@ltypes = @types;
}


if(($func =~ /{TYPE}/ && $func =~ /{DIMS}/) ){
my ($type, $dims);
Expand All @@ -330,7 +336,7 @@ sub buildout{
}

my $repeatstr = build_repeatstr($dims);

my $str = $func;
$str =~ s/{TYPE}/$type/g;
$str =~ s/{VTYPE}/$vtype->{$type}/g;
Expand Down Expand Up @@ -358,9 +364,9 @@ sub buildout{
}else{
$dimstr='';
}

my $repeatstr = build_repeatstr($dims);

my $str = $func;
$str =~ s/{DIMS}/$dims/g;
$str =~ s/{DIMSTR}/$dimstr/g;
Expand Down
2 changes: 1 addition & 1 deletion set_flags.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/src/flib -D_NETCDF

# Is the user building with pnetcdf?
if BUILD_PNETCDF
AM_CPPFLAGS += -D_PETCDF
AM_CPPFLAGS += -D_PNETCDF
endif

# Is the user building with netCDF-4 parallel I/O?
Expand Down
13 changes: 12 additions & 1 deletion src/clib/pio_darray.c
Original file line number Diff line number Diff line change
Expand Up @@ -988,8 +988,19 @@ PIOc_read_darray(int ncid, int varid, int ioid, PIO_Offset arraylen,
{
if (!(tmparray = malloc(iodesc->piotype_size * iodesc->maplen)))
return pio_err(ios, NULL, PIO_ENOMEM, __FILE__, __LINE__);
for (int m = 0; m < iodesc->maplen; m++)
if(iodesc->piotype_size == 1){
for (int m = 0; m < iodesc->maplen; m++)
((signed char *)array)[m] = -1;
}else if(iodesc->piotype_size == 2){
for (int m = 0; m < iodesc->maplen; m++)
((short *)array)[m] = -1;
}else if(iodesc->piotype_size == 4){
for (int m = 0; m < iodesc->maplen; m++)
((int *)array)[m] = -1;
}else if(iodesc->piotype_size == 8){
for (int m = 0; m < iodesc->maplen; m++)
((double *)array)[m] = -1;
}
}
else
tmparray = array;
Expand Down
4 changes: 2 additions & 2 deletions src/clib/pio_nc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2280,8 +2280,8 @@ PIOc_def_var(int ncid, const char *name, nc_type xtype, int ndims,
#ifdef _NETCDF4
/* For netCDF-4 serial files, turn on compression for this
* variable, unless this file was opened through the netCDF
* integration feature. */
if (!ierr && file->iotype == PIO_IOTYPE_NETCDF4C && !file->ncint_file)
* integration feature (or is a scalar). */
if (!ierr && file->iotype == PIO_IOTYPE_NETCDF4C && !file->ncint_file && ndims)
ierr = nc_def_var_deflate(file->fh, varid, 0, 1, 1);

/* For netCDF-4 parallel files, set parallel access to collective. */
Expand Down
7 changes: 6 additions & 1 deletion src/clib/pio_nc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ PIOc_def_var_deflate(int ncid, int varid, int shuffle, int deflate,
if (file->iotype != PIO_IOTYPE_NETCDF4P && file->iotype != PIO_IOTYPE_NETCDF4C)
return pio_err(ios, file, PIO_ENOTNC4, __FILE__, __LINE__);

PLOG((1, "PIOc_def_var_deflate ncid = %d varid = %d shuffle = %d deflate = %d deflate_level = %d",
ncid, varid, shuffle, deflate, deflate_level));

/* If async is in use, and this is not an IO task, bcast the parameters. */
if (ios->async)
{
Expand Down Expand Up @@ -116,7 +119,7 @@ PIOc_def_var_deflate(int ncid, int varid, int shuffle, int deflate,
* @param deflatep pointer to an int that will be set to non-zero if
* deflation is in use for this variable. Ignored if NULL.
* @param deflate_levelp pointer to an int that will get the deflation
* level (from 1-9) if deflation is in use for this variable. Ignored
* level (from 1-9) if deflation is in use for this variable. Ignored
* if NULL.
* @return PIO_NOERR for success, otherwise an error code.
* @ingroup PIO_inq_var_c
Expand All @@ -140,6 +143,8 @@ PIOc_inq_var_deflate(int ncid, int varid, int *shufflep, int *deflatep,
if (file->iotype != PIO_IOTYPE_NETCDF4P && file->iotype != PIO_IOTYPE_NETCDF4C)
return pio_err(ios, file, PIO_ENOTNC4, __FILE__, __LINE__);

PLOG((1, "PIOc_inq_var_deflate ncid = %d varid = %d", ncid, varid));

/* If async is in use, and this is not an IO task, bcast the parameters. */
if (ios->async)
{
Expand Down
2 changes: 1 addition & 1 deletion src/flib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ else ()
ExternalProject_Add (genf90
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/genf90
GIT_REPOSITORY https://github.com/PARALLELIO/genf90
GIT_TAG genf90_140121
GIT_TAG genf90_200608
UPDATE_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
Expand Down
2 changes: 1 addition & 1 deletion src/flib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# The library we are building.
lib_LTLIBRARIES = libpiof.la

AM_CPPFLAGS = -D_NETCDF -D_NETCDF4 -D_PETCDF
AM_CPPFLAGS = -D_NETCDF -D_NETCDF4 -D_PNETCDF

# These linker flags specify libtool version info.
# See http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning
Expand Down
13 changes: 6 additions & 7 deletions src/flib/pio.F90
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
!>
!! @file
!! @file
!! User interface Module for PIO, this is the only file a user program should 'use'.
!! @author Jim Edwards
!<
Expand Down Expand Up @@ -33,7 +33,7 @@ module pio
pio_rearr_opt_t, pio_rearr_comm_fc_opt_t, pio_rearr_comm_fc_2d_enable,&
pio_rearr_comm_fc_1d_comp2io, pio_rearr_comm_fc_1d_io2comp,&
pio_rearr_comm_fc_2d_disable, pio_rearr_comm_unlimited_pend_req,&
pio_rearr_comm_p2p, pio_rearr_comm_coll,&
pio_rearr_comm_p2p, pio_rearr_comm_coll, pio_short, &
pio_int, pio_real, pio_double, pio_noerr, iotype_netcdf, &
iotype_pnetcdf, pio_iotype_netcdf4p, pio_iotype_netcdf4c, &
pio_iotype_pnetcdf,pio_iotype_netcdf, &
Expand All @@ -45,7 +45,7 @@ module pio
pio_64bit_offset, pio_64bit_data, &
pio_internal_error, pio_bcast_error, pio_return_error, pio_default

use piodarray, only : pio_read_darray, pio_write_darray, pio_set_buffer_size_limit
use piodarray, only : pio_read_darray, pio_write_darray, pio_set_buffer_size_limit

use pio_nf, only: &
PIO_enddef, &
Expand Down Expand Up @@ -124,11 +124,11 @@ integer(C_INT) function PIOc_iam_iotask(iosysid, iotask) &
logical(C_BOOL), intent(out) :: iotask
end function PIOc_iam_iotask
end interface

ierr = PIOc_iam_iotask(iosystem%iosysid, ctask)
task = ctask
end function pio_iam_iotask

!>
!! Integer function returns rank of IO task.
!! @author Jim Edwards
Expand All @@ -144,7 +144,7 @@ integer(C_INT) function PIOc_iotask_rank(iosysid, rank) &
integer(C_INT), intent(out) :: rank
end function PIOc_iotask_rank
end interface

ierr = PIOc_iotask_rank(iosystem%iosysid, rank)
end function pio_iotask_rank

Expand Down Expand Up @@ -172,4 +172,3 @@ end function PIOc_iosystem_is_active
end subroutine pio_iosystem_is_active

end module pio

3 changes: 2 additions & 1 deletion src/flib/pio_kinds.F90
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ module pio_kinds
char_len = 360 ,& !< char len
log_kind = kind(.true.) ,& !< logical kind
int_kind = kind(1) ,& !< int kind
i2 = selected_int_kind(4) ,& !< i2 (short) kind
i4 = selected_int_kind(6) ,& !< i4 kind
i8 = selected_int_kind(13) ,& !< i8 kind
r4 = selected_real_kind(6) ,& !< r4 kind
r8 = selected_real_kind(13) !< r8 kind
!
! MPI defines MPI_OFFSET_KIND as the byte size of the
! MPI defines MPI_OFFSET_KIND as the byte size of the
! type, which is not nessasarily the type kind
!
!> Byte size of the MPI_OFFSET type.
Expand Down
4 changes: 3 additions & 1 deletion src/flib/pio_types.F90
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@
!!
!! @defgroup PIO_kinds PIO Fortran Type Kinds
!! PIO supports different kinds of Fortran types.
!! - PIO_double : 8-byte reals or double precision
!! - PIO_doauble : 8-byte reals or double precision
!! - PIO_real : 4-byte reals
!! - PIO_int : 4-byte integers
!! - PIO_short : 2-byte integers
!! - PIO_char : character

module pio_types
Expand Down Expand Up @@ -136,6 +137,7 @@ module pio_types
integer, public, parameter :: PIO_double = nf_double !< double type
integer, public, parameter :: PIO_real = nf_real !< real type
integer, public, parameter :: PIO_int = nf_int !< int type
integer, public, parameter :: PIO_short = nf_short !< short int type
integer, public, parameter :: PIO_char = nf_char !< char type
integer, public, parameter :: PIO_noerr = nf_noerr !< no error
integer, public, parameter :: PIO_WRITE = nf_write !< read-write
Expand Down
Loading

0 comments on commit c295eb3

Please sign in to comment.