forked from CESM-Development/cime
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ESMCI#1559 from NCAR/ejh_ncint_fortran
netcdf integration for Fortran
- Loading branch information
Showing
7 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#define __PIO_FILE__ "piolib_mod.f90" | ||
#include "config.h" | ||
!> | ||
!! @file | ||
!! Initialization Routines for PIO. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
## This is the automake file for building the netCDF integration layer | ||
## tests. | ||
|
||
# Ed Hartnett 7/3/19 | ||
|
||
# Link to the PIO Fortran and C libraries. | ||
LDADD = ${top_builddir}/src/flib/libpiof.la ${top_builddir}/src/clib/libpioc.la | ||
|
||
# Link to the netCDF fortran library. | ||
LDADD += -lnetcdff | ||
|
||
# Find the pio.mod file. | ||
AM_FCFLAGS = -I${top_builddir}/src/flib ${CPPFLAGS} | ||
|
||
# Build the test for make check. | ||
check_PROGRAMS = ftst_pio | ||
ftst_pio_SOURCES = ftst_pio.f90 | ||
|
||
if RUN_TESTS | ||
# Tests will run from a bash script. | ||
TESTS = run_tests.sh | ||
endif # RUN_TESTS | ||
|
||
# Distribute the test script. | ||
EXTRA_DIST = run_tests.sh | ||
|
||
# Clean up files produced during testing. | ||
CLEANFILES = *.nc *.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
!> This is a test program for the Fortran API use of the netCDF | ||
!! integration layer. | ||
|
||
program ftst_pio | ||
use pio | ||
implicit none | ||
include 'mpif.h' | ||
include 'netcdf.inc' | ||
|
||
integer :: myRank, ntasks | ||
type(iosystem_desc_t) :: ioSystem | ||
integer :: niotasks = 1, numAggregator = 0, stride = 1, base = 0 | ||
integer :: ncid | ||
character*(*) FILE_NAME | ||
parameter (FILE_NAME='ftst_pio.nc') | ||
integer :: ierr | ||
|
||
call MPI_Init(ierr) | ||
call MPI_Comm_rank(MPI_COMM_WORLD, myRank, ierr) | ||
call MPI_Comm_size(MPI_COMM_WORLD, ntasks, ierr) | ||
|
||
ierr = pio_set_log_level(2) | ||
ierr = nf_set_log_level(2) | ||
call nf_init_intracom(myRank, MPI_COMM_WORLD, niotasks, numAggregator, & | ||
stride, PIO_rearr_subset, ioSystem, base) | ||
|
||
ierr = nf_create(FILE_NAME, 64, ncid) | ||
ierr = nf_close(ncid) | ||
|
||
call PIO_finalize(ioSystem, ierr) | ||
call MPI_Finalize(ierr) | ||
if (myRank .eq. 0) then | ||
print *, '*** SUCCESS running ftst_pio!' | ||
endif | ||
end program ftst_pio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/sh | ||
# This is a test script for PIO. | ||
# Ed Hartnett | ||
|
||
# Stop execution of script if error is returned. | ||
set -e | ||
|
||
# Stop loop if ctrl-c is pressed. | ||
trap exit INT TERM | ||
|
||
printf 'running Fortran tests for PIO netCDF integration...\n' | ||
|
||
PIO_TESTS='ftst_pio' | ||
|
||
success1=true | ||
for TEST in $PIO_TESTS | ||
do | ||
success1=false | ||
echo "running ${TEST}" | ||
mpiexec -n 4 ./${TEST} && success1=true | ||
if test $success1 = false; then | ||
break | ||
fi | ||
done | ||
|
||
# Did we succeed? | ||
if test x$success1 = xtrue; then | ||
exit 0 | ||
fi | ||
exit 1 |