NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Sudheer,I think you already found the correct solution, download netcdf_check.f90 from my FTP directory and add that to your compile line.
There are probably two different copies of the user subroutine "check", your version and my version. They probably do exactly the same thing. If you want to use your version only, simply delete one line "use netcdf__check" in the file getnc_dims.f90, and do not include netcdf_check.f90 on the compile line. This may be the simplest thing for your purposes. It is also okay to use them both in the same compile, because my version is inside a module.
Be careful about one other thing. Many fortran 90+ compilers depend on the order of compilation of modules and the creation of *.mod files. If a subroutine says "use netcdf__check", then the module netcdf__check must have previously been compiled. This depends on the order of source files on the command line.
So in your case, list the source files in order of increasing dependency, main program last, for best results:
ifort -extend-source -O3 -o ncep2ascii.x -I/usr/local/include \ netcdf_check.f90 getnc_dims.f90 ncep2ascii.f90 \ -L/usr/local/lib/ -lnetcdfSee if that works for you. There are other methods to manage the chain of dependencies, but this a simple method that I use.
--Dave On 6/13/2010 11:41 PM, Sudheer Joseph wrote:
Thank you Dave& Pierce, Sorry about that confusion, Yes it is possible for allocating an array with 2 dimenstion as parameters and last dimesion as variable. What I as facing was some error with the library. I have a question regarding your modules "getnc_dims.f90 netcdf_check.f90". After seeing that they are very useful modules I have added them to my include path ie under directory along with netcdf.mod as below sjo@sjo-desktop:~/hdd4/NRL_file_gen$ ll /usr/local/include/*.mod -rw-r--r-- 1 sjo sjo 4272 2010-06-14 10:40 /usr/local/include/getnc__dims.mod -rw-r--r-- 1 sjo sjo 562 2010-06-14 10:40 /usr/local/include/netcdf__check.mod -rw-r--r-- 1 root root 277339 2010-06-03 18:57 /usr/local/include/netcdf.mod -rw-r--r-- 1 root root 1510 2010-06-03 18:57 /usr/local/include/typesizes.mod but when I complie by ifort -extend-source -O3 -o ncep2ascii.x -I/usr/local/include ncep2ascii.f90 getnc_dims.f90 -L/usr/local/lib/ -lnetcdf it gives error as below sjo@sjo-desktop:~/hdd4/NRL_file_gen$ ifort -extend-source -O3 -I/usr/local/include ncep2ascii.f90 getnc_dims.f90 -L/usr/local/lib/ -lnetcdf/tmp/ifortEEeYgg.o: In function `MAIN__': ncep2ascii.f90:(.text+0x30c): undefined reference to `netcdf__check_mp_check_' ncep2ascii.f90:(.text+0x55e): undefined reference to `netcdf__check_mp_check_' ncep2ascii.f90:(.text+0x595): undefined reference to `netcdf__check_mp_check_' ncep2ascii.f90:(.text+0x5cc): undefined reference to `netcdf__check_mp_check_' ncep2ascii.f90:(.text+0x667): undefined reference to `netcdf__check_mp_check_' /tmp/ifortEEeYgg.o:ncep2ascii.f90:(.text+0x6f8): more undefined references to `netcdf__check_mp_check_' follow but if i compile by ifort -extend-source -O3 -o ncep2ascii.x -I/usr/local/include ncep2ascii.f90 getnc_dims.f90 netcdf_check.f90 -L/usr/local/lib/ -lnetcdf it works with out problem So are these modules not supposed to be used similar way as netcdf.mod ? which can be used in any code by including its path during compilation? or what change I need to make them to use them like netcdf.mod? I have attached here the code where I am trying to use these modules. please advice. with best regards, Sudheer On Fri, Jun 11, 2010 at 10:06 AM, Sudheer Joseph<sjo@xxxxxxxxxxxxx> wrote:Thank you Dave, The subroutine you mentioned is very useful. But my question was slightly different. suppose if you get the dimension size before reading the 3 dimensional variable. we cannot use that information to read the netcdf 3rd dimension at a stretch. I mean if I use the NTIM= nf_get_dim(time) ( just for illustration sake ) and use this for allocating the dimension for 3D variable it will not accept as it is not defined as a parameter. allocate(pres_in(NLONS, NLATS, NTIM)) count = (/ NLONS, NLATS,NTIM/) start = (/ 1, 1, 1/) One possibility came to my mind yesterday night was to read the data as xy slabs and use a do loop to read the time dimension. It appears there is no way to read the 3D variable at one call if we are not defining the dimension as parameter. with best regards, Sudheer On Fri, Jun 11, 2010 at 3:42 AM, Dave Allured<dave.allured@xxxxxxxx> wrote:Sudheer, If the names of the dimensions are always the same, then use nf90_inq_dimid followed by nf90_inquire_dimension to get the length of each dimension. See the example on this page: http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f90/NF90_005fINQUIRE_005fDIMENSION.html If all the dimensions have coordinate variables, then the following subroutine will get several dimension lengths in one call: http://www.esrl.noaa.gov/psd/people/dave.allured/data/f90/lib/getnc_dims.f90 If the dimension names change between Netcdf files, then the problem is more complicated. We can address that if neither of the above works for you. --Dave A. NOAA/PSD/CIRES On 6/10/2010 7:55 AM, Sudheer Joseph wrote:Dear Users, I have been coding a program to read multiple netcdf files having different time dimensions. I want to know if there is a way to read netcdf varibale with out defining the dimension as parameter. with in fortran 90 program. normally we need to define like below ! timesteps of data. integer, parameter :: NDIMS = 3, NRECS =1 integer, parameter :: NTIM=1464, NLATS = 94, NLONS = 192 allocate(pres_in(NLONS, NLATS, NTIM))count = (/ NLONS, NLATS,NTIM/) start = (/ 1, 1, 1/) ! Read the surface pressure and temperature data from the file, one ! record at a time. call check( nf90_get_var(ncid, pres_varid, pres_in, start = start,count = count) ) In my case ntim may be different for different files. I wanted to use the reading part as a subroutine where ntim is provided as a variable and passed to subroutine but if I declare ntim as varible then netcdf gives an error. If any one have a solution please help. I am not looking for solutions like replacing the parameter statement using shell script and re compiling it etc._______________________________________________ netcdfgroup mailing list netcdfgroup@xxxxxxxxxxxxxxxx For list information or to unsubscribe, visit: http://www.unidata.ucar.edu/mailing_lists/
netcdfgroup
archives: