diff --git a/examples/F90/clone.f90 b/examples/F90/clone.f90 index f661b744d..88cc1dc2d 100644 --- a/examples/F90/clone.f90 +++ b/examples/F90/clone.f90 @@ -29,7 +29,7 @@ program clone ! a new grib message is loaded from file ! igrib is the grib id to be used in subsequent calls - call codes_new_from_file(infile,igrib_in) + call codes_grib_new_from_file(infile,igrib_in) call codes_get(igrib_in,"Ni", nx) diff --git a/examples/F90/copy_message.f90 b/examples/F90/copy_message.f90 index 911209414..1cef66f41 100644 --- a/examples/F90/copy_message.f90 +++ b/examples/F90/copy_message.f90 @@ -28,7 +28,7 @@ program copy ! a new grib message is loaded from file ! igrib is the grib id to be used in subsequent calls - call codes_new_from_file(infile,igrib_in) + call codes_grib_new_from_file(infile,igrib_in) call codes_get_message_size(igrib_in, byte_size) allocate(message(byte_size), stat=err) diff --git a/examples/F90/copy_namespace.f90 b/examples/F90/copy_namespace.f90 index 29f457e1c..2be6d576d 100644 --- a/examples/F90/copy_namespace.f90 +++ b/examples/F90/copy_namespace.f90 @@ -21,8 +21,8 @@ program copy_namespace call codes_open_file(file2,'../../data/regular_latlon_surface.grib1','r') call codes_open_file(file3,'out.grib','w') - call codes_new_from_file(file1,igrib1) - call codes_new_from_file(file2,igrib2) + call codes_grib_new_from_file(file1,igrib1) + call codes_grib_new_from_file(file2,igrib2) call codes_clone(igrib2,igrib3) diff --git a/examples/F90/count_messages.f90 b/examples/F90/count_messages.f90 index 0cc3b0126..34eea3e84 100644 --- a/examples/F90/count_messages.f90 +++ b/examples/F90/count_messages.f90 @@ -38,7 +38,7 @@ program get ! Load the messages from the file. DO i=1,n - call codes_new_from_file(ifile,igrib(i), iret) + call codes_grib_new_from_file(ifile,igrib(i), iret) END DO ! we can close the file diff --git a/examples/F90/get.f90 b/examples/F90/get.f90 index 8cc4d9569..6080e9c51 100644 --- a/examples/F90/get.f90 +++ b/examples/F90/get.f90 @@ -35,7 +35,7 @@ program get ! a new grib message is loaded from file ! igrib is the grib id to be used in subsequent calls - call codes_new_from_file(ifile,igrib, iret) + call codes_grib_new_from_file(ifile,igrib, iret) LOOP: DO WHILE (iret /= CODES_END_OF_FILE) @@ -114,7 +114,7 @@ program get call codes_release(igrib) - call codes_new_from_file(ifile,igrib, iret) + call codes_grib_new_from_file(ifile,igrib, iret) end do LOOP diff --git a/examples/F90/get_data.f90 b/examples/F90/get_data.f90 index 3c7f916b3..9eee94993 100644 --- a/examples/F90/get_data.f90 +++ b/examples/F90/get_data.f90 @@ -32,7 +32,7 @@ implicit none ! Loop on all the messages in a file. - call codes_new_from_file(ifile,igrib,iret) + call codes_grib_new_from_file(ifile,igrib,iret) do while (iret/=CODES_END_OF_FILE) count1=count1+1 @@ -57,7 +57,7 @@ implicit none deallocate(values) call codes_release(igrib) - call codes_new_from_file(ifile,igrib, iret) + call codes_grib_new_from_file(ifile,igrib, iret) end do diff --git a/examples/F90/get_fortran.f90 b/examples/F90/get_fortran.f90 index 4d936ba6a..8930df92d 100644 --- a/examples/F90/get_fortran.f90 +++ b/examples/F90/get_fortran.f90 @@ -31,7 +31,7 @@ implicit none ! a new grib message is loaded from file ! igrib is the grib id to be used in subsequent calls - call codes_new_from_file(ifile,igrib) + call codes_grib_new_from_file(ifile,igrib) ! get as a integer call codes_get(igrib,'numberOfPointsAlongAParallel', & diff --git a/examples/F90/get_pl.f90 b/examples/F90/get_pl.f90 index 706410110..0e7597271 100644 --- a/examples/F90/get_pl.f90 +++ b/examples/F90/get_pl.f90 @@ -25,7 +25,7 @@ program get_pl ! a new grib message is loaded from file ! igrib is the grib id to be used in subsequent calls - call codes_new_from_file(infile,igrib) + call codes_grib_new_from_file(infile,igrib) ! set PVPresent as an integer call codes_get(igrib,'PLPresent',PLPresent) diff --git a/examples/F90/get_pv.f90 b/examples/F90/get_pv.f90 index b8f28f60b..0ef0c1fa6 100644 --- a/examples/F90/get_pv.f90 +++ b/examples/F90/get_pv.f90 @@ -26,7 +26,7 @@ program get_pv ! a new grib message is loaded from file ! igrib is the grib id to be used in subsequent calls - call codes_new_from_file(infile,igrib) + call codes_grib_new_from_file(infile,igrib) ! set PVPresent as an integer call codes_get(igrib,'PVPresent',PVPresent) diff --git a/examples/F90/get_set_uuid.f90 b/examples/F90/get_set_uuid.f90 index 066cc4d5a..4e169b637 100644 --- a/examples/F90/get_set_uuid.f90 +++ b/examples/F90/get_set_uuid.f90 @@ -28,7 +28,7 @@ program get_set_uuid ! Load first grib message from file ! igrib is the grib id to be used in subsequent calls - call codes_new_from_file (infile, igrib, iret) + call codes_grib_new_from_file (infile, igrib, iret) uuid_string_expected = '08b1e836bc6911e1951fb51b5624ad8d' count1 = 0 @@ -70,7 +70,7 @@ program get_set_uuid call codes_release (igrib) call codes_release (ogrib) - call codes_new_from_file (infile, igrib, iret) + call codes_grib_new_from_file (infile, igrib, iret) end do call codes_close_file (infile) diff --git a/examples/F90/iterator_fortran.f90 b/examples/F90/iterator_fortran.f90 index ca4122c27..0aeebab0e 100644 --- a/examples/F90/iterator_fortran.f90 +++ b/examples/F90/iterator_fortran.f90 @@ -27,7 +27,7 @@ implicit none ! Loop on all the messages in a file. - call codes_new_from_file(ifile,igrib,iret) + call codes_grib_new_from_file(ifile,igrib,iret) LOOP: DO WHILE (iret/=CODES_END_OF_FILE) ! get as a real8 @@ -61,7 +61,7 @@ implicit none call grib_iterator_delete(iter) call codes_release(igrib) - call codes_new_from_file(ifile,igrib, iret) + call codes_grib_new_from_file(ifile,igrib, iret) end do LOOP diff --git a/examples/F90/keys_iterator.f90 b/examples/F90/keys_iterator.f90 index 4efb44772..3649a0b44 100644 --- a/examples/F90/keys_iterator.f90 +++ b/examples/F90/keys_iterator.f90 @@ -28,7 +28,7 @@ program keys_iterator ! Loop on all the messages in a file. - call codes_new_from_file(ifile,igrib, iret) + call codes_grib_new_from_file(ifile,igrib, iret) do while (iret /= CODES_END_OF_FILE) @@ -54,7 +54,7 @@ program keys_iterator call codes_keys_iterator_delete(kiter) call codes_release(igrib) - call codes_new_from_file(ifile,igrib, iret) + call codes_grib_new_from_file(ifile,igrib, iret) end do diff --git a/examples/F90/keys_iterator_fortran.f90 b/examples/F90/keys_iterator_fortran.f90 index f8dfd3e03..c3cdaf4d4 100644 --- a/examples/F90/keys_iterator_fortran.f90 +++ b/examples/F90/keys_iterator_fortran.f90 @@ -32,7 +32,7 @@ program keys_iterator grib_count=0 ! Loop on all the messages in a file. - call codes_new_from_file(ifile,igrib) + call codes_grib_new_from_file(ifile,igrib) do while (igrib .ne. -1) @@ -60,7 +60,7 @@ program keys_iterator call codes_keys_iterator_delete(kiter) call codes_release(igrib) - call codes_new_from_file(ifile,igrib, iret) + call codes_grib_new_from_file(ifile,igrib, iret) end do call codes_close_file(ifile) diff --git a/examples/F90/multi.f90 b/examples/F90/multi.f90 index 34d0a2b91..ba26dd658 100644 --- a/examples/F90/multi.f90 +++ b/examples/F90/multi.f90 @@ -31,7 +31,7 @@ program multi ! turn off support for multi fields messages */ !call codes_grib_multi_support_off() - call codes_new_from_file(ifile,igrib, iret) + call codes_grib_new_from_file(ifile,igrib, iret) ! Loop on all the messages in a file. write(*,*) 'step' @@ -40,7 +40,7 @@ program multi call codes_get(igrib,'step', step) write(*,'(i3)') step - call codes_new_from_file(ifile,igrib, iret) + call codes_grib_new_from_file(ifile,igrib, iret) end do call codes_close_file(ifile) diff --git a/examples/F90/multi_fortran.f90 b/examples/F90/multi_fortran.f90 index 916fe15c6..0a3918763 100644 --- a/examples/F90/multi_fortran.f90 +++ b/examples/F90/multi_fortran.f90 @@ -31,7 +31,7 @@ program multi ! turn off support for multi fields messages */ !call codes_grib_multi_support_off() - call codes_new_from_file(ifile,igrib) + call codes_grib_new_from_file(ifile,igrib) ! Loop on all the messages in a file. do while (igrib .ne. -1) @@ -60,7 +60,7 @@ program multi endif call codes_release(igrib) - call codes_new_from_file(ifile,igrib, iret) + call codes_grib_new_from_file(ifile,igrib, iret) end do call codes_close_file(ifile) diff --git a/examples/F90/multi_write.f90 b/examples/F90/multi_write.f90 index 422af00ca..844164f4b 100644 --- a/examples/F90/multi_write.f90 +++ b/examples/F90/multi_write.f90 @@ -29,7 +29,7 @@ program multi_write ! a grib message is loaded from file ! in_gribid is the grib id to be used in subsequent calls - call codes_new_from_file(infile,in_gribid) + call codes_grib_new_from_file(infile,in_gribid) startsection=4 do step=0,240,12 diff --git a/examples/F90/nearest.f90 b/examples/F90/nearest.f90 index e88a59ada..bbae6b528 100644 --- a/examples/F90/nearest.f90 +++ b/examples/F90/nearest.f90 @@ -47,7 +47,7 @@ program find ! a new grib message is loaded from file ! igrib is the grib id to be used in subsequent calls - call codes_new_from_file(infile,igrib) + call codes_grib_new_from_file(infile,igrib) call codes_grib_find_nearest(igrib, .true., lats, lons, nearest_lats, nearest_lons,lsm_values, distances, indexes) @@ -58,7 +58,7 @@ program find ! will apply it to another GRIB call codes_open_file(infile, & '../../data/reduced_gaussian_pressure_level.grib1','r') - call codes_new_from_file(infile,igrib) + call codes_grib_new_from_file(infile,igrib) call codes_get_element(igrib,"values", indexes, values) call codes_release(igrib) diff --git a/examples/F90/new_from_file.f90 b/examples/F90/new_from_file.f90 index 437942958..79d0d30de 100644 --- a/examples/F90/new_from_file.f90 +++ b/examples/F90/new_from_file.f90 @@ -27,12 +27,12 @@ use eccodes ! Loop on all the messages in a file. - call codes_new_from_file(ifile,igrib, iret) + call codes_grib_new_from_file(ifile,igrib, iret) do while (iret==CODES_SUCCESS) count1=count1+1 print *, "===== Message #",count1 - call codes_new_from_file(ifile,igrib, iret) + call codes_grib_new_from_file(ifile,igrib, iret) end do if (iret /= CODES_END_OF_FILE) then diff --git a/examples/F90/precision.f90 b/examples/F90/precision.f90 index 339145e54..0e24cc694 100644 --- a/examples/F90/precision.f90 +++ b/examples/F90/precision.f90 @@ -32,7 +32,7 @@ program precision ! a new grib message is loaded from file ! igrib is the grib id to be used in subsequent calls - call codes_new_from_file(infile,igrib) + call codes_grib_new_from_file(infile,igrib) ! bitsPerValue before changing the packing parameters call codes_get(igrib,'bitsPerValue',bitsPerValue1) diff --git a/examples/F90/precision_fortran.f90 b/examples/F90/precision_fortran.f90 index e925beda7..02def309f 100644 --- a/examples/F90/precision_fortran.f90 +++ b/examples/F90/precision_fortran.f90 @@ -30,7 +30,7 @@ program precision ! a new grib message is loaded from file ! igrib is the grib id to be used in subsequent calls - call codes_new_from_file(infile,igrib) + call codes_grib_new_from_file(infile,igrib) ! bitsPerValue before changing the packing parameters call codes_get(igrib,'bitsPerValue',bitsPerValue1) diff --git a/examples/F90/print_data.f90 b/examples/F90/print_data.f90 index be2ac236d..097bd8481 100644 --- a/examples/F90/print_data.f90 +++ b/examples/F90/print_data.f90 @@ -30,7 +30,7 @@ call codes_open_file(ifile, & ! a new grib message is loaded from file ! igrib is the grib id to be used in subsequent calls - call codes_new_from_file(ifile,igrib) + call codes_grib_new_from_file(ifile,igrib) ! get the size of the values array call codes_get_size(igrib,'values',numPoints) diff --git a/examples/F90/print_data_fortran.f90 b/examples/F90/print_data_fortran.f90 index 7ab9ec3c0..ddad1fcf2 100644 --- a/examples/F90/print_data_fortran.f90 +++ b/examples/F90/print_data_fortran.f90 @@ -31,7 +31,7 @@ call codes_open_file(ifile, & ! a new grib message is loaded from file ! igrib is the grib id to be used in subsequent calls - call codes_new_from_file(ifile,igrib) + call codes_grib_new_from_file(ifile,igrib) ! get the size of the values array diff --git a/examples/F90/samples.f90 b/examples/F90/samples.f90 index b91247930..c061f219e 100644 --- a/examples/F90/samples.f90 +++ b/examples/F90/samples.f90 @@ -39,7 +39,7 @@ program sample call codes_open_file(outfile, 'out.samples.grib1','w') call codes_open_file(datafile,'../../data/tp_ecmwf.grib','r') - call codes_new_from_file(datafile,igribdata,err) + call codes_grib_new_from_file(datafile,igribdata,err) call codes_get_size(igribdata,'values',size1) allocate(v(size1)) @@ -69,7 +69,7 @@ program sample call codes_write(igribclone,outfile) - call codes_new_from_file(datafile,igribdata,err) + call codes_grib_new_from_file(datafile,igribdata,err) if (err==0) then call codes_get(igribdata,'values',v2) diff --git a/examples/F90/set.f90 b/examples/F90/set.f90 index 38549c764..331b8d4ef 100644 --- a/examples/F90/set.f90 +++ b/examples/F90/set.f90 @@ -30,7 +30,7 @@ program set ! a new grib message is loaded from file ! igrib is the grib id to be used in subsequent calls - call codes_new_from_file(infile,igrib) + call codes_grib_new_from_file(infile,igrib) call codes_set(igrib,'dataDate',date1) ! set centre as a integer */ diff --git a/examples/F90/set_bitmap.f90 b/examples/F90/set_bitmap.f90 index 486a633f5..680522375 100644 --- a/examples/F90/set_bitmap.f90 +++ b/examples/F90/set_bitmap.f90 @@ -36,7 +36,7 @@ program set_bitmap ! a new grib message is loaded from file ! igrib is the grib id to be used in subsequent calls - call codes_new_from_file(infile,igrib) + call codes_grib_new_from_file(infile,igrib) ! The missingValue is not coded in the message. ! It is a value we define as a placeholder for a missing value diff --git a/examples/F90/set_fortran.f90 b/examples/F90/set_fortran.f90 index e025a74e5..f17ff992a 100644 --- a/examples/F90/set_fortran.f90 +++ b/examples/F90/set_fortran.f90 @@ -34,7 +34,7 @@ program set ! a new grib message is loaded from file ! igrib is the grib id to be used in subsequent calls - call codes_new_from_file(infile,igrib) + call codes_grib_new_from_file(infile,igrib) ! set centre as a long */ centre=80 diff --git a/examples/F90/set_gvc.f90 b/examples/F90/set_gvc.f90 index ca832cefb..f8a3dbd62 100644 --- a/examples/F90/set_gvc.f90 +++ b/examples/F90/set_gvc.f90 @@ -23,7 +23,7 @@ program set call codes_open_file(outfile, 'out_gvc.grib2','w') - call codes_new_from_file(infile,igrib) + call codes_grib_new_from_file(infile,igrib) ! Individual ensemble forecast call codes_set(igrib,'productDefinitionTemplateNumber', 11) diff --git a/examples/F90/set_missing.f90 b/examples/F90/set_missing.f90 index 7a713b3d6..91b564a1f 100644 --- a/examples/F90/set_missing.f90 +++ b/examples/F90/set_missing.f90 @@ -29,7 +29,7 @@ program set ! a new grib message is loaded from file ! igrib is the grib id to be used in subsequent calls - call codes_new_from_file(infile,igrib) + call codes_grib_new_from_file(infile,igrib) call codes_set(igrib,'typeOfFirstFixedSurface','sfc') call codes_set_missing(igrib,'scaleFactorOfFirstFixedSurface') diff --git a/examples/F90/set_missing_fortran.f90 b/examples/F90/set_missing_fortran.f90 index 649fe2a4c..e928d160d 100644 --- a/examples/F90/set_missing_fortran.f90 +++ b/examples/F90/set_missing_fortran.f90 @@ -30,7 +30,7 @@ program set ! a new grib message is loaded from file ! igrib is the grib id to be used in subsequent calls - call codes_new_from_file(infile,igrib) + call codes_grib_new_from_file(infile,igrib) call codes_set(igrib,'typeOfFirstFixedSurface','sfc') call codes_set_missing(igrib,'scaleFactorOfFirstFixedSurface') diff --git a/examples/python/binary_message.py b/examples/python/binary_message.py index ed65ba320..91643d7d0 100644 --- a/examples/python/binary_message.py +++ b/examples/python/binary_message.py @@ -20,7 +20,7 @@ def example(): out = open(sys.argv[2],'w') while 1: - gid = codes_new_from_file(f) + gid = codes_grib_new_from_file(f) if gid is None: break message = codes_get_message(gid) diff --git a/examples/python/clone.py b/examples/python/clone.py index e41f088c0..4e09ac11b 100644 --- a/examples/python/clone.py +++ b/examples/python/clone.py @@ -22,7 +22,7 @@ def example(): fin = open(INPUT) fout = open(OUTPUT,'w') - gid = codes_new_from_file(fin) + gid = codes_grib_new_from_file(fin) nx = codes_get(gid,'Ni') ny = codes_get(gid,'Nj') diff --git a/examples/python/count_messages.py b/examples/python/count_messages.py index ac8eed998..6c5c746af 100644 --- a/examples/python/count_messages.py +++ b/examples/python/count_messages.py @@ -20,7 +20,7 @@ def example(): f = open(INPUT) mcount = codes_count_in_file(f) - gid_list = [codes_new_from_file(f) for i in range(mcount)] + gid_list = [codes_grib_new_from_file(f) for i in range(mcount)] f.close() diff --git a/examples/python/get.py b/examples/python/get.py index b7eb58f22..3003cd8da 100644 --- a/examples/python/get.py +++ b/examples/python/get.py @@ -27,7 +27,7 @@ def example(): ] while 1: - gid = codes_new_from_file(f) + gid = codes_grib_new_from_file(f) if gid is None: break for key in keys: diff --git a/examples/python/iterator.py b/examples/python/iterator.py index 76ca378cf..b2f447142 100644 --- a/examples/python/iterator.py +++ b/examples/python/iterator.py @@ -19,7 +19,7 @@ def example(INPUT): f = open(INPUT) while 1: - gid = codes_new_from_file(f) + gid = codes_grib_new_from_file(f) if gid is None: break iterid = codes_grib_iterator_new(gid,0) diff --git a/examples/python/keys_iterator.py b/examples/python/keys_iterator.py index e1ac2e7e3..0b9153d0a 100644 --- a/examples/python/keys_iterator.py +++ b/examples/python/keys_iterator.py @@ -20,7 +20,7 @@ def example(): f = open(INPUT) while 1: - gid = codes_new_from_file(f) + gid = codes_grib_new_from_file(f) if gid is None: break iterid = codes_keys_iterator_new(gid,'ls') diff --git a/examples/python/multi_write.py b/examples/python/multi_write.py index 212606d1b..88424b4ce 100644 --- a/examples/python/multi_write.py +++ b/examples/python/multi_write.py @@ -21,7 +21,7 @@ def example(): fin = open(INPUT) fout = open(OUTPUT,'w') - gid = codes_new_from_file(fin) + gid = codes_grib_new_from_file(fin) mgid = codes_grib_multi_new() diff --git a/examples/python/nearest.py b/examples/python/nearest.py index 322945b09..d714e1018 100644 --- a/examples/python/nearest.py +++ b/examples/python/nearest.py @@ -20,7 +20,7 @@ def example(): points = ((30,-20),(13,234)) f = open(INPUT) - gid = codes_new_from_file(f) + gid = codes_grib_new_from_file(f) for lat,lon in points: nearest = codes_grib_find_nearest(gid,lat,lon)[0] diff --git a/examples/python/print_data.py b/examples/python/print_data.py index 9d94f9302..b994cf373 100644 --- a/examples/python/print_data.py +++ b/examples/python/print_data.py @@ -18,7 +18,7 @@ VERBOSE=1 # verbose error reporting def example(): f = open(INPUT) - gid = codes_new_from_file(f) + gid = codes_grib_new_from_file(f) values = codes_get_values(gid) for i in xrange(len(values)): diff --git a/examples/python/samples.py b/examples/python/samples.py index 90aebf28e..0348514c6 100644 --- a/examples/python/samples.py +++ b/examples/python/samples.py @@ -34,7 +34,7 @@ def example(): prev_vals = None while 1: - gid = codes_new_from_file(fin) + gid = codes_grib_new_from_file(fin) if gid is None: break curr_vals = codes_get_values(gid) diff --git a/examples/python/set.py b/examples/python/set.py index 010fe1a49..17b4acdca 100644 --- a/examples/python/set.py +++ b/examples/python/set.py @@ -19,7 +19,7 @@ VERBOSE=1 # verbose error reporting def example(): fin = open(INPUT) fout = open(OUTPUT,'w') - gid = codes_new_from_file(fin) + gid = codes_grib_new_from_file(fin) dt = date.today() today = "%d%02d%02d" % (dt.year,dt.month,dt.day) diff --git a/examples/python/set_bitmap.py b/examples/python/set_bitmap.py index 40607f4c6..3707264f5 100644 --- a/examples/python/set_bitmap.py +++ b/examples/python/set_bitmap.py @@ -18,7 +18,7 @@ VERBOSE = 1 # verbose error reporting def example(): fin = open(INPUT) fout = open(OUTPUT,'w') - gid = codes_new_from_file(fin) + gid = codes_grib_new_from_file(fin) codes_set(gid,'missingValue', MISSING) values = codes_get_values(gid) diff --git a/examples/python/set_missing.py b/examples/python/set_missing.py index a477c96c9..89a1fd99a 100644 --- a/examples/python/set_missing.py +++ b/examples/python/set_missing.py @@ -21,7 +21,7 @@ def example(): fin = open(INPUT) fout = open(OUTPUT,'w') - gid = codes_new_from_file(fin) + gid = codes_grib_new_from_file(fin) codes_set_long(gid, "scaledValueOfFirstFixedSurface", 15); codes_set_long(gid, "scaleFactorOfFirstFixedSurface", 1) diff --git a/fortran/eccodes_f90_head.f90 b/fortran/eccodes_f90_head.f90 index 0a7ad55b2..4f7b05021 100644 --- a/fortran/eccodes_f90_head.f90 +++ b/fortran/eccodes_f90_head.f90 @@ -17,6 +17,11 @@ module eccodes include "eccodes_constants.h" include "eccodes_visibility.h" + integer, parameter,public :: CODES_PRODUCT_GRIB = 1 + integer, parameter,public :: CODES_PRODUCT_BUFR = 2 + integer, parameter,public :: CODES_PRODUCT_ANY = 3 + + !> Create a new message in memory from an integer or character array containting the coded message. !> !> The message can be accessed through its gribid and it will be available\n diff --git a/fortran/eccodes_f90_tail.f90 b/fortran/eccodes_f90_tail.f90 index e24665b04..1b0936d54 100644 --- a/fortran/eccodes_f90_tail.f90 +++ b/fortran/eccodes_f90_tail.f90 @@ -504,17 +504,35 @@ subroutine codes_headers_only_new_from_file ( ifile, gribid , status) call grib_headers_only_new_from_file ( ifile, gribid , status) end subroutine codes_headers_only_new_from_file +!------------------ +subroutine codes_new_from_file (ifile, gribid , product_kind, status) + integer(kind=kindOfInt),intent(in) :: ifile + integer(kind=kindOfInt),intent(out) :: gribid + integer(kind=kindOfInt),intent(in) :: product_kind + integer(kind=kindOfInt),optional,intent(out) :: status + integer(kind=kindOfInt) :: iret + + if (product_kind == CODES_PRODUCT_GRIB) then + call codes_grib_new_from_file ( ifile, gribid , status) + else if (product_kind == CODES_PRODUCT_BUFR) then + call codes_bufr_new_from_file ( ifile, gribid , status) + else + ! CODES_PRODUCT_ANY - Not yet implemented + call grib_check(1,'codes_new_from_file','invalid product_kind') + end if +end subroutine codes_new_from_file + ! -subroutine codes_new_from_file ( ifile, gribid , status) +subroutine codes_grib_new_from_file ( ifile, gribid , status) integer(kind=kindOfInt),intent(in) :: ifile integer(kind=kindOfInt),intent(out) :: gribid integer(kind=kindOfInt),optional,intent(out) :: status integer(kind=kindOfInt) :: iret call grib_new_from_file ( ifile, gribid , status) -end subroutine codes_new_from_file +end subroutine codes_grib_new_from_file -!! TODO: temporary fix for BUFR +! subroutine codes_bufr_new_from_file ( ifile, bufrid , status) integer(kind=kindOfInt),intent(in) :: ifile integer(kind=kindOfInt),intent(out) :: bufrid diff --git a/fortran/eccodes_visibility.h b/fortran/eccodes_visibility.h index 966d9c786..e28427a37 100644 --- a/fortran/eccodes_visibility.h +++ b/fortran/eccodes_visibility.h @@ -12,7 +12,8 @@ public :: codes_keys_iterator_get_name, & codes_keys_iterator_rewind public :: codes_new_from_message, & codes_new_from_samples, codes_new_from_file, & - codes_read_from_file,codes_headers_only_new_from_file + codes_grib_new_from_file, codes_bufr_new_from_file, & + codes_read_from_file,codes_headers_only_new_from_file public :: codes_release public :: codes_dump public :: codes_get_error_string @@ -23,4 +24,4 @@ public :: codes_check public :: codes_clone, codes_copy_namespace public :: codes_index_get,codes_index_select,& codes_index_create,codes_index_get_size,codes_index_release,& - codes_grib_util_sections_copy + codes_grib_util_sections_copy diff --git a/python/eccodes.py b/python/eccodes.py index 5a853f89b..a63d2d9d8 100644 --- a/python/eccodes.py +++ b/python/eccodes.py @@ -1,7 +1,5 @@ from gribapi import GRIB_CHECK as CODES_CHECK -from gribapi import grib_new_from_file as codes_new_from_file - -# TODO: temporary +from gribapi import grib_new_from_file as codes_grib_new_from_file from gribapi import bufr_new_from_file as codes_bufr_new_from_file from gribapi import grib_count_in_file as codes_count_in_file diff --git a/python/gribapi.py b/python/gribapi.py index fd09003ab..38e1f6fae 100644 --- a/python/gribapi.py +++ b/python/gribapi.py @@ -42,6 +42,13 @@ KEYTYPES = { 3:str, } +CODES_PRODUCT_GRIB=1 +""" GRIB product kind """ +CODES_PRODUCT_BUFR=2 +""" BUFR product kind """ +CODES_PRODUCT_ANY=3 +""" Generic product kind """ + # GRIB-51 Skip function arguments type checking if the # environment variable is defined no_type_checks = os.environ.get('GRIB_API_PYTHON_NO_TYPE_CHECKS') is not None @@ -173,6 +180,14 @@ def gts_new_from_file(fileobj, headers_only = False): else: return gribid +@require(fileobj=file,product_kind=int) +def codes_new_from_file(fileobj, product_kind, headers_only = False): + if product_kind == CODES_PRODUCT_GRIB: + return grib_new_from_file(fileobj, headers_only) + if product_kind == CODES_PRODUCT_BUFR: + return bufr_new_from_file(fileobj, headers_only) + raise Exception("Invalid product kind: " + product_kind) + @require(fileobj=file) def bufr_new_from_file(fileobj, headers_only = False): """