This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Susan, > Thank you for your help ... I added the -lcurl plus -lnetcdf to my > compilation line and jason2read.f compiled. > However, the compiled program cannot read the data file. I have attached > the trial run, the data (JA file) and the program. Do you see any > problems? It has run for other folks using fortran. I compiled your program (after changing the leading 'c' comment characters to '!' for my f95 compiler) and it seemed to run fine, producing the following output: $ ./jason2read JA2_GPR_2PTP057_012_20100118_181556_20100118_191209 arg 1 JA2_GPR_2PTP057_012_20100118_181556_20100118_191209 arg 2 arg JA2_GPR_2PTP057_012_20100118_181556_20100118_191209 Opened netcdf jason-2 data file JA2_GPR_2PTP057_012_20100118_181556_20100118_191209 arg where I've deleted the trailing blanks in output lines. It would be helpful if you printed out the netCDF error corresponding to the error return code from the nf_open call, using something like: print *, nf_strerror(istat) after where you write that an error was returned. It will provide more details, such as "No such file" (meaning it's probably in a different directory than where you are running) or "Permission denied" (meaning you don't have read permission on the file). --Russ > Unidata netCDF Support wrote: > > Hi Susan, > > > > > >> I am having great difficulty trying to compile a relatively simple > >> fortran program. > >> > > > > You need to add at least "-lcurl" to the end, something like: > > > > gfortran -I/usr/local/lib64/include jason2read.f > > /usr/local/lib64/lib/libnetcdf.a -o jason2read -lcurl > > > > because apparently static libraries are installed rather than shared > > libraries, so you need to explicitly reference external libraries > > used by netCDF. > > > > If that still doesn't work, determine all the libraries needed for > > compiling and building a Fortran application by running: > > > > nc-config --flibs > > > > where "nc-config" is a netCDF utility installed in the same directory > > as ncdump and ncgen. To see all the flags supported by nc-config, > > run > > > > nc-config --all > > > > --Russ > > > > Russ Rew UCAR Unidata Program > > address@hidden http://www.unidata.ucar.edu > > > > > > > > Ticket Details > > =================== > > Ticket ID: HAG-816423 > > Department: Support netCDF > > Priority: Normal > > Status: Closed > > > > > > -- > Susan Henderson Delay > Senior Research Analyst > Boston College > Institute for Scientific Research > 140 Commonwealth Avenue > Chestnut Hill, MA 02467 > > Tel: (617)552-8549 > Fax: (617)552-2818 > e-mail: address@hidden > > > > program jason2read > c read jason-2 netcdf files, outputs TEC in TEC units > C#include <netcdf.inc> > include "netcdf.inc" > > character fname*256, ofile*128, timestr*32 > real(8), allocatable, dimension(:) :: time, lat, lon, alt, tec > dimension ndate(6) > data ofile / 'jason2out' / > > lout= 0 > mtime= 0 > j= 0 > 4 j= j+1 > call getarg( j, fname ) > write(6,*) 'arg ', j, ' ', fname > if( fname.ne.' ' ) goto 4 > j= 0 > 5 j= j+1 > call getarg( j, fname ) > write(6,1) 'arg ', fname > if( fname.eq.' ' ) call exit(0) > if( fname.eq.'-o' ) then > j= j+1 > call getarg( j, ofile ) > write(6,1) 'arg ', ofile > goto 5 > endif > > istat = nf_open(fname,NF_NOWRITE,ncid) > if (istat /= NF_NOERR) then > write(6,"('Error opening ncfile ',a)") trim(fname) > goto 5 > endif > write(6,"('Opened netcdf jason-2 data file ',a)") trim(fname) > > istat= nf_get_att_text(ncid, NF_GLOBAL, 'first_meas_time',timestr) > if( istat/=NF_NOERR ) then > write(6,"('Error reading first_meas_time')") > goto 5 > endif > read(timestr,2) ndate(1), ndate(2), ndate(3), ihr, imn, sec > 2 format( i4,1x,i2,1x,i2,1x,i2,1x,i2,1x,f9.5 ) > mjd= mjulday( ndate ) > ut0= sec + 60.*( imn + 60.*ihr ) > > ! Get time dimension: > istat = nf_inq_dimid(ncid,'time',id_ndata) > istat = nf_inq_dimlen(ncid,id_ndata,ntime) > if( mtime.eq.0 ) then > mtime= 2*max( ntime, 4000 ) > ! Allocate data arrays > allocate(time(mtime),stat=istat) > allocate(lat(mtime),stat=istat) > allocate(lon(mtime),stat=istat) > allocate(alt(mtime),stat=istat) > allocate(tec(mtime),stat=istat) > endif > > ! Read vars: > istat = nf_inq_varid(ncid,'time',ivid) > istat = nf_get_var_double(ncid,ivid,time) > > istat = nf_inq_varid(ncid,'lat',ivid) > istat = nf_get_var_double(ncid,ivid,lat ) > > istat = nf_inq_varid(ncid,'lon',ivid) > istat = nf_get_var_double(ncid,ivid,lon ) > > istat = nf_inq_varid(ncid,'alt',ivid) > istat = nf_get_var_double(ncid,ivid,alt ) > > istat = nf_inq_varid(ncid,'iono_corr_alt_ku',ivid) > istat = nf_get_var_double(ncid,ivid,tec ) > > istat= nf_close(ncid) > > if( lout.eq.0 ) then > lout= 1 > open(25, file= ofile ) > write(25,1) 'mjd uts lat lon alt tec' > 1 format( a,a,a ) > endif > time0= time(1) > do 10 i= 1,ntime > uts= time(i)-time0 + ut0 > jd= mjd > if( uts.gt.86400. ) then > jd= jd+1 > uts= uts-86400. > endif > lat(i)= 1.e-6*lat(i) > lon(i)= 1.e-6*lon(i) > alt(i)= 1300. + 1.e-7*alt(i) > tec(i)= 1.e-4*tec(i) > tec(i)= -tec(i)*(13.575*1.e9)**2/40.3/1.e16 > write(25,3) jd, uts, lat(i), lon(i), alt(i), tec(i) > 3 format( i6, 5(1x, f10.3) ) > 10 continue > goto 5 > > end > > function mjulday( ndate ) > c modified Julian day from date array > dimension ndate(5) > > iyr= ndate(1) > imo= ndate(2) > di= (1461*(iyr+(imo-8)/6))/4 - 712179 + (mod(imo+9,12)*153+2)/5 > di= di + ndate(3) > mjulday= di+33282. > return > end > > > > [sdelay@dbrskqc1-1 JASON2]$ ./jason2read > JA2_GPR_2PTP057_012_20100118_181556_20100118_191209 > arg 1 JA2_GPR_2PTP057_012_20100118_181556_20100118_191209 > arg 2 > arg JA2_GPR_2PTP057_012_20100118_181556_20100118_191209 > Error opening ncfile JA2_GPR_2PTP057_012_20100118_181556_20100118_191209 > arg > > Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: HAG-816423 Department: Support netCDF Priority: Normal Status: Closed