[mpas-developers] trunk commit: I/O for character variables

Michael Duda duda at ucar.edu
Mon Mar 11 18:01:49 MDT 2013


Hi, All.

I have a bug fix that I'd like to commit to the trunk. The bug only
affects time-independent scalar character variables, where we try to
read or write the variable with length StrKIND, which is equal to 512,
despite defining the variable with a truncated length of 64 in the file.
Automatic truncation is handled for scalar character variables with a
time dimension, and the fix is essentially to do the same for
time-independent character variables. Here are the changes in mpas_io.F
(original on the left, new on the right):

1251c1251,1254
<             pio_ierr = PIO_get_var(handle % pio_file, field_cursor % fieldhandle % field_desc, charVal)
---
>             start1(1) = 1
>             count1(1) = field_cursor % fieldhandle % dims(1) % dimsize
>             pio_ierr = PIO_get_var(handle % pio_file, field_cursor % fieldhandle % fieldid, start1, count1, tempchar)
>             charVal(1:count1(1)) = tempchar(1)(1:count1(1))
1646c1649,1651
<             pio_ierr = PIO_put_var(handle % pio_file, field_cursor % fieldhandle % field_desc, charVal)
---
>             start1(1) = 1
>             count1(1) = field_cursor % fieldhandle % dims(1) % dimsize
>             pio_ierr = PIO_put_var(handle % pio_file, field_cursor % fieldhandle % fieldid, start1, count1, (/charVal/))

If anyone would like to test this by, e.g., defining a variable like

   var persistent text    foo ( ) 0 so foo mesh - -

a patch version of mpas_io.F already exists in
branches/atmos_physics/src/framework/.

If there are no objections or suggestions for improvement, I'll go ahead
and commit this fix to the trunk in the next couple of days.

Thanks,
Michael 


More information about the mpas-developers mailing list