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.
Hi Soumik, Sorry to have taken so long to respond to your question. > I am a new netCDF user.Can anybody please tell me how I can read multiple > .nc files with a single Fortran code. Suppose I have temp_01.nc,temp_02.nc > etc. and I want to read them together in a single Fortran code. The simplest answer is that you can open each file separately, by calling the nf90_open function once for each file. This will give you back a different netCDF ID for each file, and then you can use those netCDF ID's in subsequent calls to read the data from all the open files, something like: integer, parameter :: NFILES = 3 ! Array of netCDF IDs integer :: ncid(NFILES) ! Open the files nf90_open("temp_01.nc", nf90_nowrite, ncid(1)) nf90_open("temp_02.nc", nf90_nowrite, ncid(2)) nf90_open("temp_03.nc", nf90_nowrite, ncid(3)) ! Read from file i using ncid(i) ... nf90_inq_varid(ncid(i), VAR_NAME, ...) If you actually want all the data to look like it comes from one file, there are two approaches: 1. Use a utility program, such as the ncrcat or ncecat utlities from the NCO (netCDF operators) package to merge the separate files into one file and then read from that. See http://nco.sourceforge.net/ 2. Put the files on a TDS server and create an NcML file that aggregates the separate files to make them look like a single file, accessed by having your client program access data through the NcML wrapper on the server. See http://www.unidata.ucar.edu/software/netcdf/ncml/ > Also I need to know how can I deal with scale factor and add offset values > without defining them manually ? Currently I am manually defining scale > factor and offset.So it is taking a long time to do it manually. If you are writing data, you can use another NCO program, ncpdq or ncap, to automatically calculate the scale factor and add offset values and supply the appropriate attributes: http://nco.sourceforge.net/nco.html#SEC100 --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: YGV-657220 Department: Support netCDF Priority: High Status: Closed