Wednesday 25 June 2014

OSX command line user admin

Setting up and modifying user accounts via the command line on OSX is a bit of pain. The supplied tools to do it require one to not only set reasonable things, such as login name, but to also choose a unique id, assign a primary group etc., things that the graphical way of creating users automatically populate with sensible defaults.

Examples of when one might need to do this are: when a machine is only accessible via ssh; when a sysadmin wants a script to run on multiple machines to setup a series of user accounts.

On Linux there are utilities such as useradd which has many options, but crucially has sensible defaults such that in practice only a few need be specified to create a new account, eg.:

useradd -m -c 'Joe Bloggs' joe

Inspired by personal experience of attempting to create a new user account on an OSX machine via ssh, I wrote versions of useradd etc. for OSX, which are available here. Of course I only implemented the features that I needed at the time... but will perhaps make them more complete in the future.

Wednesday 18 June 2014

Fortran module filenames

The Fortran standard does not define a rule as to the filename format of F90 module files. In fact, some (mostly old) compilers don't even use module files at all, instead embedding the modules within the object files.

The autoconf package provides a macro, AC_FC_MODULE_EXTENSION, which can be used to determine the file suffix of module files for a compiler, although currently it only handles cases when the file basename is the module name either in upper or lower case. However, there appears no macro that actually returns the format of the module file. For example a module named test could result in one of:
  • test.mod
  • TEST.mod
  • test.MOD
  • TEST.MOD
being created.

As a result I wrote a new macro MAY_FC_MODULE_FILENAME_FORMAT available here which returns the filename format of module files in the variable FC_MODFMT. For the cases listed above the values of FC_MODFMT returned are:
  • %m.mod
  • %M.mod
  • %m.MOD
  • %M.MOD

As mentioned there are other less common possibilities, these are not currently implemented but will be if I need them or if there is demand.

Hello world

1st post