alex-robinson / ncio

Simple Fortran interface to NetCDF reading and writing.
23 stars 9 forks source link

Problem with nc_put_att in debug mode #11

Closed einola closed 3 years ago

einola commented 3 years ago

When using the debugging option I have a crash in nc_put_att because of an un-allocated variable (see below). This only happens when I've exported the environment variable debug = 1.

This doesn't seem to be a big problem, but it makes using ncio in debug mode a pain or even impossible.

I'm on a mac (10.15.7) using gfortran from macports (gcc version 11.2.0 (MacPorts gcc11 11.2.0_1)).

Monaco:ncio einola$ export debug=1
Monaco:ncio einola$ make test
gfortran -w -g -p -ggdb -ffpe-trap=invalid,zero,overflow,underflow -fbacktrace -fcheck=all -I.obj -J.obj -I/opt/local/include -c -o .obj/ncio.o ncio.f90
gfortran -w -g -p -ggdb -ffpe-trap=invalid,zero,overflow,underflow -fbacktrace -fcheck=all -I.obj -J.obj -I/opt/local/include -c -o .obj/ncio_transpose.o ncio_transpose.f90
gfortran -w -g -p -ggdb -ffpe-trap=invalid,zero,overflow,underflow -fbacktrace -fcheck=all -I.obj -J.obj -I/opt/local/include -o test_ncio.x .obj/ncio.o .obj/ncio_transpose.o test_ncio.f90 -L/opt/local/lib -lnetcdff -lnetcdf

    test_ncio.x is ready.

Monaco:ncio einola$ ./test_ncio.x

 ====== WRITING ======

ncio:: nc_create   :: out_ncio.nc
ncio:: nc_write_map:: out_ncio.nc : polar_stereographic
At line 822 of file ncio.f90
Fortran runtime error: Allocatable argument 'v' is not allocated

Error termination. Backtrace:
#0  0x102fe76e0 in ???
#1  0x102fe7f78 in ???
#2  0x102fe84eb in ???
#3  0x102e1e46b in nc_put_att
        at /Users/einola/tmp/ncio/ncio.f90:822
#4  0x102e154cf in nc_write_dim_internal
        at /Users/einola/tmp/ncio/ncio.f90:1833
#5  0x102e17b48 in __ncio_MOD_nc_write_dim_int_pt
        at /Users/einola/tmp/ncio/ncio.f90:1605
#6  0x102e3401e in test
        at /Users/einola/tmp/ncio/test_ncio.f90:74
#7  0x102e3b447 in main
        at /Users/einola/tmp/ncio/test_ncio.f90:5

PS: Thanks for the code - it's a lifesaver!