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.
Hi all, I am experiencing a problem in using NetCdf Fortran90 interface with OpenMP. Imagine I read as many different files as the number of threads: !$OMP PARALLEL DEFAULT(SHARED),PRIVATE(JF,ISTARTX,ISTARTY,IENDX,IENDY,ILX,ILY,& !$OMP & STAT,IDVAR,NCD) !$OMP DO SCHEDULE(STATIC,1) DO JF=1,NICEFILES ! [...] !... Define indexes (ISTARTX,ISTARTY,IENDX,IENDY,ILX,IL) for each thread !... STAT = NF90_OPEN(CICEFILES(JF), NF90_NOWRITE, NCD) IF (STAT /= NF90_NOERR) CALL HANDLE_ERR(STAT) STAT = NF90_INQ_VARID (NCD, CVARNAME, IDVAR) IF (STAT /= NF90_NOERR) CALL HANDLE_ERR(STAT) STAT = NF90_GET_VAR (NCD,IDVAR,F3T(ISTARTX:IENDX,ISTARTY:IENDY),& & START=(/1,1,1/),COUNT=(/ILX,ILY,1/)) IF (STAT /= NF90_NOERR) CALL HANDLE_ERR(STAT) STAT = NF90_CLOSE(NCD) IF (STAT /= NF90_NOERR) CALL HANDLE_ERR(STAT) ENDDO !$OMP END DO !$OMP END PARALLEL Note that each thread reads a different file, no overlapping of data occurs, but sometimes, randomly (one every 50 times), this code crashes because of "ERROR: Not a netCDF id", which, I guess, depends on the fact that being NetCdf "thread-unsafe" as I found on docs, NetCdf ids might overlap between different threads. Do you figure out any solution to safely use OpenMP for reading different NetCdf files? If this is crucial, note that this code runs on a NEC SX-9 vectorial machine (sxf90) with netcdf-3.6.1p1 (build: dwdW-multi-64). Or would you suggest to recompile NetCdf in a different thread-safe way (which i don't know) Thanks a lot in advance Regards Andrea ==================== Andrea Storto, Ph.D. Dept. of Numerical Applications and Scenarios (ANS) Euro-Mediterranean Centre for Climate Change (CMCC) - www.cmcc.it viale Aldo Moro, 44, 7th Floor - 40127 BOLOGNA - Italy Phone: +39 (0)51 3782605 (int. 205) Mobile: +39 339 8176646 Fax: +39 (0)51 3782655 Email: andrea.storto@xxxxxxx ====================
netcdfgroup
archives: