Scheduled Downtime
On Tuesday 24 October 2023 @ 5pm MT the forums will be in read only mode in preparation for the downtime. On Wednesday 25 October 2023 @ 5am MT, this website will be down for maintenance and expected to return online later in the morning.
Normal Operations
The forums are back online with normal operations. If you notice any issues or errors related to the forums, please reach out to help@ucar.edu

How to use PIO in Fortran ?

Mikasa

sky
Member
Hello, I have already installed the PIO in our HPC. And I try to use PIO to read or write nc file. Here I write some very simple code :
program main
use mpi
use pio, only : PIO_read_darray, pio_openfile, PIO_iotype_netcdf
use pio, only : PIO_init, PIO_rearr_subset, iosystem_desc_t, file_desc_t
integer :: ierr,i
integer :: myRank, ntasks, namelen, niotasks
integer :: stride=1
integer :: numAggregator=0
integer :: optBase=1
integer :: iotype = PIO_iotype_netcdf
type(iosystem_desc_t) :: pioIoSystem

call MPI_Init(ierr)
call MPI_Comm_rank(MPI_COMM_WORLD, myRank, ierr)
call MPI_Comm_size(MPI_COMM_WORLD, ntasks , ierr)
niotasks = ntasks

call PIO_init(myRank, MPI_COMM_WORLD, niotasks, numAggregator, stride,PIO_rearr_subset, pioIoSystem,base=optBase)

end program main
But errors occur when I try to compile it with
mpiifort program_main.f90 -I/paht/to/pio-2.3.0/include
the error is 'undefined reference to `piolib_mod_mp_init_intracom_'
How can I compile this successfully?
Thank you very much for answering my questions!
 

jedwards

CSEG and Liaisons
Staff member
You need to link the pio libraries along with the netcdf libraries, something like this:
-L/path/to/pio-2.3.0/lib -lpiof -lpioc -L/path/to/netcdf -lnetcdf
 

Mikasa

sky
Member
You need to link the pio libraries along with the netcdf libraries, something like this:
-L/path/to/pio-2.3.0/lib -lpiof -lpioc -L/path/to/netcdf -lnetcdf
Hello, I have noticed that there are both PIO1 and PIO2 in the CESM2.1.3 src. I wonder which version is used by the cpl, pop and cam ? Thank you very much for your answer !
 
Top