Skip to content

Commit 22dfe08

Browse files
authored
Fix some errors find by Address Sanitizer (#1795)
1 parent 734eb8c commit 22dfe08

4 files changed

Lines changed: 34 additions & 23 deletions

File tree

mpp/include/mpp_domains_misc.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ end subroutine init_nonblock_type
331331
! Force use of "scalar", integer pointer mpp interface
332332
call mpp_send(ibounds(1), plen=4, to_pe=pelist2(1), tag=COMM_TAG_1)
333333
call mpp_send(send_buffer(1),plen=im*jm, to_pe=pelist2(1), tag=COMM_TAG_2)
334-
deallocate(send_buffer)
335334

336335
else if(pelist2(1) == pe) then ! receive data and compare
337336
do p = pelist1(1), pelist1(size(pelist1(:)))
@@ -366,12 +365,13 @@ end subroutine init_nonblock_type
366365
print*, trim(mesg)//": ", 'comparison between 1 pe and ', npes-1, ' pes is ok'
367366
endif
368367
! release memery
369-
deallocate(field1, send_buffer)
368+
deallocate(field1)
370369
endif
371370

372371
deallocate(field2)
373372

374373
call mpp_sync()
374+
if (allocated(send_buffer)) deallocate(send_buffer)
375375

376376
end subroutine mpp_check_field_2d_type1
377377

mpp/include/mpp_util_mpi.inc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,24 @@ subroutine mpp_error_basic( errortype, errormsg )
3838
#endif
3939
integer, intent(in) :: errortype
4040
character(len=*), intent(in), optional :: errormsg
41-
character(len=512) :: text
41+
character(len=512) :: text, text_errortype
4242
integer :: errunit
4343
4444
if( .NOT.module_is_initialized )call ABORT()
4545
4646
select case( errortype )
4747
case(NOTE)
48-
text = 'NOTE' !just FYI
48+
text_errortype = 'NOTE' !just FYI
4949
case(WARNING)
50-
text = 'WARNING' !probable error
50+
text_errortype = 'WARNING' !probable error
5151
case(FATAL)
52-
text = 'FATAL' !fatal error
52+
text_errortype = 'FATAL' !fatal error
5353
case default
54-
text = 'WARNING: non-existent errortype (must be NOTE|WARNING|FATAL)'
54+
text_errortype = 'WARNING: non-existent errortype (must be NOTE|WARNING|FATAL)'
5555
end select
5656
57-
if( npes.GT.1 )write( text,'(a,i6)' )trim(text)//' from PE', pe !this is the mpp part
58-
if( PRESENT(errormsg) )text = trim(text)//': '//trim(errormsg)
57+
if( npes.GT.1 ) write( text,'(a,i6)' ) trim(text_errortype) // ' from PE', pe !this is the mpp part
58+
if( PRESENT(errormsg) )text = trim(text) // ': ' // trim(errormsg)
5959
!$OMP CRITICAL (MPP_ERROR_CRITICAL)
6060
select case( errortype )
6161
case(NOTE)

test_fms/diag_manager/test_diag_update_buffer.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ program test_diag_update_buffer
183183
diag_field_id = 1
184184
sample = 1
185185
weight = 1.0
186-
missvalue = 1.0e-5
186+
missvalue = 1.0e-5_r4_kind
187187
pow_value = 1
188188
phys_window = .false.
189189
need_compute = .false.

test_fms/exchange/test_xgrid.F90

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,8 @@ program xgrid_test
781781

782782
subroutine test_unstruct_exchange()
783783

784-
real(r8_kind), allocatable :: atm_data_in(:,:), atm_data_sg(:,:)
784+
real(r8_kind), allocatable :: atm_data_in_0(:,:), atm_data_in_1(:,:), atm_data_in_2(:,:), atm_data_in_3(:,:)
785+
real(r8_kind), allocatable :: atm_data_sg(:,:)
785786
real(r8_kind), allocatable :: atm_data_sg_1(:,:), atm_data_sg_2(:,:), atm_data_sg_3(:,:)
786787
real(r8_kind), allocatable :: lnd_data_sg(:,:,:), ice_data_sg(:,:,:)
787788
real(r8_kind), allocatable :: atm_data_ug(:,:), tmp_sg(:,:,:)
@@ -877,12 +878,18 @@ subroutine test_unstruct_exchange()
877878
allocate(atm_data_ug_2(isc_atm:iec_atm, jsc_atm:jec_atm ) )
878879
allocate(atm_data_ug_3(isc_atm:iec_atm, jsc_atm:jec_atm ) )
879880

880-
allocate(atm_data_in(isc_atm:iec_atm, jsc_atm:jec_atm ) )
881+
allocate(atm_data_in_0(isc_atm:iec_atm, jsc_atm:jec_atm ) )
882+
allocate(atm_data_in_1(isc_atm:iec_atm, jsc_atm:jec_atm ) )
883+
allocate(atm_data_in_2(isc_atm:iec_atm, jsc_atm:jec_atm ) )
884+
allocate(atm_data_in_3(isc_atm:iec_atm, jsc_atm:jec_atm ) )
881885
allocate(atm_data_sg(isc_atm:iec_atm, jsc_atm:jec_atm ) )
882886
allocate(atm_data_sg_1(isc_atm:iec_atm, jsc_atm:jec_atm ) )
883887
allocate(atm_data_sg_2(isc_atm:iec_atm, jsc_atm:jec_atm ) )
884888
allocate(atm_data_sg_3(isc_atm:iec_atm, jsc_atm:jec_atm ) )
885-
atm_data_in = 0
889+
atm_data_in_0 = 0
890+
atm_data_in_1 = 0
891+
atm_data_in_2 = 0
892+
atm_data_in_3 = 0
886893
atm_data_sg = 0
887894
atm_data_sg_1 = 0
888895
atm_data_sg_2 = 0
@@ -914,11 +921,14 @@ subroutine test_unstruct_exchange()
914921
x_3 = 0
915922
x_4 = 0
916923

917-
call random_number(atm_data_in)
918-
call put_to_xgrid(atm_data_in, 'ATM', x_1, Xmap, remap_method=remap_method)
919-
call put_to_xgrid(atm_data_in+1, 'ATM', x_2, Xmap, remap_method=remap_method, complete=.false.)
920-
call put_to_xgrid(atm_data_in+2, 'ATM', x_3, Xmap, remap_method=remap_method, complete=.false.)
921-
call put_to_xgrid(atm_data_in+3, 'ATM', x_4, Xmap, remap_method=remap_method, complete=.true.)
924+
call random_number(atm_data_in_0)
925+
atm_data_in_1 = atm_data_in_0 + 1
926+
atm_data_in_2 = atm_data_in_0 + 2
927+
atm_data_in_3 = atm_data_in_0 + 3
928+
call put_to_xgrid(atm_data_in_0, 'ATM', x_1, Xmap, remap_method=remap_method)
929+
call put_to_xgrid(atm_data_in_1, 'ATM', x_2, Xmap, remap_method=remap_method, complete=.false.)
930+
call put_to_xgrid(atm_data_in_2, 'ATM', x_3, Xmap, remap_method=remap_method, complete=.false.)
931+
call put_to_xgrid(atm_data_in_3, 'ATM', x_4, Xmap, remap_method=remap_method, complete=.true.)
922932
call get_from_xgrid(lnd_data_sg, 'LND', x_1, xmap)
923933
call get_from_xgrid(ice_data_sg, 'OCN', x_1, xmap)
924934
call put_to_xgrid(lnd_data_sg, 'LND', x_2, xmap)
@@ -936,10 +946,10 @@ subroutine test_unstruct_exchange()
936946
y_3 = 0
937947
y_4 = 0
938948

939-
call put_to_xgrid(atm_data_in, 'ATM', y_1, Xmap_ug, remap_method=remap_method)
940-
call put_to_xgrid(atm_data_in+1, 'ATM', y_2, Xmap_ug, remap_method=remap_method, complete=.false.)
941-
call put_to_xgrid(atm_data_in+2, 'ATM', y_3, Xmap_ug, remap_method=remap_method, complete=.false.)
942-
call put_to_xgrid(atm_data_in+3, 'ATM', y_4, Xmap_ug, remap_method=remap_method, complete=.true.)
949+
call put_to_xgrid(atm_data_in_0, 'ATM', y_1, Xmap_ug, remap_method=remap_method)
950+
call put_to_xgrid(atm_data_in_1, 'ATM', y_2, Xmap_ug, remap_method=remap_method, complete=.false.)
951+
call put_to_xgrid(atm_data_in_2, 'ATM', y_3, Xmap_ug, remap_method=remap_method, complete=.false.)
952+
call put_to_xgrid(atm_data_in_3, 'ATM', y_4, Xmap_ug, remap_method=remap_method, complete=.true.)
943953
call get_from_xgrid_ug(lnd_data_ug, 'LND', y_1, xmap_ug)
944954
call get_from_xgrid(ice_data_ug, 'OCN', y_1, xmap_ug)
945955
call put_to_xgrid_ug(lnd_data_ug, 'LND', y_2, xmap_ug)
@@ -967,7 +977,8 @@ subroutine test_unstruct_exchange()
967977

968978
if(ice_pe) deallocate(ice_data_sg, ice_data_ug)
969979
deallocate(tmp_sg, x_1, x_2, x_3, x_4, y_1, y_2, y_3, y_4)
970-
deallocate(atm_data_in, atm_data_sg)
980+
deallocate(atm_data_in_0, atm_data_in_1, atm_data_in_2, atm_data_in_3)
981+
deallocate(atm_data_sg)
971982
deallocate(atm_data_sg_1, atm_data_sg_2, atm_data_sg_3)
972983
deallocate(atm_data_ug)
973984
deallocate(atm_data_ug_1, atm_data_ug_2, atm_data_ug_3)

0 commit comments

Comments
 (0)