From 4e0f5f1090a8b62be30bc09b2ec2e8b2e55ce3f6 Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ens.fr> Date: Wed, 7 Jun 2023 22:09:19 +0200 Subject: [PATCH] Write speed to shapefile `cont_list` --- Inst_eddies/Tests/cont_list.f90 | 8 ++++---- Inst_eddies/set_max_speed.F90 | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Inst_eddies/Tests/cont_list.f90 b/Inst_eddies/Tests/cont_list.f90 index 69daaa32..c6b5bd33 100644 --- a/Inst_eddies/Tests/cont_list.f90 +++ b/Inst_eddies/Tests/cont_list.f90 @@ -6,6 +6,7 @@ module cont_list_m TYPE(shpfileobject), protected, save:: hshp_cont_list logical, protected:: write_cont_list = .false. + integer, save:: ifield_ssh, ifield_speed private shpfileobject @@ -16,13 +17,12 @@ contains use shapelib, only: ftdouble, shpt_polygon use shapelib_03, only: shp_create_03, dbf_add_field_03 - ! Local: - integer ifield - !--------------------------------------------------------------- call shp_create_03("cont_list", shpt_polygon, hshp_cont_list) - call dbf_add_field_03(ifield, hshp_cont_list, 'ssh', ftdouble, & + call dbf_add_field_03(ifield_ssh, hshp_cont_list, 'ssh', ftdouble, & + nwidth = 13, ndecimals = 6) + call dbf_add_field_03(ifield_speed, hshp_cont_list, 'speed', ftdouble, & nwidth = 13, ndecimals = 6) write_cont_list = .true. diff --git a/Inst_eddies/set_max_speed.F90 b/Inst_eddies/set_max_speed.F90 index 53afe9f3..322d7d62 100644 --- a/Inst_eddies/set_max_speed.F90 +++ b/Inst_eddies/set_max_speed.F90 @@ -29,7 +29,8 @@ contains use good_contour_m, only: good_contour use mean_speed_m, only: mean_speed use spher_polyline_area_m, only: spher_polyline_area - use cont_list_m, only: write_cont_list, hshp_cont_list + use cont_list_m, only: write_cont_list, hshp_cont_list, ifield_ssh, & + ifield_speed type(ssh_contour), intent(out):: speed_cont @@ -115,8 +116,17 @@ contains do i = 1, n_cont call shp_append_object_03(ishape, hshp_cont_list, shpt_polygon, & cont_list(i)%points * rad_to_deg) - call dbf_write_attribute_03(hshp_cont_list, ishape, ifield = 0, & + call dbf_write_attribute_03(hshp_cont_list, ishape, ifield_ssh, & fieldvalue = cont_list(i)%ssh) + + if (ieee_is_nan(speed(i))) then + call dbf_write_attribute_03(hshp_cont_list, ishape, ifield_speed, & + missing_speed) + ! (Cannot write NaN to dbf file.) + else + call dbf_write_attribute_03(hshp_cont_list, ishape, ifield_speed, & + speed(i)) + end if end do end if #endif -- GitLab