diff --git a/Sources/Tests/test_local_extrema.f b/Sources/Tests/test_local_extrema.f index ca673400289968c1b6b7db7490317f538e099b0e..e2b70c0cb5252585a377d3bbe4549e4921c84752 100644 --- a/Sources/Tests/test_local_extrema.f +++ b/Sources/Tests/test_local_extrema.f @@ -10,34 +10,42 @@ program test_local_extrema implicit none - integer, parameter:: ilon_llc = 21, ilat_llc = 215 ! lower left corner - integer, parameter:: ilon_urc = 49, ilat_urc = 231 ! upper right corner - integer, parameter:: nlon = ilon_urc - ilon_llc + 1 - integer, parameter:: nlat = ilat_urc - ilat_llc + 1 + integer:: ilon_llc = 21, ilat_llc = 215 ! lower left corner + integer:: ilon_urc = 49, ilat_urc = 231 ! upper right corner + integer nlon, nlat integer ncid, varid, dimid_lat, dimid_lon integer varid_lat, varid_lon, varid_extr_map integer i, length, status, unit character(len = :), allocatable:: filename - real longitude(nlon), latitude(nlat) ! in degrees - real ssh(nlon, nlat) ! sea-surface height, in m + real, allocatable:: longitude(:) ! (nlon) in degrees + real, allocatable:: latitude(:) ! (nlat) in degrees + real, allocatable:: ssh(:, :) ! (nlon, nlat) sea-surface height, in m + integer, allocatable:: extr_map(:, :) ! (nlon, nlat) map of extrema integer, allocatable:: ind_extr(:, :) ! (2, n_extr) ! indices in the two dimensions of extrema - integer extr_map(nlon, nlat) ! map of extrema - real, allocatable:: innermost_level(:) ! (n_extr) ! level of innermost contour, for each extremum logical, allocatable:: cyclone(:) ! (n_extr) + namelist /main_nml/ ilon_llc, ilat_llc, ilon_urc, ilat_urc + !--------------------------------------------------------------------- - call get_command_argument(1, length = length, status = status) + call get_command_argument(number = 1, length = length, status = status) call assert(status == 0, "Required argument: ADT file") allocate(character(len = length):: filename) call get_command_argument(1, filename) + + print *, "Enter namelist main_nml." + read(unit = *, nml = main_nml) + nlon = ilon_urc - ilon_llc + 1 + nlat = ilat_urc - ilat_llc + 1 + allocate(longitude(nlon), latitude(nlat)) + allocate(ssh(nlon, nlat), extr_map(nlon, nlat)) call nf95_open(filename, nf90_nowrite, ncid) @@ -70,7 +78,7 @@ program test_local_extrema end do close(unit) print *, 'Created file "test_local_extrema.csv".' - + call nf95_create("test_local_extrema.nc", NF90_CLOBBER, ncid) call nf95_def_dim(ncid, "lat", nlat, dimid_lat) @@ -79,11 +87,11 @@ program test_local_extrema call nf95_def_var(ncid, "lat", NF90_FLOAT, dimid_lat, varid_lat) call nf95_put_att(ncid, varid_lat, "standard_name", "latitude") call nf95_put_att(ncid, varid_lat, "units", "degrees_north") - + call nf95_def_var(ncid, "lon", NF90_FLOAT, dimid_lon, varid_lon) call nf95_put_att(ncid, varid_lon, "standard_name", "longitude") call nf95_put_att(ncid, varid_lon, "units", "degrees_east") - + call nf95_def_var(ncid, "extr_map", NF90_INT, [dimid_lon, dimid_lat], & varid_extr_map) diff --git a/Sources/Tests/test_local_extrema.py b/Sources/Tests/test_local_extrema.py index 63675ab19aa081cf74b58391949d04b9e4b09f3e..7003e6a04e45fc60299ece6a81d9606848a9ffec 100755 --- a/Sources/Tests/test_local_extrema.py +++ b/Sources/Tests/test_local_extrema.py @@ -12,11 +12,11 @@ if len(sys.argv) != 2: sys.exit("Required argument: ADT file") f= netCDF4.Dataset(sys.argv[1]) # Lower left corner (llc): -ilon_llc = np.searchsorted(f.variables["lon"], 5) -ilat_llc = np.searchsorted(f.variables["lat"], -36.5) +ilon_llc = np.searchsorted(f.variables["lon"], 6.125) +ilat_llc = np.searchsorted(f.variables["lat"], -38.125) # Upper right corner (urc): -ilon_urc = np.searchsorted(f.variables["lon"], 12) -ilat_urc = np.searchsorted(f.variables["lat"], -32.5) +ilon_urc = np.searchsorted(f.variables["lon"], 12.625) +ilat_urc = np.searchsorted(f.variables["lat"], -34.125) print("ilon_llc = ", ilon_llc) print("ilat_llc = ", ilat_llc) diff --git a/Sources/Tests/tests_detection_eddies.sh b/Sources/Tests/tests_detection_eddies.sh index 6511ff0f3b74835cb679d234c6f179cf213ebfe7..d692b8379b657cb7cc4be11326e5b048772dd138 100755 --- a/Sources/Tests/tests_detection_eddies.sh +++ b/Sources/Tests/tests_detection_eddies.sh @@ -9,7 +9,9 @@ src_tests_dir=~/Documents/Informatique_fonctionnement/Programs/Detection_eddies/ $compil_prod_dir/test_good_contour -$compil_prod_dir/test_local_extrema h_2006_01_01.nc +$compil_prod_dir/test_local_extrema h_2006_01_01.nc <<EOF +&main_nml / +EOF $src_tests_dir/test_local_extrema.py h_2006_01_01.nc $compil_prod_dir/test_inside diff --git a/Sources/get_eddy.f b/Sources/get_eddy.f index fad88e26e162266bc2a985ee15758beef1488c9c..4fb909f6c7ce9da619e858b8bb6738b3d3fd8af1 100644 --- a/Sources/get_eddy.f +++ b/Sources/get_eddy.f @@ -9,12 +9,12 @@ contains use contour_531, only: convert_to_reg_coord, convert_to_ind use derived_types, only: eddy + use get_outermost_contour_m, only: get_outermost_contour use good_contour_m, only: good_contour use max_speed_contour_ssh_m, only: max_speed_contour_ssh use mean_speed_m, only: mean_speed - use get_outermost_contour_m, only: get_outermost_contour + use nr_util, only: pack_indices use outermost_possible_level_m, only: outermost_possible_level - use pack_indices_m, only: pack_indices use spherical_polygon_area_m, only: spherical_polygon_area real, intent(in):: ssh(:, :), u(:, :), v(:, :) diff --git a/Sources/pack_indices.f b/Sources/pack_indices.f deleted file mode 100644 index e87941bd206ebefd3adeba0502bdaf58abbfb8e7..0000000000000000000000000000000000000000 --- a/Sources/pack_indices.f +++ /dev/null @@ -1,37 +0,0 @@ -module pack_indices_m - - implicit none - -contains - - pure function pack_indices(my_array, excluded) - - ! Returns the indices of the elements not excluded in my_array. - - integer, allocatable:: pack_indices(:, :) ! (2, n_packed) - integer, intent(in):: my_array(:, :) ! (m, :) - integer, intent(in):: excluded(:) ! excluded values of my_array - - ! Local: - integer n_packed, i, j, m - integer t(2, size(my_array)) ! Maximum number of packed elements is m * n. - - !--------------------------------------------------------------- - - m = size(my_array, 1) - n_packed = 0 - - do j = 1, size(my_array, 2) - do i = 1, m - if (all(my_array(i, j) /= excluded)) then - n_packed = n_packed + 1 - t(:, n_packed) = [i, j] - end if - end do - end do - - pack_indices = t(:, :n_packed) - - end function pack_indices - -end module pack_indices_m diff --git a/depend.mk b/depend.mk index 162e962f666078f805c2dc01e41c7908692e5c61..e5bfb95ead52645940db019baadee8b6f3c7dec4 100644 --- a/depend.mk +++ b/depend.mk @@ -1,5 +1,5 @@ dispatch_snapshot.o : write_eddy.o send_snapshot.o derived_types.o -get_eddy.o : spherical_polygon_area.o pack_indices.o outermost_possible_level.o get_outermost_contour.o mean_speed.o max_speed_contour_ssh.o good_contour.o derived_types.o +get_eddy.o : spherical_polygon_area.o outermost_possible_level.o mean_speed.o max_speed_contour_ssh.o good_contour.o get_outermost_contour.o derived_types.o get_snapshot.o : receive_snapshot.o local_extrema.o get_eddy.o derived_types.o max_speed_contour_ssh.o : inside.o get_outermost_contour.o : spherical_polygon_area.o derived_types.o good_contour.o diff --git a/file_list b/file_list index b0cb0597a480139547bf33a0fcdf4a9604194652..166bce50390eebee7c1950662ba245a83088ce52 100644 --- a/file_list +++ b/file_list @@ -9,7 +9,6 @@ max_speed_contour_ssh.f mean_speed.f get_outermost_contour.f outermost_possible_level.f -pack_indices.f receive_snapshot.f send_snapshot.f spherical_polygon_area.f