[petsc-users] how to read netcdf into petsc

Matthew Knepley knepley at gmail.com
Sat Feb 28 08:38:54 CST 2015


On Fri, Feb 27, 2015 at 11:34 PM, Ed Bueler <elbueler at alaska.edu> wrote:

> Dear Petsc --
>
> There is a "--download-netcdf" configure option that seems to work for
> me.  The petscviewer.h (in petsc-maint) has a PetscViewerNetcdfOpen()
> declaration, but that seems to not be linkable, perhaps because it has no
> implementation of it:
>
> $ make mahaffy
> /home/ed/petsc-maint/linux-c-opt/bin/mpicc -o mahaffy.o -c -fPIC -Wall
> -Wwrite-strings -Wno-strict-aliasing -Wno-unknown-pragmas -O
> -I/home/ed/petsc-maint/include -I/home/ed/petsc-maint/linux-c-opt/include
>  `pwd`/mahaffy.c
> /home/ed/petsc-maint/linux-c-opt/bin/mpicc -fPIC -Wall -Wwrite-strings
> -Wno-strict-aliasing -Wno-unknown-pragmas -O  -o mahaffy mahaffy.o
>  -Wl,-rpath,/home/ed/petsc-maint/linux-c-opt/lib
> -L/home/ed/petsc-maint/linux-c-opt/lib  -lpetsc
> -Wl,-rpath,/home/ed/petsc-maint/linux-c-opt/lib -lflapack -lfblas -lX11
> -lpthread -lnetcdf -lm -Wl,-rpath,/usr/lib/gcc/x86_64-linux-gnu/4.8
> -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -Wl,-rpath,/usr/lib/x86_64-linux-gnu
> -L/usr/lib/x86_64-linux-gnu -Wl,-rpath,/lib/x86_64-linux-gnu
> -L/lib/x86_64-linux-gnu -lmpichf90 -lgfortran -lm -lgfortran -lm -lquadmath
> -lm -lmpichcxx -lstdc++ -Wl,-rpath,/home/ed/petsc-maint/linux-c-opt/lib
> -L/home/ed/petsc-maint/linux-c-opt/lib
> -Wl,-rpath,/usr/lib/gcc/x86_64-linux-gnu/4.8
> -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -Wl,-rpath,/usr/lib/x86_64-linux-gnu
> -L/usr/lib/x86_64-linux-gnu -Wl,-rpath,/lib/x86_64-linux-gnu
> -L/lib/x86_64-linux-gnu -Wl,-rpath,/usr/lib/x86_64-linux-gnu
> -L/usr/lib/x86_64-linux-gnu -ldl
> -Wl,-rpath,/home/ed/petsc-maint/linux-c-opt/lib -lmpich -lopa -lmpl -lrt
> -lpthread -lgcc_s -ldl
> mahaffy.o: In function `ReadThicknessFromNetCDF':
> mahaffy.c:(.text+0x2cbb): undefined reference to `PetscViewerNetcdfOpen'
> collect2: error: ld returned 1 exit status
> make: [mahaffy] Error 1 (ignored)
> /bin/rm -f mahaffy.o
>
> In particular, src/sys/classes/viewer/impls/ does not have a netcdf/ case.
>
> So what is the recommended way to read a netcdf file into a petsc vec?
> Should I go via python and netcdf4-python or something, using
> bin/pythonscripts/PetscBinaryIO.py to write a petsc binary, and then read
> that?
>

I think a converter to binary in Python sounds great. However, do you want
the data in the absence of a mesh?


> Dump to ascii and read that?--yes, this is a taunt.
>

I think we at one time had a NetCDF viewer which we abandoned because HDF5
turned out to be better (a damning judgment indeed). The --download-netcdf
is there to support ExodusII, which we can load.

   Thanks,

     Matt


> Thanks for help!
>
> Ed
>
>
> --
> Ed Bueler
> Dept of Math and Stat and Geophysical Institute
> University of Alaska Fairbanks
> Fairbanks, AK 99775-6660
> 301C Chapman and 410D Elvey
> 907 474-7693 and 907 474-7199  (fax 907 474-5394)
>



-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150228/5f0fdd65/attachment.html>


More information about the petsc-users mailing list