Page 1 of 1

NETCDF files produced by anaddb

Posted: Tue Aug 08, 2017 3:31 pm
by NPike
Hello all,

I am currently using version 8.5.1 of ANADDB and want to try to use the NetCDF files to visualize my data with ABIPY. However, opening the NetCDF file in ABIPY results in an error message. When I was looking into this, I discovered that my NetCDF files produced by ANADDB are structured, but the information in almost every array (?) within the NetCDF file is a very large negative number.

For instance, I have a NetCDF file that I tried to open with the following python code snippet (note that NetCDF files can not be attached (I assume because they are too big?). I can email it to anyone who wants it)

Code: Select all

from netCDF4 import Dataset

nc_file = 'mos2_PHBST.nc'
fh = Dataset(nc_file,mode='r')
fh.variables['atom_species'][:]


The result of this code is...

Code: Select all

array([-2147483647, -2147483647, -2147483647, ..., -2147483647,
       -2147483647, -2147483647], dtype=int32)

Is there something compiled wrong with ANADDB that causes the netcdf file to be filled with negative numbers? Or, is it something within ANADDB itself?

Re: NETCDF files produced by anaddb

Posted: Wed Aug 09, 2017 10:37 am
by NPike
Hello again,

The problem I posted previously turns out to be a little larger than I thought...

It turns out that during the construction of the NetCDF files is incorrect as some data is simply missing, and
consequently being read as a large negative number by ABIPY.

During an anaddb calculation, several NetCDF files are produced depending on the type of calculation one
is running. It appears that by default a file is produced called "anaddb.nc"
in 98_main/anaddb.F90 which creates a NetCDF file with some general data from the DDB calculations.

A second NetCDF file is produced which ends in "_PHBST.nc" which contains the band structure information.
(This is the file needed by ABIPY to produces the band structure). This file is produced in 77_ddb/m_phonons.F90
in two places(?). One of which is in the subroutine called ifc_mkphbs. In any case, when the NetCDF file is written it
appears that several pieces of information are missing from the files. What I have discovered thus far is...

In the "_PHBST.nc" file the following items are incomplete and filled with underscores:
atom_species
reduced_sym_matricies
space_group
symafm

In the "anaddb.nc" file, the same items are missing. They might also be missing in the third NetCDF file produced by anaddb.

When I was looking at the NetCDF files produced by during a ground state calculation the files appeared complete :D

For now, I can fix my files by simply modifying the NetCDF file using the information from the "_GSR.nc" file. Also,
why are there three NetCDF files produced by anaddb?

~Best

Re: NETCDF files produced by anaddb

Posted: Wed Aug 16, 2017 11:53 am
by mverstra
PS: we have tried looking through the source code for inconsistencies.

The calls to crystal_ncwrite looks ok, but some of the integer arrays are being miswritten from within anaddb (they are fine written out in the fortran on the fly) to netcdf. The type looks ok (int32 checked with the fortran kind). And there are 1 or 2 additional integer arrays which are printed correctly (atomic_numbers valence_charges...) but they are short. space_group is a strange type of its own, but seems to suffer the same fate.

The same happens for all 3 .nc files written from anaddb.F90. Dimensions and variable defs are ok, but the put of the int arrays fails.

Matthieu and Nick