test_read_write_0d_string Subroutine

public subroutine test_read_write_0d_string()

Arguments

None

Calls

proc~~test_read_write_0d_string~~CallsGraph proc~test_read_write_0d_string test_read_write_0d_string assertequal assertequal proc~test_read_write_0d_string->assertequal asserttrue asserttrue proc~test_read_write_0d_string->asserttrue none~add_variable FileMetadata%add_variable proc~test_read_write_0d_string->none~add_variable none~create~2 NetCDF4_FileFormatter%create proc~test_read_write_0d_string->none~create~2 none~get_var~22 NetCDF4_FileFormatter%get_var proc~test_read_write_0d_string->none~get_var~22 none~inq_var_string_length NetCDF4_FileFormatter%inq_var_string_length proc~test_read_write_0d_string->none~inq_var_string_length none~put_var~22 NetCDF4_FileFormatter%put_var proc~test_read_write_0d_string->none~put_var~22 at at none~add_variable->at begin begin none~add_variable->begin get get none~add_variable->get interface~mapl_assert MAPL_Assert none~add_variable->interface~mapl_assert next next none~add_variable->next none~get_const_value Variable%get_const_value none~add_variable->none~get_const_value none~get_dimensions Variable%get_dimensions none~add_variable->none~get_dimensions none~get_shape UnlimitedEntity%get_shape none~add_variable->none~get_shape none~insert~63 StringVariableMap%insert none~add_variable->none~insert~63 none~is_empty UnlimitedEntity%is_empty none~add_variable->none~is_empty proc~mapl_return MAPL_Return none~add_variable->proc~mapl_return push_back push_back none~add_variable->push_back nf90_create nf90_create none~create~2->nf90_create none~create~2->proc~mapl_return proc~mapl_verify MAPL_Verify none~create~2->proc~mapl_verify none~get_var_real64_4 NetCDF4_FileFormatter%get_var_real64_4 none~get_var~22->none~get_var_real64_4 nf90_inq_varid nf90_inq_varid none~inq_var_string_length->nf90_inq_varid none~inq_var_string_length->proc~mapl_return none~inq_var_string_length->proc~mapl_verify proc~pfio_nf90_get_var_string_len pfio_nf90_get_var_string_len none~inq_var_string_length->proc~pfio_nf90_get_var_string_len none~put_var_real64_4 NetCDF4_FileFormatter%put_var_real64_4 none~put_var~22->none~put_var_real64_4

Source Code

   subroutine test_read_write_0d_string()
      type (NetCDF4_FileFormatter) :: formatter
      character(len=:), allocatable :: char_write
      character(len=:), allocatable :: char_read
      type (FileMetadata) :: metadata
      integer :: status, length
      type (Variable) :: v

      v = Variable(type=pFIO_STRING)
      call metadata%add_variable('new_char',v)
      char_write = "I am 0d String"

      call formatter%create('test.nc', mode=PFIO_CLOBBER, rc=status)
      @assertEqual(NF90_NOERR, status)
      call formatter%write(metadata, rc=status)
      @assertEqual(NF90_NOERR, status)
      call formatter%put_var('new_char', char_write)
      call formatter%close(rc=status)
      @assertEqual(NF90_NOERR, status)

      call formatter%open('test.nc', PFIO_READ, rc=status)
      @assertEqual(NF90_NOERR, status)
      call formatter%inq_var_string_length('new_char',length)
      allocate(character(len=length):: char_read)
      call formatter%get_var('new_char', char_read)
      call formatter%close()

      @assertTrue(char_write == char_read)

   end subroutine test_read_write_0d_string