Index: flexpart_code/fpmetbinary_mod.F90
===================================================================
--- flexpart_code/fpmetbinary_mod.F90	(revision 5f50284edd2756b2281689ed836a9a1f50391c1f)
+++ flexpart_code/fpmetbinary_mod.F90	(revision 515b21c06ac454a3edcdd8f8fcbbaafcaa3d2291)
@@ -55,9 +55,17 @@
     INTEGER, PARAMETER :: IOUNIT_DUMP = 33, IOUNIT_LOAD = 34, &
                           IOUNIT_TEXTOUT = 35
+                          
+                   
+    INTEGER, PARAMETER :: PREPROC_FMT_STR_DIM = 11
 
     ! When a change is made to the format of the preprocessed file, such that
     ! this routine will not be able to read a previous version, this version
     ! string should be modified
-    CHARACTER(LEN=12), PARAMETER :: PREPROC_FORMAT_VERSION_STR = 'FP_p-9.3.1'//char(0)
+
+
+    ! WARNING - for now, for NC4 compatability, make sure that the PREPROC_FMT_STR_DIM 
+    ! defined above is exactly the length of the string PLUS the null character added
+    ! I've had a hell of a time making it all compatible with NC4 (DJM)
+    CHARACTER(LEN=PREPROC_FMT_STR_DIM), PARAMETER :: PREPROC_FORMAT_VERSION_STR = 'FP_p-9.3.1'//char(0)
 
     PRIVATE IOUNIT_DUMP, IOUNIT_LOAD, IOUNIT_TEXTOUT, fpio,    &
@@ -331,5 +339,5 @@
 &                  maxspec_dimid, numclass_dimid, maxnests_dimid, nxmaxn_dimid, nymaxn_dimid, &
 &                  zero_to_nzmax_dimid, zero_to_maxnests_dimid, polemap_dimid, &
-&                  nconvlevmax_dimid, na_dimid
+&                  nconvlevmax_dimid, na_dimid, preproc_fmt_str_dimid
 
 
@@ -349,5 +357,6 @@
 &                                       maxnests_dimname, nxmaxn_dimname, nymaxn_dimname, &
 &                                       zero_to_nzmax_dimname, zero_to_maxnests_dimname, &
-&                                       polemap_dimname, nconvlevmax_dimname, na_dimname
+&                                       polemap_dimname, nconvlevmax_dimname, na_dimname, &
+&                                       preproc_fmt_str_dimname
 
         ! These are temporary variables, used in the LOAD option, for 
@@ -356,7 +365,7 @@
 &                  temp_nuvzmax, temp_nwzmax, &
 &                  temp_maxspec, temp_numclass,&
-&                  temp_maxnests, temp_nxmaxn, temp_nymaxn
-
-        CHARACTER(LEN=12) :: temp_preproc_format_version_str
+&                  temp_maxnests, temp_nxmaxn, temp_nymaxn, temp_preproc_fmt_str_dim
+
+        CHARACTER(LEN=PREPROC_FMT_STR_DIM) :: temp_preproc_format_version_str
 
         CHARACTER(LEN=128) :: errmesg
@@ -385,4 +394,11 @@
 
 
+            ! Dimension for the preprocessing format string
+            ncret = nf90_def_dim(ncid, 'preproc_fmt_str_dim', PREPROC_FMT_STR_DIM, &
+&                                preproc_fmt_str_dimid)
+            call handle_nf90_err(ncret)
+PRINT *, '1'
+
+
             ncret = nf90_def_dim(ncid, 'nxmax', nxmax, nxmax_dimid)
             call handle_nf90_err(ncret)
@@ -418,4 +434,18 @@
 
             ! Scalar values
+
+
+            dim1dids = (/preproc_fmt_str_dimid/)
+            ncret = nf90_def_var(ncid, 'preproc_fmt_str', NF90_CHAR, &
+&                                       dim1dids, ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_def_var_deflate(ncid, ncvarid,   &
+&                                        shuffle=0,     &
+&                                        deflate=1,     &
+&                                        deflate_level=DEF_LEVEL)
+            call handle_nf90_err(ncret)
+            ncret = nf90_put_var(ncid, ncvarid, PREPROC_FORMAT_VERSION_STR(1:preproc_fmt_str_dim)) 
+            call handle_nf90_err(ncret)
+
 
 
@@ -604,5 +634,4 @@
             WRITE(iounit) cloudsh(:,:,cm_index)
 #endif
-
 
 
@@ -833,5 +862,4 @@
 
 
-
             dim2dids = (/nxmax_dimid, nymax_dimid/)
 
@@ -2211,9 +2239,29 @@
 
 
+
+
+
+
+
 #ifdef RAWBIN
             READ (iounit) temp_preproc_format_version_str
+#endif
+
+
+            ncret = nf90_inq_dimid(ncid, 'preproc_fmt_str_dim', preproc_fmt_str_dimid)
+            call handle_nf90_err(ncret)            
+            ncret = nf90_inquire_dimension(ncid, preproc_fmt_str_dimid, preproc_fmt_str_dimname, &
+&                                                temp_preproc_fmt_str_dim)
+            call handle_nf90_err(ncret)
+            PRINT *, 'temp_preproc_fmt_str_dim: ', temp_preproc_fmt_str_dim
+
+            ncret = nf90_inq_varid(ncid, 'preproc_fmt_str', ncvarid)
+            call handle_nf90_err(ncret)
+            ncret = nf90_get_var(ncid, ncvarid, temp_preproc_format_version_str(1:temp_preproc_fmt_str_dim))
+            call handle_nf90_err(ncret)
+
+
             PRINT *, 'Reading preprocessed file format version: ', &
 &                    temp_preproc_format_version_str
-
             IF (TRIM(temp_preproc_format_version_str) == &
 &                                        TRIM(PREPROC_FORMAT_VERSION_STR)) THEN
@@ -2227,5 +2275,5 @@
                 STOP
             END IF
-#endif
+
 
 
@@ -2247,9 +2295,12 @@
 
 
-PRINT *, 'GET DIMENSIONS'
+
             ! Get dimensions
+            
+            
+
+
             ncret = nf90_inq_dimid(ncid, 'nxmax', nxmax_dimid)
-            call handle_nf90_err(ncret)
-PRINT *, 'GOT nxmax_dimid'            
+            call handle_nf90_err(ncret)            
             ncret = nf90_inquire_dimension(ncid, nxmax_dimid, nxmax_dimname, &
 &                                                temp_nxmax)
@@ -2257,5 +2308,4 @@
             PRINT *, 'temp_nxmax: ', temp_nxmax
 
-PRINT *, 'GOT temp_nxmax'
 
             ncret = nf90_inq_dimid(ncid, 'nymax', nymax_dimid)
@@ -2302,6 +2352,4 @@
 
 
-
-PRINT *, 'CHECK DIMENSIONS'
 
             IF ( (temp_nxmax == nxmax) .AND. (temp_nymax == nymax) .AND. &
@@ -2340,7 +2388,4 @@
 
 
-
-
-PRINT *, 'GET SCALARS'
 
             ! Get the varid , then read into scalar variable
